hedgewars/uCommandHandlers.pas
changeset 10392 5012e1f9e893
parent 10249 b47ac2c19de3
child 10439 7de934f2247c
equal deleted inserted replaced
10391:ce3ccc45d790 10392:5012e1f9e893
    24 
    24 
    25 procedure initModule;
    25 procedure initModule;
    26 procedure freeModule;
    26 procedure freeModule;
    27 
    27 
    28 implementation
    28 implementation
    29 uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uRandom, uCaptions
    29 uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uWorld, uRandom, uCaptions
    30      {$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF};
    30      {$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF};
    31 
    31 
    32 var prevGState: TGameState = gsConfirm;
    32 var prevGState: TGameState = gsConfirm;
    33     cTagsMasks : array[0..15] of byte = (7, 0, 0, 0, 15, 6, 4, 5, 0, 0, 0, 0, 0, 14, 12, 13);
    33     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, 2, 11, 1, 0, 0, 0, 0, 0, 10, 0, 9, 0, 0, 0, 0);
    34     cTagsMasksNoHealth: array[0..15] of byte = (3, 2, 11, 1, 0, 0, 0, 0, 0, 10, 0, 9, 0, 0, 0, 0);
    50     s:= s; // avoid compiler hint
    50     s:= s; // avoid compiler hint
    51     if (GameState = gsGame) or (GameState = gsChat) then
    51     if (GameState = gsGame) or (GameState = gsChat) then
    52         begin
    52         begin
    53         prevGState:= GameState;
    53         prevGState:= GameState;
    54         GameState:= gsConfirm;
    54         GameState:= gsConfirm;
    55         SDL_ShowCursor(1)
       
    56         end
    55         end
    57     else
    56     else
    58         if GameState = gsConfirm then
    57         if GameState = gsConfirm then            
    59             begin
    58             GameState:= prevGState;            
    60             GameState:= prevGState;
    59             
    61             SDL_ShowCursor(ord(isPaused))
    60     updateCursorVisibility;
    62             end
       
    63 end;
    61 end;
    64 
    62 
    65 procedure chForceQuit(var s: shortstring);
    63 procedure chForceQuit(var s: shortstring);
    66 begin
    64 begin
    67     s:= s; // avoid compiler hint
    65     s:= s; // avoid compiler hint
   174 end;
   172 end;
   175 
   173 
   176 procedure chLeft_p(var s: shortstring);
   174 procedure chLeft_p(var s: shortstring);
   177 begin
   175 begin
   178 s:= s; // avoid compiler hint
   176 s:= s; // avoid compiler hint
   179 if CheckNoTeamOrHH or isPaused then
   177 if CheckNoTeamOrHH then
   180     exit;
   178     exit;
   181 if not isExternalSource then
   179 if not isExternalSource then
   182     SendIPC(_S'L');
   180     SendIPC(_S'L');
   183 bShowFinger:= false;
   181 bShowFinger:= false;
   184 with CurrentHedgehog^.Gear^ do
   182 with CurrentHedgehog^.Gear^ do
   199 end;
   197 end;
   200 
   198 
   201 procedure chRight_p(var s: shortstring);
   199 procedure chRight_p(var s: shortstring);
   202 begin
   200 begin
   203 s:= s; // avoid compiler hint
   201 s:= s; // avoid compiler hint
   204 if CheckNoTeamOrHH or isPaused then
   202 if CheckNoTeamOrHH then
   205     exit;
   203     exit;
   206 if not isExternalSource then
   204 if not isExternalSource then
   207     SendIPC(_S'R');
   205     SendIPC(_S'R');
   208 bShowFinger:= false;
   206 bShowFinger:= false;
   209 with CurrentHedgehog^.Gear^ do
   207 with CurrentHedgehog^.Gear^ do
   224 end;
   222 end;
   225 
   223 
   226 procedure chUp_p(var s: shortstring);
   224 procedure chUp_p(var s: shortstring);
   227 begin
   225 begin
   228 s:= s; // avoid compiler hint
   226 s:= s; // avoid compiler hint
   229 if CheckNoTeamOrHH or isPaused then
   227 if CheckNoTeamOrHH then
   230     exit;
   228     exit;
   231 if not isExternalSource then
   229 if not isExternalSource then
   232     SendIPC(_S'U');
   230     SendIPC(_S'U');
   233 bShowFinger:= false;
   231 bShowFinger:= false;
   234 with CurrentHedgehog^.Gear^ do
   232 with CurrentHedgehog^.Gear^ do
   249 end;
   247 end;
   250 
   248 
   251 procedure chDown_p(var s: shortstring);
   249 procedure chDown_p(var s: shortstring);
   252 begin
   250 begin
   253 s:= s; // avoid compiler hint
   251 s:= s; // avoid compiler hint
   254 if CheckNoTeamOrHH or isPaused then
   252 if CheckNoTeamOrHH then
   255     exit;
   253     exit;
   256 if not isExternalSource then
   254 if not isExternalSource then
   257     SendIPC(_S'D');
   255     SendIPC(_S'D');
   258 bShowFinger:= false;
   256 bShowFinger:= false;
   259 with CurrentHedgehog^.Gear^ do
   257 with CurrentHedgehog^.Gear^ do
   274 end;
   272 end;
   275 
   273 
   276 procedure chPrecise_p(var s: shortstring);
   274 procedure chPrecise_p(var s: shortstring);
   277 begin
   275 begin
   278 s:= s; // avoid compiler hint
   276 s:= s; // avoid compiler hint
   279 if CheckNoTeamOrHH or isPaused then
   277 if CheckNoTeamOrHH then
   280     exit;
   278     exit;
   281 if not isExternalSource then
   279 if not isExternalSource then
   282     SendIPC(_S'Z');
   280     SendIPC(_S'Z');
   283 bShowFinger:= false;
   281 bShowFinger:= false;
   284 with CurrentHedgehog^.Gear^ do
   282 with CurrentHedgehog^.Gear^ do
   299 end;
   297 end;
   300 
   298 
   301 procedure chLJump(var s: shortstring);
   299 procedure chLJump(var s: shortstring);
   302 begin
   300 begin
   303 s:= s; // avoid compiler hint
   301 s:= s; // avoid compiler hint
   304 if CheckNoTeamOrHH or isPaused then
   302 if CheckNoTeamOrHH then
   305     exit;
   303     exit;
   306 if not isExternalSource then
   304 if not isExternalSource then
   307     SendIPC(_S'j');
   305     SendIPC(_S'j');
   308 bShowFinger:= false;
   306 bShowFinger:= false;
   309 with CurrentHedgehog^.Gear^ do
   307 with CurrentHedgehog^.Gear^ do
   312 end;
   310 end;
   313 
   311 
   314 procedure chHJump(var s: shortstring);
   312 procedure chHJump(var s: shortstring);
   315 begin
   313 begin
   316 s:= s; // avoid compiler hint
   314 s:= s; // avoid compiler hint
   317 if CheckNoTeamOrHH or isPaused then
   315 if CheckNoTeamOrHH then
   318     exit;
   316     exit;
   319 if not isExternalSource then
   317 if not isExternalSource then
   320     SendIPC(_S'J');
   318     SendIPC(_S'J');
   321 bShowFinger:= false;
   319 bShowFinger:= false;
   322 with CurrentHedgehog^.Gear^ do
   320 with CurrentHedgehog^.Gear^ do
   325 end;
   323 end;
   326 
   324 
   327 procedure chAttack_p(var s: shortstring);
   325 procedure chAttack_p(var s: shortstring);
   328 begin
   326 begin
   329 s:= s; // avoid compiler hint
   327 s:= s; // avoid compiler hint
   330 if CheckNoTeamOrHH or isPaused then
   328 if CheckNoTeamOrHH then
   331     exit;
   329     exit;
   332 bShowFinger:= false;
   330 bShowFinger:= false;
   333 with CurrentHedgehog^.Gear^ do
   331 with CurrentHedgehog^.Gear^ do
   334     begin
   332     begin
   335     AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State));
   333     AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State));
   360 end;
   358 end;
   361 
   359 
   362 procedure chSwitch(var s: shortstring);
   360 procedure chSwitch(var s: shortstring);
   363 begin
   361 begin
   364 s:= s; // avoid compiler hint
   362 s:= s; // avoid compiler hint
   365 if CheckNoTeamOrHH or isPaused then
   363 if CheckNoTeamOrHH then
   366     exit;
   364     exit;
   367 if not isExternalSource then
   365 if not isExternalSource then
   368     SendIPC(_S'S');
   366     SendIPC(_S'S');
   369 bShowFinger:= false;
   367 bShowFinger:= false;
   370 with CurrentHedgehog^.Gear^ do
   368 with CurrentHedgehog^.Gear^ do
   574 end;
   572 end;
   575 
   573 
   576 procedure chFindhh(var s: shortstring);
   574 procedure chFindhh(var s: shortstring);
   577 begin
   575 begin
   578 s:= s; // avoid compiler hint
   576 s:= s; // avoid compiler hint
   579 if CheckNoTeamOrHH or isPaused then
   577 if CheckNoTeamOrHH then
   580     exit;
   578     exit;
   581 
   579 
   582 if autoCameraOn then
   580 if autoCameraOn then
   583     begin
   581     begin
   584     FollowGear:= nil;
   582     FollowGear:= nil;
   595     end
   593     end
   596 end;
   594 end;
   597 
   595 
   598 procedure chPause(var s: shortstring);
   596 procedure chPause(var s: shortstring);
   599 begin
   597 begin
   600 s:= s; // avoid compiler hint
   598 if (gameType <> gmtNet) or (s = 'server') then
   601 if gameType <> gmtNet then
       
   602     isPaused:= not isPaused
   599     isPaused:= not isPaused
   603     else
   600     else
   604     if (CurrentTeam^.ExtDriven) or (CurrentHedgehog^.BotLevel > 0) then
   601     if (CurrentTeam^.ExtDriven) or (CurrentHedgehog^.BotLevel > 0) then
   605         isAFK:= not isAFK
   602         isAFK:= not isAFK
   606     else
   603     else
   607         isAFK:= false; // for real ninjas
   604         isAFK:= false; // for real ninjas
   608 
   605 
   609 if isPaused or isAFK then
   606 updateCursorVisibility;
   610     SDL_ShowCursor(1)
       
   611     else
       
   612     SDL_ShowCursor(ord(GameState = gsConfirm))
       
   613 end;
   607 end;
   614 
   608 
   615 procedure chRotateMask(var s: shortstring);
   609 procedure chRotateMask(var s: shortstring);
   616 begin
   610 begin
   617 s:= s; // avoid compiler hint
   611 s:= s; // avoid compiler hint