hedgewars/uCommandHandlers.pas
changeset 7439 0a494f951dcf
parent 7426 55b49cc1f33a
child 7442 9bb6abdb5675
child 7468 1333ca7554dc
equal deleted inserted replaced
7358:57a508884052 7439:0a494f951dcf
   410     Message:= Message or (gmSwitch and InputMask);
   410     Message:= Message or (gmSwitch and InputMask);
   411     ScriptCall('onSwitch');
   411     ScriptCall('onSwitch');
   412 end;
   412 end;
   413 
   413 
   414 procedure chNextTurn(var s: shortstring);
   414 procedure chNextTurn(var s: shortstring);
   415 var checksum: Longword;
   415 var i: Longword;
   416     gi: PGear;
   416     gi: PGear;
   417 begin
   417 begin
   418     s:= s; // avoid compiler hint
   418     s:= s; // avoid compiler hint
   419 
   419 
   420     TryDo(AllInactive, '/nextturn called when not all gears are inactive', true);
   420     TryDo(AllInactive, '/nextturn called when not all gears are inactive', true);
   421 
   421 
   422     checksum:= GameTicks;
   422     CheckSum:= CheckSum xor GameTicks;
   423     gi := GearsList;
   423     gi := GearsList;
   424     while gi <> nil do
   424     while gi <> nil do
   425         begin
   425         begin
   426         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;
   426         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         AddRandomness(CheckSum);
   427         gi := gi^.NextGear
   428         gi := gi^.NextGear
   428         end;
   429         end;
   429 
   430 
   430     if not CurrentTeam^.ExtDriven then
   431     if not CurrentTeam^.ExtDriven then
   431         begin
   432         begin
   432         s[0]:= #5;
   433         s[0]:= #5;
   433         s[1]:= 'N';
   434         s[1]:= 'N';
   434         SDLNet_Write32(checksum, @s[2]);
   435         SDLNet_Write32(CheckSum, @s[2]);
   435         SendIPC(s)
   436         SendIPC(s)
   436         end
   437         end
   437     else
   438     else
   438         TryDo(checksum = lastTurnChecksum, 'Desync detected', true);
   439         TryDo(CheckSum = lastTurnChecksum, 'Desync detected', true);
   439     AddFileLog('Next turn: time '+inttostr(GameTicks));
   440     AddFileLog('Next turn: time '+inttostr(GameTicks));
   440 end;
   441 end;
   441 
   442 
   442 procedure chTimer(var s: shortstring);
   443 procedure chTimer(var s: shortstring);
   443 begin
   444 begin
   650 end;
   651 end;
   651 
   652 
   652 procedure chSpeedup_p(var s: shortstring);
   653 procedure chSpeedup_p(var s: shortstring);
   653 begin
   654 begin
   654 s:= s; // avoid compiler hint
   655 s:= s; // avoid compiler hint
       
   656 SpeedStart:= RealTicks;
   655 isSpeed:= true
   657 isSpeed:= true
   656 end;
   658 end;
   657 
   659 
   658 procedure chSpeedup_m(var s: shortstring);
   660 procedure chSpeedup_m(var s: shortstring);
   659 begin
   661 begin
   762 end;
   764 end;
   763 
   765 
   764 procedure chGameFlags(var s: shortstring);
   766 procedure chGameFlags(var s: shortstring);
   765 begin
   767 begin
   766 GameFlags:= StrToInt(s);
   768 GameFlags:= StrToInt(s);
   767 if GameFlags and gfSharedAmmo <> 0 then GameFlags:= GameFlags and not gfPerHogAmmo
   769 if GameFlags and gfSharedAmmo <> 0 then GameFlags:= GameFlags and (not gfPerHogAmmo)
   768 end;
   770 end;
   769 
   771 
   770 procedure chHedgehogTurnTime(var s: shortstring);
   772 procedure chHedgehogTurnTime(var s: shortstring);
   771 begin
   773 begin
   772 cHedgehogTurnTime:= StrToInt(s)
   774 cHedgehogTurnTime:= StrToInt(s)
   783 end;
   785 end;
   784 
   786 
   785 procedure initModule;
   787 procedure initModule;
   786 begin
   788 begin
   787 //////// Begin top sorted by freq analysis not including chatmsg
   789 //////// Begin top sorted by freq analysis not including chatmsg
   788     RegisterVariable('+right'  , @chRight_p      , false);
   790     RegisterVariable('+right'  , @chRight_p      , false, true);
   789     RegisterVariable('-right'  , @chRight_m      , false);
   791     RegisterVariable('-right'  , @chRight_m      , false, true);
   790     RegisterVariable('+up'     , @chUp_p         , false);
   792     RegisterVariable('+up'     , @chUp_p         , false, true);
   791     RegisterVariable('-up'     , @chUp_m         , false);
   793     RegisterVariable('-up'     , @chUp_m         , false, true);
   792     RegisterVariable('+left'   , @chLeft_p       , false);
   794     RegisterVariable('+left'   , @chLeft_p       , false, true);
   793     RegisterVariable('-left'   , @chLeft_m       , false);
   795     RegisterVariable('-left'   , @chLeft_m       , false, true);
   794     RegisterVariable('+attack' , @chAttack_p     , false);
   796     RegisterVariable('+attack' , @chAttack_p     , false);
   795     RegisterVariable('+down'   , @chDown_p       , false);
   797     RegisterVariable('+down'   , @chDown_p       , false, true);
   796     RegisterVariable('-down'   , @chDown_m       , false);
   798     RegisterVariable('-down'   , @chDown_m       , false, true);
   797     RegisterVariable('hjump'   , @chHJump        , false);
   799     RegisterVariable('hjump'   , @chHJump        , false, true);
   798     RegisterVariable('ljump'   , @chLJump        , false);
   800     RegisterVariable('ljump'   , @chLJump        , false, true);
   799     RegisterVariable('nextturn', @chNextTurn     , false);
   801     RegisterVariable('nextturn', @chNextTurn     , false);
   800     RegisterVariable('-attack' , @chAttack_m     , false);
   802     RegisterVariable('-attack' , @chAttack_m     , false);
   801     RegisterVariable('slot'    , @chSlot         , false);
   803     RegisterVariable('slot'    , @chSlot         , false);
   802     RegisterVariable('setweap' , @chSetWeapon    , false);
   804     RegisterVariable('setweap' , @chSetWeapon    , false, true);
   803 //////// End top by freq analysis
   805 //////// End top by freq analysis
   804     RegisterVariable('gencmd'  , @chGenCmd       , false);
   806     RegisterVariable('gencmd'  , @chGenCmd       , false);
   805     RegisterVariable('flag'    , @chFlag         , false);
   807     RegisterVariable('flag'    , @chFlag         , false);
   806     RegisterVariable('script'  , @chScript       , false);
   808     RegisterVariable('script'  , @chScript       , false);
   807     RegisterVariable('proto'   , @chCheckProto   , true );
   809     RegisterVariable('proto'   , @chCheckProto   , true );
   843     RegisterVariable('-speedup', @chSpeedup_m    , true );
   845     RegisterVariable('-speedup', @chSpeedup_m    , true );
   844     RegisterVariable('zoomin'  , @chZoomIn       , true );
   846     RegisterVariable('zoomin'  , @chZoomIn       , true );
   845     RegisterVariable('zoomout' , @chZoomOut      , true );
   847     RegisterVariable('zoomout' , @chZoomOut      , true );
   846     RegisterVariable('zoomreset',@chZoomReset    , true );
   848     RegisterVariable('zoomreset',@chZoomReset    , true );
   847     RegisterVariable('ammomenu', @chAmmoMenu     , true);
   849     RegisterVariable('ammomenu', @chAmmoMenu     , true);
   848     RegisterVariable('+precise', @chPrecise_p    , false);
   850     RegisterVariable('+precise', @chPrecise_p    , false, true);
   849     RegisterVariable('-precise', @chPrecise_m    , false);
   851     RegisterVariable('-precise', @chPrecise_m    , false, true);
   850     RegisterVariable('switch'  , @chSwitch       , false);
   852     RegisterVariable('switch'  , @chSwitch       , false);
   851     RegisterVariable('timer'   , @chTimer        , false);
   853     RegisterVariable('timer'   , @chTimer        , false, true);
   852     RegisterVariable('taunt'   , @chTaunt        , false);
   854     RegisterVariable('taunt'   , @chTaunt        , false);
   853     RegisterVariable('put'     , @chPut          , false);
   855     RegisterVariable('put'     , @chPut          , false);
   854     RegisterVariable('+volup'  , @chVol_p        , true );
   856     RegisterVariable('+volup'  , @chVol_p        , true );
   855     RegisterVariable('-volup'  , @chVol_m        , true );
   857     RegisterVariable('-volup'  , @chVol_m        , true );
   856     RegisterVariable('+voldown', @chVol_m        , true );
   858     RegisterVariable('+voldown', @chVol_m        , true );