hedgewars/hwengine.pas
changeset 5565 1a326ba319c9
parent 5562 8056d82b4d23
child 5577 272c82f82cee
child 5616 a96231121eac
--- a/hedgewars/hwengine.pas	Sun Aug 14 17:49:12 2011 -0400
+++ b/hedgewars/hwengine.pas	Mon Aug 15 00:23:32 2011 +0200
@@ -124,7 +124,6 @@
 begin
     WriteLnToConsole('Freeing resources...');
     FreeActionsList();
-    uVisualGears.freeModule;
     StoreRelease();
     ControllerClose();
     CloseIPC();
@@ -200,14 +199,6 @@
     end;
 end;
 
-/////////////////////////
-procedure ShowMainWindow;
-begin
-    if cFullScreen then ParseCommand('fullscr 1', true)
-    else ParseCommand('fullscr 0', true);
-    SDL_ShowCursor(0)
-end;
-
 ///////////////
 {$IFDEF HWLIBRARY}
 procedure Game(gameArgs: PPChar); cdecl; export;
@@ -239,7 +230,6 @@
     cStereoMode:= smNone;
 {$ENDIF}
 
-    cLogfileBase:= 'game';
     initEverything(true);
 
     WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')');
@@ -261,19 +251,15 @@
     WriteLnToConsole(msgOK);
 
     SDL_EnableUNICODE(1);
+    SDL_ShowCursor(0);
 
     WriteToConsole('Init SDL_ttf... ');
     SDLTry(TTF_Init() <> -1, true);
     WriteLnToConsole(msgOK);
 
-{$IFDEF WIN32}
-    s:= SDL_getenv('SDL_VIDEO_CENTERED');
-    SDL_putenv('SDL_VIDEO_CENTERED=1');
-    ShowMainWindow();
-    SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s));
-{$ELSE}
-    ShowMainWindow();
-{$ENDIF}
+    // show main window
+    if cFullScreen then ParseCommand('fullscr 1', true)
+    else ParseCommand('fullscr 0', true);
 
     ControllerInit(); // has to happen before InitKbdKeyTable to map keys
     InitKbdKeyTable();
@@ -335,6 +321,9 @@
 begin
     Randomize();
 
+    if complete then cLogfileBase:= 'game'
+    else cLogfileBase:= 'preview';
+
     // uConsts does not need initialization as they are all consts
     uUtils.initModule;
     uMisc.initModule;
@@ -425,7 +414,6 @@
 procedure GenLandPreview{$IFDEF HWLIBRARY}(port: LongInt); cdecl; export{$ENDIF};
 var Preview: TPreview;
 begin
-    cLogfileBase:= 'preview';
     initEverything(false);
 {$IFDEF HWLIBRARY}
     WriteLnToConsole('Preview connecting on port ' + inttostr(port));
@@ -496,9 +484,7 @@
     else if GameType = gmtSyntax then DisplayUsage()
     else Game();
 
-    if GameType = gmtSyntax then
-        ExitCode:= 1
-    else
-        ExitCode:= 0;
+    // return 1 when engine is not called correctly
+    ExitCode:= LongInt(GameType = gmtSyntax);
 {$ENDIF}
 end.