Rev 193 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 193 | Rev 194 | ||
---|---|---|---|
Line 141... | Line 141... | ||
141 | READ_WIDESTRING (options.part_letters.knight, inifile, L"abbreviations", L"knight", L"N"); options.part_letters.knight[0] = towupper (options.part_letters.knight[0]); options.part_letters.knight[1] = 0; // sanitize |
141 | READ_WIDESTRING (options.part_letters.knight, inifile, L"abbreviations", L"knight", L"N"); options.part_letters.knight[0] = towupper (options.part_letters.knight[0]); options.part_letters.knight[1] = 0; // sanitize |
142 | READ_WIDESTRING (options.part_letters.bishop, inifile, L"abbreviations", L"bishop", L"B"); options.part_letters.bishop[0] = towupper (options.part_letters.bishop[0]); options.part_letters.bishop[1] = 0; // sanitize |
142 | READ_WIDESTRING (options.part_letters.bishop, inifile, L"abbreviations", L"bishop", L"B"); options.part_letters.bishop[0] = towupper (options.part_letters.bishop[0]); options.part_letters.bishop[1] = 0; // sanitize |
143 | READ_WIDESTRING (options.part_letters.queen, inifile, L"abbreviations", L"queen", L"Q"); options.part_letters.queen[0] = towupper (options.part_letters.queen[0]); options.part_letters.rook[1] = 0; // sanitize |
143 | READ_WIDESTRING (options.part_letters.queen, inifile, L"abbreviations", L"queen", L"Q"); options.part_letters.queen[0] = towupper (options.part_letters.queen[0]); options.part_letters.rook[1] = 0; // sanitize |
144 | READ_WIDESTRING (options.part_letters.king, inifile, L"abbreviations", L"king", L"K"); options.part_letters.king[0] = towupper (options.part_letters.king[0]); options.part_letters.king[1] = 0; // sanitize |
144 | READ_WIDESTRING (options.part_letters.king, inifile, L"abbreviations", L"king", L"K"); options.part_letters.king[0] = towupper (options.part_letters.king[0]); options.part_letters.king[1] = 0; // sanitize |
145 | 145 | ||
- | 146 | #ifndef NO_REGISTRATION |
|
146 | // [registration] |
147 | // [registration] |
147 | READ_WIDESTRING (options.registration.user_email, inifile, L"registration", L"user email", L""); |
148 | READ_WIDESTRING (options.registration.user_email, inifile, L"registration", L"user email", L""); |
148 | options.registration.activation_code = (unsigned __int32) INIFile_ReadEntryAsLong (inifile, L"registration", L"activation code", 0); |
149 | options.registration.activation_code = (unsigned __int32) INIFile_ReadEntryAsLong (inifile, L"registration", L"activation code", 0); |
- | 150 | #endif // !NO_REGISTRATION |
|
149 | 151 | ||
150 | // [smilies] |
152 | // [smilies] |
151 | if (inifile == NULL) |
153 | if (inifile == NULL) |
152 | { |
154 | { |
153 | // if the .ini file doesn't exist yet, re-create one with the default smilies set |
155 | // if the .ini file doesn't exist yet, re-create one with the default smilies set |
Line 371... | Line 373... | ||
371 | wchar_t smiley_name[32]; |
373 | wchar_t smiley_name[32]; |
372 | smiley_t *smiley; |
374 | smiley_t *smiley; |
373 | void *inifile; |
375 | void *inifile; |
374 | int smiley_index; |
376 | int smiley_index; |
375 | int smiley_index2; |
377 | int smiley_index2; |
- | 378 | #ifndef NO_REGISTRATION |
|
376 | HKEY hRegistryKey; |
379 | HKEY hRegistryKey; |
- | 380 | #endif // !NO_REGISTRATION |
|
377 | 381 | ||
378 | // create a config file with the default values |
382 | // create a config file with the default values |
379 | inifile = INIFile_NewINIFile (); |
383 | inifile = INIFile_NewINIFile (); |
380 | 384 | ||
381 | // [options] -- FIXME: should be [gameplay] but would cause backwards compatibility problems |
385 | // [options] -- FIXME: should be [gameplay] but would cause backwards compatibility problems |
Line 439... | Line 443... | ||
439 | WRITE_WIDESTRING (L"abbreviations", L"knight", options.part_letters.knight); |
443 | WRITE_WIDESTRING (L"abbreviations", L"knight", options.part_letters.knight); |
440 | WRITE_WIDESTRING (L"abbreviations", L"bishop", options.part_letters.bishop); |
444 | WRITE_WIDESTRING (L"abbreviations", L"bishop", options.part_letters.bishop); |
441 | WRITE_WIDESTRING (L"abbreviations", L"queen", options.part_letters.queen); |
445 | WRITE_WIDESTRING (L"abbreviations", L"queen", options.part_letters.queen); |
442 | WRITE_WIDESTRING (L"abbreviations", L"king", options.part_letters.king); |
446 | WRITE_WIDESTRING (L"abbreviations", L"king", options.part_letters.king); |
443 | 447 | ||
- | 448 | #ifndef NO_REGISTRATION |
|
444 | // [registration] |
449 | // [registration] |
445 | WRITE_WIDESTRING (L"registration", L"user email", options.registration.user_email); |
450 | WRITE_WIDESTRING (L"registration", L"user email", options.registration.user_email); |
446 | INIFile_WriteEntryAsLong (inifile, L"registration", L"activation code", (long) options.registration.activation_code); |
451 | INIFile_WriteEntryAsLong (inifile, L"registration", L"activation code", (long) options.registration.activation_code); |
- | 452 | #endif // !NO_REGISTRATION |
|
447 | 453 | ||
448 | // [smilies] |
454 | // [smilies] |
449 | for (smiley_index = 0; smiley_index < smiley_count; smiley_index++) |
455 | for (smiley_index = 0; smiley_index < smiley_count; smiley_index++) |
450 | { |
456 | { |
451 | smiley = &smilies[smiley_index]; // quick access to smiley |
457 | smiley = &smilies[smiley_index]; // quick access to smiley |
Line 468... | Line 474... | ||
468 | 474 | ||
469 | // now save the INI file |
475 | // now save the INI file |
470 | swprintf_s (filename, WCHAR_SIZEOF (filename), L"%s/config.ini", app_path); |
476 | swprintf_s (filename, WCHAR_SIZEOF (filename), L"%s/config.ini", app_path); |
471 | INIFile_SaveINIFile (filename, inifile); |
477 | INIFile_SaveINIFile (filename, inifile); |
472 | 478 | ||
- | 479 | #ifndef NO_REGISTRATION |
|
473 | // SAFETY: if the current registration data is good, back it up in the registry if we can |
480 | // SAFETY: if the current registration data is good, back it up in the registry if we can |
474 | if (IsRegistrationCorrect (options.registration.user_email, options.registration.activation_code) |
481 | if (IsRegistrationCorrect (options.registration.user_email, options.registration.activation_code) |
475 | && (RegOpenKeyEx (HKEY_CURRENT_USER, L"SOFTWARE\\Chess Giants", 0, KEY_SET_VALUE, &hRegistryKey) == 0)) |
482 | && (RegOpenKeyEx (HKEY_CURRENT_USER, L"SOFTWARE\\Chess Giants", 0, KEY_SET_VALUE, &hRegistryKey) == 0)) |
476 | { |
483 | { |
477 | RegSetValueEx (hRegistryKey, L"UserEmail", 0, REG_SZ, (BYTE *) options.registration.user_email, wcslen (options.registration.user_email) * sizeof (wchar_t)); |
484 | RegSetValueEx (hRegistryKey, L"UserEmail", 0, REG_SZ, (BYTE *) options.registration.user_email, wcslen (options.registration.user_email) * sizeof (wchar_t)); |
478 | RegSetValueEx (hRegistryKey, L"ActivationCode", 0, REG_DWORD, (BYTE *) &options.registration.activation_code, sizeof (options.registration.activation_code)); |
485 | RegSetValueEx (hRegistryKey, L"ActivationCode", 0, REG_DWORD, (BYTE *) &options.registration.activation_code, sizeof (options.registration.activation_code)); |
479 | RegCloseKey (hRegistryKey); // once we've written the data we were interested in, close the registry key |
486 | RegCloseKey (hRegistryKey); // once we've written the data we were interested in, close the registry key |
480 | } |
487 | } |
- | 488 | #endif // !NO_REGISTRATION |
|
481 | 489 | ||
482 | return; // finished |
490 | return; // finished |
483 | } |
491 | } |