hedgewars/uCommandHandlers.pas
branchios-develop
changeset 13413 ba39a1d396c0
parent 13107 7b3bc9a4dfb9
child 13459 08a3851aaf67
equal deleted inserted replaced
13411:6e8b807bda4b 13413:ba39a1d396c0
    28 implementation
    28 implementation
    29 uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uWorld, uRandom, uCaptions
    29 uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uWorld, uRandom, uCaptions
    30     , uVisualGearsList, uGearsHedgehog
    30     , uVisualGearsList, uGearsHedgehog
    31      {$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF};
    31      {$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF};
    32 
    32 
    33 var prevGState: TGameState = gsConfirm;
    33 var cTagsMasks : array[0..15] of byte = (7, 0, 0, 0, 0, 4, 5, 6, 15, 8, 8, 8, 8, 12, 13, 14);
    34     cTagsMasks : array[0..15] of byte = (7, 0, 0, 0, 15, 6, 4, 5, 0, 0, 0, 0, 0, 14, 12, 13);
    34     cTagsMasksNoHealth: array[0..15] of byte = (3, 0, 1, 2, 0, 0, 0, 0, 11, 8, 9, 10, 8, 8, 8, 8);
    35     cTagsMasksNoHealth: array[0..15] of byte = (3, 2, 11, 1, 0, 0, 0, 0, 0, 10, 0, 9, 0, 0, 0, 0);
       
    36 
    35 
    37 procedure chGenCmd(var s: shortstring);
    36 procedure chGenCmd(var s: shortstring);
    38 begin
    37 begin
    39 case s[1] of
    38 case s[1] of
    40     'R': if ReadyTimeLeft > 0 then
    39     'R': if ReadyTimeLeft > 0 then
    47 end;
    46 end;
    48 
    47 
    49 procedure chQuit(var s: shortstring);
    48 procedure chQuit(var s: shortstring);
    50 begin
    49 begin
    51     s:= s; // avoid compiler hint
    50     s:= s; // avoid compiler hint
    52     if (GameState = gsGame) or (GameState = gsChat) then
    51     if (GameState = gsGame) then
    53         begin
    52     begin
    54         prevGState:= GameState;
    53         isInChatMode:= false;
    55         GameState:= gsConfirm;
    54         GameState:= gsConfirm;
    56         end
    55     end
    57     else
    56     else begin
    58         if GameState = gsConfirm then
    57         if GameState = gsConfirm then
    59             GameState:= prevGState;
    58             GameState:= gsGame;
       
    59     end;
    60 
    60 
    61     updateCursorVisibility;
    61     updateCursorVisibility;
    62 end;
    62 end;
    63 
    63 
    64 procedure chForceQuit(var s: shortstring);
    64 procedure chForceQuit(var s: shortstring);
    74     if GameState = gsConfirm then
    74     if GameState = gsConfirm then
    75         begin
    75         begin
    76         SendIPC(_S'Q');
    76         SendIPC(_S'Q');
    77         GameState:= gsExit
    77         GameState:= gsExit
    78         end
    78         end
    79     else
       
    80         ParseCommand('chat team', true);
       
    81 end;
    79 end;
    82 
    80 
    83 procedure chHalt (var s: shortstring);
    81 procedure chHalt (var s: shortstring);
    84 begin
    82 begin
    85     s:= s; // avoid compiler hint
    83     s:= s; // avoid compiler hint
   531     begin
   529     begin
   532     SetRandomSeed(s, true);
   530     SetRandomSeed(s, true);
   533     cSeed:= s;
   531     cSeed:= s;
   534     InitStepsFlags:= InitStepsFlags or cifRandomize
   532     InitStepsFlags:= InitStepsFlags or cifRandomize
   535     end
   533     end
   536     end;
   534 end;
   537 
   535 
   538 procedure chAmmoMenu(var s: shortstring);
   536 procedure chAmmoMenu(var s: shortstring);
   539 begin
   537 begin
   540 s:= s; // avoid compiler hint
   538 s:= s; // avoid compiler hint
   541 if CheckNoTeamOrHH then
   539 if CheckNoTeamOrHH then
   569 begin
   567 begin
   570 s:= s; // avoid compiler hint
   568 s:= s; // avoid compiler hint
   571 dec(cVolumeDelta, 3)
   569 dec(cVolumeDelta, 3)
   572 end;
   570 end;
   573 
   571 
       
   572 procedure chMute(var s: shortstring);
       
   573 begin
       
   574 s:= s; // avoid compiler hint
       
   575 cMuteToggle:= true;
       
   576 end;
       
   577 
   574 procedure chFindhh(var s: shortstring);
   578 procedure chFindhh(var s: shortstring);
   575 begin
   579 begin
   576 s:= s; // avoid compiler hint
   580 s:= s; // avoid compiler hint
   577 if CheckNoTeamOrHH then
   581 if CheckNoTeamOrHH then
   578     exit;
   582     exit;
   614     begin
   618     begin
   615     if UIDisplay <> uiNone then
   619     if UIDisplay <> uiNone then
   616          UIDisplay:= uiNone
   620          UIDisplay:= uiNone
   617     else UIDisplay:= uiAll
   621     else UIDisplay:= uiAll
   618     end
   622     end
       
   623 else
       
   624     begin
       
   625     if UIDisplay <> uiNoTeams then
       
   626          UIDisplay:= uiNoTeams
       
   627     else UIDisplay:= uiAll
       
   628     end
       
   629 end;
       
   630 
       
   631 procedure chRotateTags(var s: shortstring);
       
   632 begin
       
   633 s:= s; // avoid compiler hint
       
   634 // Rotate Tags key + Switch: Toggle translucency only
       
   635 if LocalMessage and gmSwitch = gmSwitch then
       
   636     if ((cTagsMask and htTransparent) = 0) then
       
   637         begin
       
   638         cTagsMask:= cTagsMask or htTransparent;
       
   639         cPrevTagsMask:= cPrevTagsMask or htTransparent
       
   640         end
       
   641     else
       
   642         begin
       
   643         cTagsMask:= cTagsMask and (not htTransparent);
       
   644         cPrevTagsMask:= cPrevTagsMask and (not htTransparent)
       
   645         end
       
   646 // Rotate Tags key + Precise: Cycle through hog tags (keeping translucency)
   619 else if LocalMessage and gmPrecise = gmPrecise then
   647 else if LocalMessage and gmPrecise = gmPrecise then
   620     begin
   648     begin
       
   649     cPrevTagsMask:= cTagsMask;
   621     if ((GameFlags and gfInvulnerable) = 0) then
   650     if ((GameFlags and gfInvulnerable) = 0) then
   622         cTagsMask:= cTagsMasks[cTagsMask]
   651         cTagsMask:= cTagsMasks[cTagsMask]
   623     else
   652     else
   624         cTagsMask:= cTagsMasksNoHealth[cTagsMask]
   653         cTagsMask:= cTagsMasksNoHealth[cTagsMask]
   625     end
   654     end
       
   655 // Rotate Tags key only: Toggle all hog tags on and off
   626 else
   656 else
   627     begin
   657     if ((cTagsMask and (htTeamName or htName or htHealth)) = 0) then
   628     if UIDisplay <> uiNoTeams then
   658         begin
   629          UIDisplay:= uiNoTeams
   659         cTagsMask:= cPrevTagsMask;
   630     else UIDisplay:= uiAll
   660         if ((GameFlags and gfInvulnerable) <> 0) then
   631     end
   661             cTagsMask:= cTagsMask and (not htHealth);
       
   662         end
       
   663     else
       
   664         begin
       
   665         cPrevTagsMask:= cTagsMask;
       
   666         cTagsMask:= cTagsMask and (not (htTeamName or htName or htHealth))
       
   667         end;
   632 end;
   668 end;
   633 
   669 
   634 procedure chSpeedup_p(var s: shortstring);
   670 procedure chSpeedup_p(var s: shortstring);
   635 begin
   671 begin
   636 s:= s; // avoid compiler hint
   672 s:= s; // avoid compiler hint
   822     RegisterVariable('scriptparam', @chScriptParam, false);
   858     RegisterVariable('scriptparam', @chScriptParam, false);
   823     RegisterVariable('proto'   , @chCheckProto   , true );
   859     RegisterVariable('proto'   , @chCheckProto   , true );
   824     RegisterVariable('spectate', @chFastUntilLag   , false);
   860     RegisterVariable('spectate', @chFastUntilLag   , false);
   825     RegisterVariable('capture' , @chCapture      , true );
   861     RegisterVariable('capture' , @chCapture      , true );
   826     RegisterVariable('rotmask' , @chRotateMask   , true );
   862     RegisterVariable('rotmask' , @chRotateMask   , true );
       
   863     RegisterVariable('rottags' , @chRotateTags   , true );
   827     RegisterVariable('rdriven' , @chTeamLocal    , false);
   864     RegisterVariable('rdriven' , @chTeamLocal    , false);
   828     RegisterVariable('map'     , @chSetMap       , false);
   865     RegisterVariable('map'     , @chSetMap       , false);
   829     RegisterVariable('theme'   , @chSetTheme     , false);
   866     RegisterVariable('theme'   , @chSetTheme     , false);
   830     RegisterVariable('seed'    , @chSetSeed      , false);
   867     RegisterVariable('seed'    , @chSetSeed      , false);
   831     RegisterVariable('template_filter', @chTemplateFilter, false);
   868     RegisterVariable('template_filter', @chTemplateFilter, false);
   868     RegisterVariable('put'     , @chPut          , false);
   905     RegisterVariable('put'     , @chPut          , false);
   869     RegisterVariable('+volup'  , @chVol_p        , true );
   906     RegisterVariable('+volup'  , @chVol_p        , true );
   870     RegisterVariable('-volup'  , @chVol_m        , true );
   907     RegisterVariable('-volup'  , @chVol_m        , true );
   871     RegisterVariable('+voldown', @chVol_m        , true );
   908     RegisterVariable('+voldown', @chVol_m        , true );
   872     RegisterVariable('-voldown', @chVol_p        , true );
   909     RegisterVariable('-voldown', @chVol_p        , true );
       
   910     RegisterVariable('mute'    , @chMute         , true );
   873     RegisterVariable('findhh'  , @chFindhh       , true );
   911     RegisterVariable('findhh'  , @chFindhh       , true );
   874     RegisterVariable('pause'   , @chPause        , true );
   912     RegisterVariable('pause'   , @chPause        , true );
   875     RegisterVariable('+cur_u'  , @chCurU_p       , true );
   913     RegisterVariable('+cur_u'  , @chCurU_p       , true );
   876     RegisterVariable('-cur_u'  , @chCurU_m       , true );
   914     RegisterVariable('-cur_u'  , @chCurU_m       , true );
   877     RegisterVariable('+cur_d'  , @chCurD_p       , true );
   915     RegisterVariable('+cur_d'  , @chCurD_p       , true );