Avoid desync playing back demos
authornemo
Fri, 20 Jul 2012 18:48:04 -0400
changeset 7409 fd91aa100ce0
parent 7408 38d369c59d51
child 7410 dc869f3187ca
child 7411 efc75c2d3be9
Avoid desync playing back demos
hedgewars/uCommandHandlers.pas
hedgewars/uCommands.pas
hedgewars/uGearsHedgehog.pas
--- a/hedgewars/uCommandHandlers.pas	Fri Jul 20 17:43:35 2012 -0400
+++ b/hedgewars/uCommandHandlers.pas	Fri Jul 20 18:48:04 2012 -0400
@@ -792,13 +792,13 @@
     RegisterVariable('-up'     , @chUp_m         , false, true);
     RegisterVariable('+left'   , @chLeft_p       , false, true);
     RegisterVariable('-left'   , @chLeft_m       , false, true);
-    RegisterVariable('+attack' , @chAttack_p     , false, true);
+    RegisterVariable('+attack' , @chAttack_p     , false, false); // WTF?
     RegisterVariable('+down'   , @chDown_p       , false, true);
     RegisterVariable('-down'   , @chDown_m       , false, true);
     RegisterVariable('hjump'   , @chHJump        , false, true);
     RegisterVariable('ljump'   , @chLJump        , false, true);
     RegisterVariable('nextturn', @chNextTurn     , false, true);
-    RegisterVariable('-attack' , @chAttack_m     , false, true);
+    RegisterVariable('-attack' , @chAttack_m     , false, false);
     RegisterVariable('slot'    , @chSlot         , false, true);
     RegisterVariable('setweap' , @chSetWeapon    , false, true);
 //////// End top by freq analysis
--- a/hedgewars/uCommands.pas	Fri Jul 20 17:43:35 2012 -0400
+++ b/hedgewars/uCommands.pas	Fri Jul 20 18:48:04 2012 -0400
@@ -27,7 +27,7 @@
 
 procedure initModule;
 procedure freeModule;
-procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean; Synced: boolean);
+procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean; Rand: boolean);
 procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean);
 procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean);
 procedure ParseTeamCommand(s: shortstring);
@@ -41,7 +41,7 @@
         Next: PVariable;
         Name: string[15];
         Handler: TCommandHandler;
-        Trusted, Synced: boolean;
+        Trusted, Rand: boolean;
         end;
 
 var
@@ -51,7 +51,7 @@
 begin
 RegisterVariable(Name, p, Trusted, false);
 end;
-procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean; Synced: boolean);
+procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean; Rand: boolean);
 var
     value: PVariable;
 begin
@@ -61,7 +61,7 @@
 value^.Name:= Name;
 value^.Handler:= p;
 value^.Trusted:= Trusted;
-value^.Synced:= Synced;
+value^.Rand:= Rand;
 
 if Variables = nil then
     Variables:= value
@@ -93,7 +93,7 @@
     begin
     if t^.Name = CmdStr then
         begin
-        if t^.Synced then CheckSum:= CheckSum xor LongWord(SDLNet_Read32(@CmdStr)) xor LongWord(s[0]) xor GameTicks;
+        if t^.Rand then CheckSum:= CheckSum xor LongWord(SDLNet_Read32(@CmdStr)) xor LongWord(s[0]) xor GameTicks;
         if TrustedSource or t^.Trusted then
             t^.Handler(s);
         exit
--- a/hedgewars/uGearsHedgehog.pas	Fri Jul 20 17:43:35 2012 -0400
+++ b/hedgewars/uGearsHedgehog.pas	Fri Jul 20 18:48:04 2012 -0400
@@ -619,7 +619,7 @@
                     else
                         begin
 // Add spawning here...
-                        AddRandomness(CheckSum xor GameTicks);
+                        AddRandomness(GameTicks);
                         
                         gi := GearsList;
                         while gi <> nil do