diff -r 6592fbb969da -r 1d7b056ff866 hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Sun Jun 20 18:35:59 2010 +0200 +++ b/hedgewars/hwengine.pas Sun Jun 20 23:05:11 2010 +0200 @@ -75,13 +75,13 @@ {$IFDEF HWLIBRARY} type arrayofpchar = array[0..8] of PChar; -procedure initEverything; -procedure freeEverything; +procedure initEverything(complete:boolean); +procedure freeEverything(complete:boolean); implementation {$ELSE} procedure OnDestroy; forward; -procedure freeEverything; forward; +procedure freeEverything(complete:boolean); forward; {$ENDIF} //////////////////////////////// @@ -243,7 +243,7 @@ s: shortstring; begin {$IFDEF HWLIBRARY} - initEverything(); + initEverything(true); cBits:= 32; cFullScreen:= false; @@ -331,81 +331,88 @@ MainLoop(); OnDestroy(); -{$IFDEF HWLIBRARY}freeEverything();{$ENDIF} +{$IFDEF HWLIBRARY}freeEverything(true);{$ENDIF} if alsoShutdownFrontend then halt; end; -procedure initEverything; +procedure initEverything (complete:boolean); begin Randomize(); uConsts.initModule; uMisc.initModule; uConsole.initModule; // MUST happen after uMisc - - uAI.initModule; - //uAIActions does not need initialization - //uAIAmmoTests does not need initialization - uAIMisc.initModule; - uAmmos.initModule; - uChat.initModule; - uCollisions.initModule; - //uFloat does not need initialization - //uGame does not need initialization - uGears.initModule; - uIO.initModule; - uKeys.initModule; + uLand.initModule; - //uLandGraphics does not need initialization - //uLandObjects does not need initialization - //uLandTemplates does not need initialization - //uLandTexture does not need initialization - //uLocale does not need initialization - uRandom.initModule; - //uSHA is initialized internally - uSound.initModule; - uStats.initModule; - uStore.initModule; - uTeams.initModule; - uVisualGears.initModule; - uWorld.initModule; - uScript.initModule; + uIO.initModule; + + if complete then + begin + uAI.initModule; + //uAIActions does not need initialization + //uAIAmmoTests does not need initialization + uAIMisc.initModule; + uAmmos.initModule; + uChat.initModule; + uCollisions.initModule; + //uFloat does not need initialization + //uGame does not need initialization + uGears.initModule; + uKeys.initModule; + //uLandGraphics does not need initialization + //uLandObjects does not need initialization + //uLandTemplates does not need initialization + //uLandTexture does not need initialization + //uLocale does not need initialization + uRandom.initModule; + //uSHA is initialized internally + uScript.initModule; + uSound.initModule; + uStats.initModule; + uStore.initModule; + uTeams.initModule; + uVisualGears.initModule; + uWorld.initModule; + end; end; -procedure freeEverything; +procedure freeEverything (complete:boolean); begin - uWorld.freeModule; - uVisualGears.freeModule; //stub - uTeams.freeModule; - uStore.freeModule; //stub - uStats.freeModule; //stub - uSound.freeModule; //stub - //uSHA does not need to be freed - uRandom.freeModule; //stub - //uLocale does not need to be freed - //uLandTemplates does not need to be freed - //uLandTexture does not need to be freed - //uLandObjects does not need to be freed - //uLandGraphics does not need to be freed + if complete then + begin + uWorld.freeModule; + uVisualGears.freeModule; //stub + uTeams.freeModule; + uStore.freeModule; //stub + uStats.freeModule; //stub + uSound.freeModule; //stub + uScript.freeModule; + //uSHA does not need to be freed + uRandom.freeModule; //stub + //uLocale does not need to be freed + //uLandTemplates does not need to be freed + //uLandTexture does not need to be freed + //uLandObjects does not need to be freed + //uLandGraphics does not need to be freed + uKeys.freeModule; //stub + uGears.freeModule; + //uGame does not need to be freed + //uFloat does not need to be freed + uCollisions.freeModule; //stub + uChat.freeModule; //stub + uAmmos.freeModule; + uAIMisc.freeModule; //stub + //uAIAmmoTests does not need to be freed + //uAIActions does not need to be freed + uAI.freeModule; //stub + end; + + uIO.freeModule; //stub uLand.freeModule; - uKeys.freeModule; //stub - uIO.freeModule; //stub - uGears.freeModule; - //uGame does not need to be freed - //uFloat does not need to be freed - uCollisions.freeModule; //stub - uChat.freeModule; //stub - uAmmos.freeModule; - uAIMisc.freeModule; //stub - //uAIAmmoTests does not need to be freed - //uAIActions does not need to be freed - uAI.freeModule; //stub uConsole.freeModule; + uMisc.freeModule; // uMisc closes the debug log. uConsts.freeModule; //stub - uScript.freeModule; - // uMisc closes the debug log. - uMisc.freeModule; end; ///////////////////////// @@ -413,7 +420,7 @@ var Preview: TPreview; begin {$IFDEF IPHONEOS} - initEverything(); + initEverything(false); WriteLnToConsole('Preview connecting on port ' + inttostr(port)); ipcPort:= port; {$ENDIF} @@ -428,7 +435,7 @@ WriteLnToConsole('Preview sent, disconnect'); CloseIPC(); {$IFDEF IPHONEOS} - freeEverything(); + freeEverything(false); {$ENDIF} end; @@ -596,7 +603,7 @@ /////////////////////////////// m a i n //////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// begin - initEverything(); + initEverything(true); WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')'); GetParams(); @@ -605,7 +612,7 @@ else if GameType = gmtSyntax then DisplayUsage() else Game(); - freeEverything(); + freeEverything(true); if GameType = gmtSyntax then ExitCode:= 1 else