wait for AI thread to finish before freeing ressources (to avoid segfaults on game exit)
--- 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();