diff options
| author | Simon Tatham <anakin@pobox.com> | 2004-05-20 08:22:49 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2004-05-20 08:22:49 +0000 |
| commit | 61f08e7634e0e39148a784c0ce6efcc112ed5a7a (patch) | |
| tree | 55b06d0ae5f94f331146b15e9437bcef5ce4e895 /windows.c | |
| parent | 350683b25371ec6a7548b2e83b2be15eb629815f (diff) | |
| download | puzzles-61f08e7634e0e39148a784c0ce6efcc112ed5a7a.zip puzzles-61f08e7634e0e39148a784c0ce6efcc112ed5a7a.tar.gz puzzles-61f08e7634e0e39148a784c0ce6efcc112ed5a7a.tar.bz2 puzzles-61f08e7634e0e39148a784c0ce6efcc112ed5a7a.tar.xz | |
Now that we have string-encodable game parameters, let's support a
command-line argument which is either a set of parameters or a
params+seed game ID.
[originally from svn r4234]
Diffstat (limited to 'windows.c')
| -rw-r--r-- | windows.c | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -7,6 +7,7 @@ #include <stdio.h> #include <assert.h> +#include <ctype.h> #include <stdarg.h> #include <stdlib.h> #include <time.h> @@ -309,7 +310,7 @@ void activate_timer(frontend *fe) } } -static frontend *new_window(HINSTANCE inst) +static frontend *new_window(HINSTANCE inst, char *game_id, char **error) { frontend *fe; int x, y; @@ -322,6 +323,15 @@ static frontend *new_window(HINSTANCE inst) time(&t); fe->me = midend_new(fe, &t, sizeof(t)); + if (game_id) { + *error = midend_game_id(fe->me, game_id, FALSE); + if (*error) { + midend_free(fe->me); + sfree(fe); + return NULL; + } + } + fe->inst = inst; midend_new_game(fe->me); midend_size(fe->me, &x, &y); @@ -1008,6 +1018,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { MSG msg; + char *error; InitCommonControls(); @@ -1028,7 +1039,15 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) RegisterClass(&wndclass); } - new_window(inst); + while (*cmdline && isspace(*cmdline)) + cmdline++; + + if (!new_window(inst, *cmdline ? cmdline : NULL, &error)) { + char buf[128]; + sprintf(buf, "%.100s Error", game_name); + MessageBox(NULL, error, buf, MB_OK|MB_ICONERROR); + return 1; + } while (GetMessage(&msg, NULL, 0, 0)) { DispatchMessage(&msg); |