wait for AI thread to finish before freeing ressources (to avoid segfaults on game exit)
authorsheepluva
Fri, 07 May 2010 20:45:03 +0000
changeset 3449 033e4a8a9c74
parent 3448 b79908461a11
child 3450 c250116b9136
wait for AI thread to finish before freeing ressources (to avoid segfaults on game exit)
hedgewars/hwengine.pas
--- a/hedgewars/hwengine.pas	Fri May 07 20:38:55 2010 +0000
+++ b/hedgewars/hwengine.pas	Fri May 07 20:45:03 2010 +0000
@@ -90,7 +90,7 @@
 var s: shortstring;
 {$ENDIF}
 begin
-    inc(RealTicks, Lag);
+    if not isPaused then inc(RealTicks, Lag);
 
     case GameState of
         gsLandGen: begin
@@ -121,13 +121,19 @@
         gsGame: begin
                 DrawWorld(Lag); // never place between ProcessKbd and DoGameTick - bugs due to /put cmd and isCursorVisible
                 ProcessKbd;
-                DoGameTick(Lag);
-                if not isPaused then ProcessVisualGears(Lag);
+                if not isPaused then
+                    begin
+                    DoGameTick(Lag);
+                    ProcessVisualGears(Lag);
+                    end;
                 end;
         gsChat: begin
                 DrawWorld(Lag);
-                DoGameTick(Lag);
-                ProcessVisualGears(Lag);
+                if not isPaused then
+                    begin
+                    DoGameTick(Lag);
+                    ProcessVisualGears(Lag);
+                    end;
                 end;
         gsExit: begin
                 isTerminated:= true;
@@ -156,6 +162,7 @@
 begin
     WriteLnToConsole('Freeing resources...');
     if isSoundEnabled then ReleaseSound();
+    FreeActionsList();
     StoreRelease();
     FreeGearsList();
     FreeVisualGears();