Fix desync when playing with AI via network, occuring in certain conditions
authorunc0rr
Sat, 14 Nov 2009 11:06:55 +0000
changeset 2621 956ff066f3a5
parent 2620 796269129c47
child 2622 39932161194e
Fix desync when playing with AI via network, occuring in certain conditions
hedgewars/uGame.pas
hedgewars/uGears.pas
hedgewars/uMisc.pas
--- a/hedgewars/uGame.pas	Sat Nov 14 05:26:26 2009 +0000
+++ b/hedgewars/uGame.pas	Sat Nov 14 11:06:55 2009 +0000
@@ -23,8 +23,6 @@
 
 procedure DoGameTick(Lag: LongInt);
 
-var skipFlag: boolean = false;
-
 ////////////////////
    implementation
 ////////////////////
@@ -47,7 +45,6 @@
 i:= 1;
 while (GameState <> gsExit) and (i <= Lag) do
     begin
-    skipFlag:= false;
     if not CurrentTeam^.ExtDriven then
        begin
        if CurrentHedgehog^.BotLevel <> 0 then ProcessBot;
@@ -74,7 +71,6 @@
                end
           else ProcessGears
        end;
-    if skipFlag then TurnTimeLeft:= 0;
     inc(i)
     end
 end;
--- a/hedgewars/uGears.pas	Sat Nov 14 05:26:26 2009 +0000
+++ b/hedgewars/uGears.pas	Sat Nov 14 11:06:55 2009 +0000
@@ -78,6 +78,7 @@
     SpeechType: Longword = 1;
     SpeechText: shortstring;
 	TrainingTargetGear: PGear = nil;
+	skipFlag: boolean = false;
 
 implementation
 uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions,
@@ -659,6 +660,12 @@
 				dec(TurnTimeLeft)
 				end;
 
+if skipFlag then
+	begin
+	TurnTimeLeft:= 0;
+	skipFlag:= false
+	end;
+
 if ((GameTicks and $FFFF) = $FFFF) then
 	begin
 	if (not CurrentTeam^.ExtDriven) then
--- a/hedgewars/uMisc.pas	Sat Nov 14 05:26:26 2009 +0000
+++ b/hedgewars/uMisc.pas	Sat Nov 14 11:06:55 2009 +0000
@@ -586,7 +586,7 @@
 finalization
 //uRandom.DumpBuffer;
 
-writeln(f, 'halt at ', GameTicks, ' ticks');
+writeln(f, 'halt at ', GameTicks, ' ticks. TurnTimeLeft = ', TurnTimeLeft);
 flush(f);
 close(f)