Rev 163 | Rev 172 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 163 | Rev 164 | ||
|---|---|---|---|
| Line 57... | Line 57... | ||
| 57 | GetModuleFileName (NULL, app_pathname, WCHAR_SIZEOF (app_pathname)); |
57 | GetModuleFileName (NULL, app_pathname, WCHAR_SIZEOF (app_pathname)); |
| 58 | GetDirectoryPath (app_pathname, app_path); |
58 | GetDirectoryPath (app_pathname, app_path); |
| 59 | SetCurrentDirectoryW (app_path); |
59 | SetCurrentDirectoryW (app_path); |
| 60 | 60 | ||
| 61 | // initialize stuff |
61 | // initialize stuff |
| 62 | is_registered = false; |
- | |
| 63 | terminate_everything = false; |
62 | terminate_everything = false; |
| 64 | hMainWnd = NULL; |
63 | hMainWnd = NULL; |
| 65 | hChatterChannelsWnd = NULL; |
64 | hChatterChannelsWnd = NULL; |
| 66 | hGamesWnd = NULL; |
65 | hGamesWnd = NULL; |
| 67 | hMOTDWnd = NULL; |
66 | hMOTDWnd = NULL; |
| 68 | hOpponentsWnd = NULL; |
67 | hOpponentsWnd = NULL; |
| 69 | hSoughtWnd = NULL; |
68 | hSoughtWnd = NULL; |
| 70 | is_paused = false; // clear pause status |
69 | is_paused = false; // clear pause status |
| 71 | #ifdef |
70 | #ifdef NO_REGISTRATION |
| - | 71 | is_registered = true; |
|
| - | 72 | want_framerate = true; // display framerate in debug mode |
|
| - | 73 | #else // !NO_REGISTRATION |
|
| - | 74 | is_registered = false; |
|
| 72 | want_framerate = false; // release mode, don't display framerate |
75 | want_framerate = false; // release mode, don't display framerate |
| 73 | #else |
- | |
| 74 | want_framerate = true; // display framerate in debug mode |
- | |
| 75 | #endif // |
76 | #endif // NO_REGISTRATION |
| 76 | is_dialogbox_displayed = false; |
77 | is_dialogbox_displayed = false; |
| 77 | is_dialogbox_about_validated = false; |
78 | is_dialogbox_about_validated = false; |
| 78 | is_dialogbox_challenge_validated = false; |
79 | is_dialogbox_challenge_validated = false; |
| 79 | is_dialogbox_changeappearance_validated = false; |
80 | is_dialogbox_changeappearance_validated = false; |
| 80 | is_dialogbox_comment_validated = false; |
81 | is_dialogbox_comment_validated = false; |
| Line 119... | Line 120... | ||
| 119 | 120 | ||
| 120 | // read configuration data |
121 | // read configuration data |
| 121 | Config_Load (); |
122 | Config_Load (); |
| 122 | 123 | ||
| 123 | // see if the program is registered |
124 | // see if the program is registered |
| - | 125 | #ifndef NO_REGISTRATION |
|
| 124 | is_registered = IsRegistrationCorrect (options.registration.user_email, options.registration.activation_code); |
126 | is_registered = IsRegistrationCorrect (options.registration.user_email, options.registration.activation_code); |
| 125 | 127 | ||
| 126 | // is it not ? if so, try to read alternate registration data from the registry |
128 | // is it not ? if so, try to read alternate registration data from the registry |
| 127 | if (!is_registered && (RegOpenKeyEx (HKEY_CURRENT_USER, L"SOFTWARE\\Chess Giants", 0, KEY_READ, &hRegistryKey) == 0)) |
129 | if (!is_registered && (RegOpenKeyEx (HKEY_CURRENT_USER, L"SOFTWARE\\Chess Giants", 0, KEY_READ, &hRegistryKey) == 0)) |
| 128 | { |
130 | { |
| Line 135... | Line 137... | ||
| 135 | RegCloseKey (hRegistryKey); // once we've read the data we were interested in, close the registry key |
137 | RegCloseKey (hRegistryKey); // once we've read the data we were interested in, close the registry key |
| 136 | 138 | ||
| 137 | // now check again if we're registered |
139 | // now check again if we're registered |
| 138 | is_registered = IsRegistrationCorrect (options.registration.user_email, options.registration.activation_code); |
140 | is_registered = IsRegistrationCorrect (options.registration.user_email, options.registration.activation_code); |
| 139 | } |
141 | } |
| - | 142 | #endif // !NO_REGISTRATION |
|
| 140 | 143 | ||
| 141 | // if we're not registered, display a dialog box to invite the user to enter his donor email to unlock the program |
144 | // if we're not registered, display a dialog box to invite the user to enter his donor email to unlock the program |
| 142 |
|
145 | //if (!is_registered) |
| 143 |
|
146 | //{ |
| 144 | DialogBox_Registration |
147 | // DialogBox_Registration (); |
| 145 |
|
148 | //} |
| 146 | //DialogBox_Registration (); |
149 | //DialogBox_Registration (); |
| 147 | //return (0); |
150 | //return (0); |
| 148 | 151 | ||
| 149 | // register the window class, create the window and show it |
152 | // register the window class, create the window and show it |
| 150 | memset (&wc, 0, sizeof (wc)); |
153 | memset (&wc, 0, sizeof (wc)); |
| Line 286... | Line 289... | ||
| 286 | if (_access (lpCmdLine, 0) == 0) |
289 | if (_access (lpCmdLine, 0) == 0) |
| 287 | { |
290 | { |
| 288 | ConvertToWideChar (load_pathname, WCHAR_SIZEOF (load_pathname), lpCmdLine); // save pathname string |
291 | ConvertToWideChar (load_pathname, WCHAR_SIZEOF (load_pathname), lpCmdLine); // save pathname string |
| 289 | is_dialogbox_load_validated = true; // and act as if the user just validated a load dialog box |
292 | is_dialogbox_load_validated = true; // and act as if the user just validated a load dialog box |
| 290 | } |
293 | } |
| 291 | #ifndef |
294 | #ifndef NO_REGISTRATION |
| 292 | // else is it a registration info ? if so, parse it |
295 | // else is it a registration info ? if so, parse it |
| 293 | else if ((strncmp (lpCmdLine, "/r=", 3) == 0) && ((endptr = strchr (&lpCmdLine[3], ',')) != NULL)) |
296 | else if ((strncmp (lpCmdLine, "/r=", 3) == 0) && ((endptr = strchr (&lpCmdLine[3], ',')) != NULL)) |
| 294 | { |
297 | { |
| 295 | *endptr = 0; // break the string at the separator between user email and activation code |
298 | *endptr = 0; // break the string at the separator between user email and activation code |
| 296 | ConvertToWideChar (temp_string, WCHAR_SIZEOF (temp_string), &lpCmdLine[3]); // read user email |
299 | ConvertToWideChar (temp_string, WCHAR_SIZEOF (temp_string), &lpCmdLine[3]); // read user email |
| 297 | is_registered = IsRegistrationCorrect (temp_string, atoi (endptr + 1)); // and see whether we're registered or not |
300 | is_registered = IsRegistrationCorrect (temp_string, atoi (endptr + 1)); // and see whether we're registered or not |
| 298 | } |
301 | } |
| 299 | #endif // |
302 | #endif // !NO_REGISTRATION |
| 300 | } |
303 | } |
| 301 | 304 | ||
| 302 | // TODO: this + offline statistics |
305 | // TODO: this + offline statistics |
| 303 | 306 | ||
| 304 | // enter the main loop |
307 | // enter the main loop |
| Line 472... | Line 475... | ||
| 472 | if (IsMenu (hMainMenu)) |
475 | if (IsMenu (hMainMenu)) |
| 473 | DestroyMenu (hMainMenu); |
476 | DestroyMenu (hMainMenu); |
| 474 | hMainMenu = NULL; |
477 | hMainMenu = NULL; |
| 475 | 478 | ||
| 476 | // are we not registered yet ? |
479 | // are we not registered yet ? |
| - | 480 | #ifndef NO_REGISTRATION |
|
| 477 | if (!is_registered) |
481 | if (!is_registered) |
| 478 | DialogBox_Registration (); |
482 | DialogBox_Registration (); |
| - | 483 | #endif // !NO_REGISTRATION |
|
| 479 | 484 | ||
| 480 | // save configuration data |
485 | // save configuration data |
| 481 | Config_Save (); |
486 | Config_Save (); |
| 482 | 487 | ||
| 483 | // unload localized texts |
488 | // unload localized texts |