hedgewars/uCommandHandlers.pas
branchwebgl
changeset 9950 2759212a27de
parent 9521 8054d9d775fd
parent 9902 eb8e8b09b2f0
child 10015 4feced261c68
equal deleted inserted replaced
9521:8054d9d775fd 9950:2759212a27de
   107 if CurrentTeam = nil then
   107 if CurrentTeam = nil then
   108     OutError(errmsgIncorrectUse + ' "/rdriven"', true);
   108     OutError(errmsgIncorrectUse + ' "/rdriven"', true);
   109 CurrentTeam^.ExtDriven:= true
   109 CurrentTeam^.ExtDriven:= true
   110 end;
   110 end;
   111 
   111 
   112 procedure chGrave(var s: shortstring);
       
   113 begin
       
   114 if CurrentTeam = nil then
       
   115     OutError(errmsgIncorrectUse + ' "/grave"', true);
       
   116 if s[1]='"' then
       
   117     Delete(s, 1, 1);
       
   118 if s[byte(s[0])]='"' then
       
   119     Delete(s, byte(s[0]), 1);
       
   120 CurrentTeam^.GraveName:= s
       
   121 end;
       
   122 
       
   123 procedure chFort(var s: shortstring);
       
   124 begin
       
   125 if CurrentTeam = nil then
       
   126     OutError(errmsgIncorrectUse + ' "/fort"', true);
       
   127 if s[1]='"' then
       
   128     Delete(s, 1, 1);
       
   129 if s[byte(s[0])]='"' then
       
   130     Delete(s, byte(s[0]), 1);
       
   131 CurrentTeam^.FortName:= s
       
   132 end;
       
   133 
       
   134 procedure chFlag(var s: shortstring);
       
   135 begin
       
   136 if CurrentTeam = nil then
       
   137     OutError(errmsgIncorrectUse + ' "/flag"', true);
       
   138 if s[1]='"' then
       
   139     Delete(s, 1, 1);
       
   140 if s[byte(s[0])]='"' then
       
   141     Delete(s, byte(s[0]), 1);
       
   142 CurrentTeam^.flag:= s
       
   143 end;
       
   144 
       
   145 procedure chScript(var s: shortstring);
   112 procedure chScript(var s: shortstring);
   146 begin
   113 begin
   147 if s[1]='"' then
   114 if s[1]='"' then
   148     Delete(s, 1, 1);
   115     Delete(s, 1, 1);
   149 if s[byte(s[0])]='"' then
   116 if s[byte(s[0])]='"' then
   150     Delete(s, byte(s[0]), 1);
   117     Delete(s, byte(s[0]), 1);
   151 cScriptName:= s;
   118 cScriptName:= s;
   152 ScriptLoad(s)
   119 ScriptLoad(s)
   153 end;
   120 end;
   154 
   121 
   155 procedure chSetHat(var s: shortstring);
   122 procedure chScriptParam(var s: shortstring);
   156 begin
   123 begin
   157 if (not isDeveloperMode) or (CurrentTeam = nil) then exit;
   124     cScriptParam:= s;
   158 with CurrentTeam^ do
       
   159     begin
       
   160     if not CurrentHedgehog^.King then
       
   161     if (s = '')
       
   162     or (((GameFlags and gfKing) <> 0) and (s = 'crown'))
       
   163     or ((Length(s) > 39) and (Copy(s,1,8) = 'Reserved') and (Copy(s,9,32) <> PlayerHash)) then
       
   164         CurrentHedgehog^.Hat:= 'NoHat'
       
   165     else
       
   166         CurrentHedgehog^.Hat:= s
       
   167     end;
       
   168 end;
   125 end;
   169 
   126 
   170 procedure chCurU_p(var s: shortstring);
   127 procedure chCurU_p(var s: shortstring);
   171 begin
   128 begin
   172 s:= s; // avoid compiler hint
   129 s:= s; // avoid compiler hint
   640 
   597 
   641 procedure chPause(var s: shortstring);
   598 procedure chPause(var s: shortstring);
   642 begin
   599 begin
   643 s:=s; // avoid compiler hint
   600 s:=s; // avoid compiler hint
   644 if gameType <> gmtNet then
   601 if gameType <> gmtNet then
   645     isPaused:= not isPaused;
   602     isPaused:= not isPaused
   646 
   603     else
   647 if isPaused then
   604     if (CurrentTeam^.ExtDriven) or (CurrentHedgehog^.BotLevel > 0) then
       
   605         isAFK:= not isAFK
       
   606     else
       
   607         isAFK:= false; // for real ninjas
       
   608 
       
   609 if isPaused or isAFK then
   648     SDL_ShowCursor(1)
   610     SDL_ShowCursor(1)
   649     else
   611     else
   650     SDL_ShowCursor(ord(GameState = gsConfirm))
   612     SDL_ShowCursor(ord(GameState = gsConfirm))
   651 end;
   613 end;
   652 
   614 
   653 procedure chRotateMask(var s: shortstring);
   615 procedure chRotateMask(var s: shortstring);
   654 begin
   616 begin
   655 s:=s; // avoid compiler hint
   617 s:= s; // avoid compiler hint
   656 if ((GameFlags and gfInvulnerable) = 0) then
   618 // this is just for me, 'cause I thought it'd be fun.  using the old precise + switch to keep it out of people's way
   657     cTagsMask:= cTagsMasks[cTagsMask]
   619 if LocalMessage and (gmPrecise or gmSwitch) = (gmPrecise or gmSwitch) then
       
   620     begin
       
   621     if UIDisplay <> uiNone then
       
   622          UIDisplay:= uiNone
       
   623     else UIDisplay:= uiAll
       
   624     end
       
   625 else if LocalMessage and gmPrecise = gmPrecise then
       
   626     begin
       
   627     if ((GameFlags and gfInvulnerable) = 0) then
       
   628         cTagsMask:= cTagsMasks[cTagsMask]
       
   629     else
       
   630         cTagsMask:= cTagsMasksNoHealth[cTagsMask]
       
   631     end
   658 else
   632 else
   659     cTagsMask:= cTagsMasksNoHealth[cTagsMask];
   633     begin
       
   634     if UIDisplay <> uiNoTeams then
       
   635          UIDisplay:= uiNoTeams
       
   636     else UIDisplay:= uiAll
       
   637     end
   660 end;
   638 end;
   661 
   639 
   662 procedure chSpeedup_p(var s: shortstring);
   640 procedure chSpeedup_p(var s: shortstring);
   663 begin
   641 begin
   664 s:=s; // avoid compiler hint
   642 s:=s; // avoid compiler hint
   821     RegisterVariable('-attack' , @chAttack_m     , false);
   799     RegisterVariable('-attack' , @chAttack_m     , false);
   822     RegisterVariable('slot'    , @chSlot         , false);
   800     RegisterVariable('slot'    , @chSlot         , false);
   823     RegisterVariable('setweap' , @chSetWeapon    , false, true);
   801     RegisterVariable('setweap' , @chSetWeapon    , false, true);
   824 //////// End top by freq analysis
   802 //////// End top by freq analysis
   825     RegisterVariable('gencmd'  , @chGenCmd       , false);
   803     RegisterVariable('gencmd'  , @chGenCmd       , false);
   826     RegisterVariable('flag'    , @chFlag         , false);
       
   827     RegisterVariable('script'  , @chScript       , false);
   804     RegisterVariable('script'  , @chScript       , false);
       
   805     RegisterVariable('scriptparam', @chScriptParam, false);
   828     RegisterVariable('proto'   , @chCheckProto   , true );
   806     RegisterVariable('proto'   , @chCheckProto   , true );
   829     RegisterVariable('spectate', @chFastUntilLag   , false);
   807     RegisterVariable('spectate', @chFastUntilLag   , false);
   830     RegisterVariable('capture' , @chCapture      , true );
   808     RegisterVariable('capture' , @chCapture      , true );
   831     RegisterVariable('rotmask' , @chRotateMask   , true );
   809     RegisterVariable('rotmask' , @chRotateMask   , true );
   832     RegisterVariable('rdriven' , @chTeamLocal    , false);
   810     RegisterVariable('rdriven' , @chTeamLocal    , false);
   851     RegisterVariable('minesnum', @chLandMines     , false);
   829     RegisterVariable('minesnum', @chLandMines     , false);
   852     RegisterVariable('explosives',@chExplosives    , false);
   830     RegisterVariable('explosives',@chExplosives    , false);
   853     RegisterVariable('gmflags' , @chGameFlags      , false);
   831     RegisterVariable('gmflags' , @chGameFlags      , false);
   854     RegisterVariable('turntime', @chHedgehogTurnTime, false);
   832     RegisterVariable('turntime', @chHedgehogTurnTime, false);
   855     RegisterVariable('minestime',@chMinesTime     , false);
   833     RegisterVariable('minestime',@chMinesTime     , false);
   856     RegisterVariable('fort'    , @chFort         , false);
       
   857     RegisterVariable('grave'   , @chGrave        , false);
       
   858     RegisterVariable('hat'     , @chSetHat       , false);
       
   859     RegisterVariable('quit'    , @chQuit         , true );
   834     RegisterVariable('quit'    , @chQuit         , true );
   860     RegisterVariable('forcequit', @chForceQuit   , true );
   835     RegisterVariable('forcequit', @chForceQuit   , true );
   861     RegisterVariable('confirm' , @chConfirm      , true );
   836     RegisterVariable('confirm' , @chConfirm      , true );
   862     RegisterVariable('halt',     @chHalt         , true );
   837     RegisterVariable('halt',     @chHalt         , true );
   863     RegisterVariable('+speedup', @chSpeedup_p    , true );
   838     RegisterVariable('+speedup', @chSpeedup_p    , true );