hedgewars/uCommandHandlers.pas
changeset 7442 9bb6abdb5675
parent 7231 f484455dd055
parent 7426 55b49cc1f33a
child 7503 deaeac102355
equal deleted inserted replaced
7392:bc3306c59a08 7442:9bb6abdb5675
   411     Message:= Message or (gmSwitch and InputMask);
   411     Message:= Message or (gmSwitch and InputMask);
   412     ScriptCall('onSwitch');
   412     ScriptCall('onSwitch');
   413 end;
   413 end;
   414 
   414 
   415 procedure chNextTurn(var s: shortstring);
   415 procedure chNextTurn(var s: shortstring);
   416 var checksum: Longword;
   416 var i: Longword;
   417     gi: PGear;
   417     gi: PGear;
   418 begin
   418 begin
   419     s:= s; // avoid compiler hint
   419     s:= s; // avoid compiler hint
   420 
   420 
   421     TryDo(AllInactive, '/nextturn called when not all gears are inactive', true);
   421     TryDo(AllInactive, '/nextturn called when not all gears are inactive', true);
   422 
   422 
   423     checksum:= GameTicks;
   423     CheckSum:= CheckSum xor GameTicks;
   424     gi := GearsList;
   424     gi := GearsList;
   425     while gi <> nil do
   425     while gi <> nil do
   426         begin
   426         begin
   427         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;
   427         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;
       
   428         AddRandomness(CheckSum);
   428         gi := gi^.NextGear
   429         gi := gi^.NextGear
   429         end;
   430         end;
   430 
   431 
   431     if not CurrentTeam^.ExtDriven then
   432     if not CurrentTeam^.ExtDriven then
   432         begin
   433         begin
   433         s[0]:= #5;
   434         s[0]:= #5;
   434         s[1]:= 'N';
   435         s[1]:= 'N';
   435         SDLNet_Write32(checksum, @s[2]);
   436         SDLNet_Write32(CheckSum, @s[2]);
   436         SendIPC(s)
   437         SendIPC(s)
   437         end
   438         end
   438     else
   439     else
   439         TryDo(checksum = lastTurnChecksum, 'Desync detected', true);
   440         TryDo(CheckSum = lastTurnChecksum, 'Desync detected', true);
   440     AddFileLog('Next turn: time '+inttostr(GameTicks));
   441     AddFileLog('Next turn: time '+inttostr(GameTicks));
   441 end;
   442 end;
   442 
   443 
   443 procedure chTimer(var s: shortstring);
   444 procedure chTimer(var s: shortstring);
   444 begin
   445 begin
   662 end;
   663 end;
   663 
   664 
   664 procedure chSpeedup_p(var s: shortstring);
   665 procedure chSpeedup_p(var s: shortstring);
   665 begin
   666 begin
   666 s:= s; // avoid compiler hint
   667 s:= s; // avoid compiler hint
       
   668 SpeedStart:= RealTicks;
   667 isSpeed:= true
   669 isSpeed:= true
   668 end;
   670 end;
   669 
   671 
   670 procedure chSpeedup_m(var s: shortstring);
   672 procedure chSpeedup_m(var s: shortstring);
   671 begin
   673 begin
   774 end;
   776 end;
   775 
   777 
   776 procedure chGameFlags(var s: shortstring);
   778 procedure chGameFlags(var s: shortstring);
   777 begin
   779 begin
   778 GameFlags:= StrToInt(s);
   780 GameFlags:= StrToInt(s);
   779 if GameFlags and gfSharedAmmo <> 0 then GameFlags:= GameFlags and not gfPerHogAmmo
   781 if GameFlags and gfSharedAmmo <> 0 then GameFlags:= GameFlags and (not gfPerHogAmmo)
   780 end;
   782 end;
   781 
   783 
   782 procedure chHedgehogTurnTime(var s: shortstring);
   784 procedure chHedgehogTurnTime(var s: shortstring);
   783 begin
   785 begin
   784 cHedgehogTurnTime:= StrToInt(s)
   786 cHedgehogTurnTime:= StrToInt(s)
   795 end;
   797 end;
   796 
   798 
   797 procedure initModule;
   799 procedure initModule;
   798 begin
   800 begin
   799 //////// Begin top sorted by freq analysis not including chatmsg
   801 //////// Begin top sorted by freq analysis not including chatmsg
   800     RegisterVariable('+right'  , @chRight_p      , false);
   802     RegisterVariable('+right'  , @chRight_p      , false, true);
   801     RegisterVariable('-right'  , @chRight_m      , false);
   803     RegisterVariable('-right'  , @chRight_m      , false, true);
   802     RegisterVariable('+up'     , @chUp_p         , false);
   804     RegisterVariable('+up'     , @chUp_p         , false, true);
   803     RegisterVariable('-up'     , @chUp_m         , false);
   805     RegisterVariable('-up'     , @chUp_m         , false, true);
   804     RegisterVariable('+left'   , @chLeft_p       , false);
   806     RegisterVariable('+left'   , @chLeft_p       , false, true);
   805     RegisterVariable('-left'   , @chLeft_m       , false);
   807     RegisterVariable('-left'   , @chLeft_m       , false, true);
   806     RegisterVariable('+attack' , @chAttack_p     , false);
   808     RegisterVariable('+attack' , @chAttack_p     , false);
   807     RegisterVariable('+down'   , @chDown_p       , false);
   809     RegisterVariable('+down'   , @chDown_p       , false, true);
   808     RegisterVariable('-down'   , @chDown_m       , false);
   810     RegisterVariable('-down'   , @chDown_m       , false, true);
   809     RegisterVariable('hjump'   , @chHJump        , false);
   811     RegisterVariable('hjump'   , @chHJump        , false, true);
   810     RegisterVariable('ljump'   , @chLJump        , false);
   812     RegisterVariable('ljump'   , @chLJump        , false, true);
   811     RegisterVariable('nextturn', @chNextTurn     , false);
   813     RegisterVariable('nextturn', @chNextTurn     , false);
   812     RegisterVariable('-attack' , @chAttack_m     , false);
   814     RegisterVariable('-attack' , @chAttack_m     , false);
   813     RegisterVariable('slot'    , @chSlot         , false);
   815     RegisterVariable('slot'    , @chSlot         , false);
   814     RegisterVariable('setweap' , @chSetWeapon    , false);
   816     RegisterVariable('setweap' , @chSetWeapon    , false, true);
   815 //////// End top by freq analysis
   817 //////// End top by freq analysis
   816     RegisterVariable('gencmd'  , @chGenCmd       , false);
   818     RegisterVariable('gencmd'  , @chGenCmd       , false);
   817     RegisterVariable('flag'    , @chFlag         , false);
   819     RegisterVariable('flag'    , @chFlag         , false);
   818     RegisterVariable('script'  , @chScript       , false);
   820     RegisterVariable('script'  , @chScript       , false);
   819     RegisterVariable('proto'   , @chCheckProto   , true );
   821     RegisterVariable('proto'   , @chCheckProto   , true );
   855     RegisterVariable('-speedup', @chSpeedup_m    , true );
   857     RegisterVariable('-speedup', @chSpeedup_m    , true );
   856     RegisterVariable('zoomin'  , @chZoomIn       , true );
   858     RegisterVariable('zoomin'  , @chZoomIn       , true );
   857     RegisterVariable('zoomout' , @chZoomOut      , true );
   859     RegisterVariable('zoomout' , @chZoomOut      , true );
   858     RegisterVariable('zoomreset',@chZoomReset    , true );
   860     RegisterVariable('zoomreset',@chZoomReset    , true );
   859     RegisterVariable('ammomenu', @chAmmoMenu     , true);
   861     RegisterVariable('ammomenu', @chAmmoMenu     , true);
   860     RegisterVariable('+precise', @chPrecise_p    , false);
   862     RegisterVariable('+precise', @chPrecise_p    , false, true);
   861     RegisterVariable('-precise', @chPrecise_m    , false);
   863     RegisterVariable('-precise', @chPrecise_m    , false, true);
   862     RegisterVariable('switch'  , @chSwitch       , false);
   864     RegisterVariable('switch'  , @chSwitch       , false);
   863     RegisterVariable('timer'   , @chTimer        , false);
   865     RegisterVariable('timer'   , @chTimer        , false, true);
   864     RegisterVariable('taunt'   , @chTaunt        , false);
   866     RegisterVariable('taunt'   , @chTaunt        , false);
   865     RegisterVariable('put'     , @chPut          , false);
   867     RegisterVariable('put'     , @chPut          , false);
   866     RegisterVariable('+volup'  , @chVol_p        , true );
   868     RegisterVariable('+volup'  , @chVol_p        , true );
   867     RegisterVariable('-volup'  , @chVol_m        , true );
   869     RegisterVariable('-volup'  , @chVol_m        , true );
   868     RegisterVariable('+voldown', @chVol_m        , true );
   870     RegisterVariable('+voldown', @chVol_m        , true );