t-h and -v output now displayed nicely in Win32 client; AI players _should_ als… | |
git clone git://src.adamsgaard.dk/vaccinewars | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 7f6da13b01f74dc977648bc4c3bd0bbbf1d420e5 | |
parent 2a6e35aef3c23dc1f6d92224fd35112771adff60 | |
Author: Ben Webb <[email protected]> | |
Date: Thu, 26 Apr 2001 04:01:28 +0000 | |
-h and -v output now displayed nicely in Win32 client; AI players _should_ | |
also display output properly now too. | |
Diffstat: | |
M src/dopewars.c | 38 ++++++++++++++++-------------… | |
M src/winmain.c | 71 ++++++++++++++++++++++-------… | |
2 files changed, 70 insertions(+), 39 deletions(-) | |
--- | |
diff --git a/src/dopewars.c b/src/dopewars.c | |
t@@ -1669,9 +1669,7 @@ int GeneralStartup(int argc,char *argv[]) { | |
/* score init.) - Returns 0 if OK, -1 if something failed. */ | |
SetupParameters(); | |
HandleCmdLine(argc,argv); | |
- if (WantVersion || WantHelp) { | |
- HandleHelpTexts(); | |
- } else if (!AIPlayer) { | |
+ if (!WantVersion && !WantHelp && !AIPlayer) { | |
return InitHighScoreFile(); | |
} | |
return 0; | |
t@@ -1686,22 +1684,26 @@ int main(int argc,char *argv[]) { | |
bindtextdomain(PACKAGE,LOCALEDIR); | |
textdomain(PACKAGE); | |
#endif | |
- if (GeneralStartup(argc,argv)==0 && !WantVersion && !WantHelp) { | |
- StartNetworking(); | |
- if (Server) { | |
- ServerLoop(); | |
- } else if (AIPlayer) { | |
- AIPlayerLoop(); | |
- } else switch(WantedClient) { | |
- case CLIENT_AUTO: | |
- if (!GtkLoop(&argc,&argv,TRUE)) CursesLoop(); | |
- break; | |
- case CLIENT_WINDOW: | |
- GtkLoop(&argc,&argv,FALSE); break; | |
- case CLIENT_CURSES: | |
- CursesLoop(); break; | |
+ if (GeneralStartup(argc,argv)==0) { | |
+ if (WantVersion || WantHelp) { | |
+ HandleHelpTexts(); | |
+ } else { | |
+ StartNetworking(); | |
+ if (Server) { | |
+ ServerLoop(); | |
+ } else if (AIPlayer) { | |
+ AIPlayerLoop(); | |
+ } else switch(WantedClient) { | |
+ case CLIENT_AUTO: | |
+ if (!GtkLoop(&argc,&argv,TRUE)) CursesLoop(); | |
+ break; | |
+ case CLIENT_WINDOW: | |
+ GtkLoop(&argc,&argv,FALSE); break; | |
+ case CLIENT_CURSES: | |
+ CursesLoop(); break; | |
+ } | |
+ StopNetworking(); | |
} | |
- StopNetworking(); | |
} | |
CloseHighScoreFile(); | |
g_free(PidFile); | |
diff --git a/src/winmain.c b/src/winmain.c | |
t@@ -60,6 +60,22 @@ static void LogMessage(const gchar *log_domain,GLogLevelFla… | |
MessageBox(NULL,message,"Error",MB_OK|MB_ICONSTOP); | |
} | |
+static GString *TextOutput=NULL; | |
+ | |
+static void WindowPrintStart() { | |
+ TextOutput=g_string_new(""); | |
+} | |
+ | |
+static void WindowPrintFunc(const gchar *string) { | |
+ g_string_append(TextOutput,string); | |
+} | |
+ | |
+static void WindowPrintEnd() { | |
+ MessageBox(NULL,TextOutput->str,"dopewars",MB_OK|MB_ICONINFORMATION); | |
+ g_string_free(TextOutput,TRUE); | |
+ TextOutput=NULL; | |
+} | |
+ | |
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, | |
LPSTR lpszCmdParam,int nCmdShow) { | |
gchar **split; | |
t@@ -74,32 +90,45 @@ int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevIn… | |
split=g_strsplit(lpszCmdParam," ",0); | |
argc=0; | |
while (split[argc] && split[argc][0]) argc++; | |
- if (GeneralStartup(argc,split)==0 && !WantVersion && !WantHelp) { | |
- StartNetworking(); | |
- if (Server) { | |
- AllocConsole(); | |
- SetConsoleTitle(_("dopewars server")); | |
- g_log_set_handler(NULL,G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_WARNING, | |
- ServerLogMessage,NULL); | |
- g_set_print_handler(ServerPrintFunc); | |
- newterm(NULL,NULL,NULL); | |
- ServerLoop(); | |
- } else if (AIPlayer) { | |
- AIPlayerLoop(); | |
- } else if (WantedClient==CLIENT_CURSES) { | |
- AllocConsole(); | |
- SetConsoleTitle(_("dopewars")); | |
- CursesLoop(); | |
+ if (GeneralStartup(argc,split)==0) { | |
+ if (WantVersion || WantHelp) { | |
+ WindowPrintStart(); | |
+ g_set_print_handler(WindowPrintFunc); | |
+ HandleHelpTexts(); | |
+ WindowPrintEnd(); | |
} else { | |
+ StartNetworking(); | |
+ if (Server) { | |
+ AllocConsole(); | |
+ SetConsoleTitle(_("dopewars server")); | |
+ g_log_set_handler(NULL,G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_WARNING, | |
+ ServerLogMessage,NULL); | |
+ g_set_print_handler(ServerPrintFunc); | |
+ newterm(NULL,NULL,NULL); | |
+ ServerLoop(); | |
+ } else if (AIPlayer) { | |
+ AllocConsole(); | |
+ SetConsoleTitle(_("dopewars AI")); | |
+ g_log_set_handler(NULL,G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_WARNING, | |
+ ServerLogMessage,NULL); | |
+ g_set_print_handler(ServerPrintFunc); | |
+ newterm(NULL,NULL,NULL); | |
+ AIPlayerLoop(); | |
+ } else if (WantedClient==CLIENT_CURSES) { | |
+ AllocConsole(); | |
+ SetConsoleTitle(_("dopewars")); | |
+ CursesLoop(); | |
+ } else { | |
#if GUI_CLIENT | |
- GtkLoop(hInstance,hPrevInstance); | |
+ GtkLoop(hInstance,hPrevInstance); | |
#else | |
- g_print(_("No graphical client available - rebuild the binary\n" | |
- "passing the --enable-gui-client option to configure, or\n" | |
- "use the curses client (if available) instead!\n")); | |
+ g_print(_("No graphical client available - rebuild the binary\n" | |
+ "passing the --enable-gui-client option to configure, or\n" | |
+ "use the curses client (if available) instead!\n")); | |
#endif | |
+ } | |
+ StopNetworking(); | |
} | |
- StopNetworking(); | |
} | |
g_strfreev(split); | |
CloseHighScoreFile(); |