hedgewars/uCommandHandlers.pas
changeset 7389 15c3fb4882df
parent 7218 9ecd5bc9810b
child 7403 e8d0b21efa82
--- a/hedgewars/uCommandHandlers.pas	Fri Jul 13 13:21:52 2012 +0400
+++ b/hedgewars/uCommandHandlers.pas	Sat Jul 14 23:19:09 2012 -0400
@@ -412,18 +412,19 @@
 end;
 
 procedure chNextTurn(var s: shortstring);
-var checksum: Longword;
+var i: Longword;
     gi: PGear;
 begin
     s:= s; // avoid compiler hint
 
     TryDo(AllInactive, '/nextturn called when not all gears are inactive', true);
 
-    checksum:= GameTicks;
+    CheckSum:= CheckSum xor GameTicks;
     gi := GearsList;
     while gi <> nil do
         begin
-        with gi^ do checksum:= checksum xor X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac;
+        with gi^ do CheckSum:= CheckSum xor X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac;
+        AddRandomness(CheckSum);
         gi := gi^.NextGear
         end;
 
@@ -431,11 +432,11 @@
         begin
         s[0]:= #5;
         s[1]:= 'N';
-        SDLNet_Write32(checksum, @s[2]);
+        SDLNet_Write32(CheckSum, @s[2]);
         SendIPC(s)
         end
     else
-        TryDo(checksum = lastTurnChecksum, 'Desync detected', true);
+        TryDo(CheckSum = lastTurnChecksum, 'Desync detected', true);
     AddFileLog('Next turn: time '+inttostr(GameTicks));
 end;