hedgewars/uCommandHandlers.pas
changeset 7442 9bb6abdb5675
parent 7231 f484455dd055
parent 7426 55b49cc1f33a
child 7503 deaeac102355
--- a/hedgewars/uCommandHandlers.pas	Fri Jul 13 16:39:20 2012 +0400
+++ b/hedgewars/uCommandHandlers.pas	Thu Jul 26 21:56:47 2012 +0400
@@ -413,18 +413,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;
 
@@ -432,11 +433,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;
 
@@ -664,6 +665,7 @@
 procedure chSpeedup_p(var s: shortstring);
 begin
 s:= s; // avoid compiler hint
+SpeedStart:= RealTicks;
 isSpeed:= true
 end;
 
@@ -776,7 +778,7 @@
 procedure chGameFlags(var s: shortstring);
 begin
 GameFlags:= StrToInt(s);
-if GameFlags and gfSharedAmmo <> 0 then GameFlags:= GameFlags and not gfPerHogAmmo
+if GameFlags and gfSharedAmmo <> 0 then GameFlags:= GameFlags and (not gfPerHogAmmo)
 end;
 
 procedure chHedgehogTurnTime(var s: shortstring);
@@ -797,21 +799,21 @@
 procedure initModule;
 begin
 //////// Begin top sorted by freq analysis not including chatmsg
-    RegisterVariable('+right'  , @chRight_p      , false);
-    RegisterVariable('-right'  , @chRight_m      , false);
-    RegisterVariable('+up'     , @chUp_p         , false);
-    RegisterVariable('-up'     , @chUp_m         , false);
-    RegisterVariable('+left'   , @chLeft_p       , false);
-    RegisterVariable('-left'   , @chLeft_m       , false);
+    RegisterVariable('+right'  , @chRight_p      , false, true);
+    RegisterVariable('-right'  , @chRight_m      , false, true);
+    RegisterVariable('+up'     , @chUp_p         , false, true);
+    RegisterVariable('-up'     , @chUp_m         , false, true);
+    RegisterVariable('+left'   , @chLeft_p       , false, true);
+    RegisterVariable('-left'   , @chLeft_m       , false, true);
     RegisterVariable('+attack' , @chAttack_p     , false);
-    RegisterVariable('+down'   , @chDown_p       , false);
-    RegisterVariable('-down'   , @chDown_m       , false);
-    RegisterVariable('hjump'   , @chHJump        , false);
-    RegisterVariable('ljump'   , @chLJump        , false);
+    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);
     RegisterVariable('-attack' , @chAttack_m     , false);
     RegisterVariable('slot'    , @chSlot         , false);
-    RegisterVariable('setweap' , @chSetWeapon    , false);
+    RegisterVariable('setweap' , @chSetWeapon    , false, true);
 //////// End top by freq analysis
     RegisterVariable('gencmd'  , @chGenCmd       , false);
     RegisterVariable('flag'    , @chFlag         , false);
@@ -857,10 +859,10 @@
     RegisterVariable('zoomout' , @chZoomOut      , true );
     RegisterVariable('zoomreset',@chZoomReset    , true );
     RegisterVariable('ammomenu', @chAmmoMenu     , true);
-    RegisterVariable('+precise', @chPrecise_p    , false);
-    RegisterVariable('-precise', @chPrecise_m    , false);
+    RegisterVariable('+precise', @chPrecise_p    , false, true);
+    RegisterVariable('-precise', @chPrecise_m    , false, true);
     RegisterVariable('switch'  , @chSwitch       , false);
-    RegisterVariable('timer'   , @chTimer        , false);
+    RegisterVariable('timer'   , @chTimer        , false, true);
     RegisterVariable('taunt'   , @chTaunt        , false);
     RegisterVariable('put'     , @chPut          , false);
     RegisterVariable('+volup'  , @chVol_p        , true );