hedgewars/CCHandlers.inc
changeset 3776 28849f5a03c9
parent 3774 af0e68ca273e
child 3796 4ab6d6f78312
equal deleted inserted replaced
3775:c0397452e7c5 3776:28849f5a03c9
   287 end;
   287 end;
   288 
   288 
   289 procedure chLeft_p(var s: shortstring);
   289 procedure chLeft_p(var s: shortstring);
   290 begin
   290 begin
   291 s:= s; // avoid compiler hint
   291 s:= s; // avoid compiler hint
   292 if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit;
   292 if CheckNoTeamOrHH or isPaused then exit;
   293 bShowFinger:= false;
       
   294 if not CurrentTeam^.ExtDriven then SendIPC('L');
   293 if not CurrentTeam^.ExtDriven then SendIPC('L');
       
   294 if ReadyTimeLeft > 1 then begin ReadyTimeLeft:= 1; exit end;
       
   295 bShowFinger:= false;
   295 with CurrentHedgehog^.Gear^ do
   296 with CurrentHedgehog^.Gear^ do
   296     Message:= Message or gm_Left
   297     Message:= Message or gm_Left
   297 end;
   298 end;
   298 
   299 
   299 procedure chLeft_m(var s: shortstring);
   300 procedure chLeft_m(var s: shortstring);
   306 end;
   307 end;
   307 
   308 
   308 procedure chRight_p(var s: shortstring);
   309 procedure chRight_p(var s: shortstring);
   309 begin
   310 begin
   310 s:= s; // avoid compiler hint
   311 s:= s; // avoid compiler hint
   311 if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit;
   312 if CheckNoTeamOrHH or isPaused then exit;
   312 bShowFinger:= false;
       
   313 if not CurrentTeam^.ExtDriven then SendIPC('R');
   313 if not CurrentTeam^.ExtDriven then SendIPC('R');
       
   314 if ReadyTimeLeft > 1 then begin ReadyTimeLeft:= 1; exit end;
       
   315 bShowFinger:= false;
   314 with CurrentHedgehog^.Gear^ do
   316 with CurrentHedgehog^.Gear^ do
   315     Message:= Message or gm_Right
   317     Message:= Message or gm_Right
   316 end;
   318 end;
   317 
   319 
   318 procedure chRight_m(var s: shortstring);
   320 procedure chRight_m(var s: shortstring);
   325 end;
   327 end;
   326 
   328 
   327 procedure chUp_p(var s: shortstring);
   329 procedure chUp_p(var s: shortstring);
   328 begin
   330 begin
   329 s:= s; // avoid compiler hint
   331 s:= s; // avoid compiler hint
   330 if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit;
   332 if CheckNoTeamOrHH or isPaused then exit;
   331 bShowFinger:= false;
       
   332 if not CurrentTeam^.ExtDriven then SendIPC('U');
   333 if not CurrentTeam^.ExtDriven then SendIPC('U');
       
   334 if ReadyTimeLeft > 1 then begin ReadyTimeLeft:= 1; exit end;
       
   335 bShowFinger:= false;
   333 with CurrentHedgehog^.Gear^ do
   336 with CurrentHedgehog^.Gear^ do
   334     Message:= Message or gm_Up
   337     Message:= Message or gm_Up
   335 end;
   338 end;
   336 
   339 
   337 procedure chUp_m(var s: shortstring);
   340 procedure chUp_m(var s: shortstring);
   344 end;
   347 end;
   345 
   348 
   346 procedure chDown_p(var s: shortstring);
   349 procedure chDown_p(var s: shortstring);
   347 begin
   350 begin
   348 s:= s; // avoid compiler hint
   351 s:= s; // avoid compiler hint
   349 if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit;
   352 if CheckNoTeamOrHH or isPaused then exit;
   350 bShowFinger:= false;
       
   351 if not CurrentTeam^.ExtDriven then SendIPC('D');
   353 if not CurrentTeam^.ExtDriven then SendIPC('D');
       
   354 if ReadyTimeLeft > 1 then begin ReadyTimeLeft:= 1; exit end;
       
   355 bShowFinger:= false;
   352 with CurrentHedgehog^.Gear^ do
   356 with CurrentHedgehog^.Gear^ do
   353     Message:= Message or gm_Down
   357     Message:= Message or gm_Down
   354 end;
   358 end;
   355 
   359 
   356 procedure chDown_m(var s: shortstring);
   360 procedure chDown_m(var s: shortstring);
   363 end;
   367 end;
   364 
   368 
   365 procedure chPrecise_p(var s: shortstring);
   369 procedure chPrecise_p(var s: shortstring);
   366 begin
   370 begin
   367 s:= s; // avoid compiler hint
   371 s:= s; // avoid compiler hint
   368 if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit;
   372 if CheckNoTeamOrHH or isPaused then exit;
   369 bShowFinger:= false;
       
   370 if not CurrentTeam^.ExtDriven then SendIPC('Z');
   373 if not CurrentTeam^.ExtDriven then SendIPC('Z');
       
   374 if ReadyTimeLeft > 1 then begin ReadyTimeLeft:= 1; exit end;
       
   375 bShowFinger:= false;
   371 with CurrentHedgehog^.Gear^ do
   376 with CurrentHedgehog^.Gear^ do
   372     Message:= Message or gm_Precise
   377     Message:= Message or gm_Precise
   373 end;
   378 end;
   374 
   379 
   375 procedure chPrecise_m(var s: shortstring);
   380 procedure chPrecise_m(var s: shortstring);
   382 end;
   387 end;
   383 
   388 
   384 procedure chLJump(var s: shortstring);
   389 procedure chLJump(var s: shortstring);
   385 begin
   390 begin
   386 s:= s; // avoid compiler hint
   391 s:= s; // avoid compiler hint
   387 if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit;
   392 if CheckNoTeamOrHH or isPaused then exit;
   388 bShowFinger:= false;
       
   389 if not CurrentTeam^.ExtDriven then SendIPC('j');
   393 if not CurrentTeam^.ExtDriven then SendIPC('j');
       
   394 if ReadyTimeLeft > 1 then begin ReadyTimeLeft:= 1; exit end;
       
   395 bShowFinger:= false;
   390 with CurrentHedgehog^.Gear^ do
   396 with CurrentHedgehog^.Gear^ do
   391     Message:= Message or gm_LJump
   397     Message:= Message or gm_LJump
   392 end;
   398 end;
   393 
   399 
   394 procedure chHJump(var s: shortstring);
   400 procedure chHJump(var s: shortstring);
   395 begin
   401 begin
   396 s:= s; // avoid compiler hint
   402 s:= s; // avoid compiler hint
   397 if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit;
   403 if CheckNoTeamOrHH or isPaused then exit;
   398 bShowFinger:= false;
       
   399 if not CurrentTeam^.ExtDriven then SendIPC('J');
   404 if not CurrentTeam^.ExtDriven then SendIPC('J');
       
   405 if ReadyTimeLeft > 1 then begin ReadyTimeLeft:= 1; exit end;
       
   406 bShowFinger:= false;
   400 with CurrentHedgehog^.Gear^ do
   407 with CurrentHedgehog^.Gear^ do
   401     Message:= Message or gm_HJump
   408     Message:= Message or gm_HJump
   402 end;
   409 end;
   403 
   410 
   404 procedure chAttack_p(var s: shortstring);
   411 procedure chAttack_p(var s: shortstring);
   437 end;
   444 end;
   438 
   445 
   439 procedure chSwitch(var s: shortstring);
   446 procedure chSwitch(var s: shortstring);
   440 begin
   447 begin
   441 s:= s; // avoid compiler hint
   448 s:= s; // avoid compiler hint
   442 if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit;
   449 if CheckNoTeamOrHH or isPaused then exit;
   443 if not CurrentTeam^.ExtDriven then SendIPC('S');
   450 if not CurrentTeam^.ExtDriven then SendIPC('S');
       
   451 if ReadyTimeLeft > 1 then begin ReadyTimeLeft:= 1; exit end;
       
   452 bShowFinger:= false;
   444 with CurrentHedgehog^.Gear^ do
   453 with CurrentHedgehog^.Gear^ do
   445     Message:= Message or gm_Switch
   454     Message:= Message or gm_Switch
   446 end;
   455 end;
   447 
   456 
   448 procedure chNextTurn(var s: shortstring);
   457 procedure chNextTurn(var s: shortstring);
   481 end;
   490 end;
   482 
   491 
   483 procedure chTimer(var s: shortstring);
   492 procedure chTimer(var s: shortstring);
   484 begin
   493 begin
   485 if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or CheckNoTeamOrHH then exit;
   494 if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or CheckNoTeamOrHH then exit;
   486 bShowFinger:= false;
       
   487 
   495 
   488 if not CurrentTeam^.ExtDriven then SendIPC(s);
   496 if not CurrentTeam^.ExtDriven then SendIPC(s);
       
   497 if ReadyTimeLeft > 1 then begin ReadyTimeLeft:= 1; exit end;
       
   498 bShowFinger:= false;
   489 with CurrentHedgehog^.Gear^ do
   499 with CurrentHedgehog^.Gear^ do
   490     begin
   500     begin
   491     Message:= Message or gm_Timer;
   501     Message:= Message or gm_Timer;
   492     MsgParam:= byte(s[1]) - ord('0')
   502     MsgParam:= byte(s[1]) - ord('0')
   493     end
   503     end
   495 
   505 
   496 procedure chSlot(var s: shortstring);
   506 procedure chSlot(var s: shortstring);
   497 var slot: LongWord;
   507 var slot: LongWord;
   498 begin
   508 begin
   499 if (s[0] <> #1) or CheckNoTeamOrHH then exit;
   509 if (s[0] <> #1) or CheckNoTeamOrHH then exit;
   500 bShowFinger:= false;
       
   501 slot:= byte(s[1]) - 49;
   510 slot:= byte(s[1]) - 49;
   502 if slot > cMaxSlotIndex then exit;
   511 if slot > cMaxSlotIndex then exit;
   503 if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79));
   512 if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79));
       
   513 if ReadyTimeLeft > 1 then begin ReadyTimeLeft:= 1; exit end;
       
   514 bShowFinger:= false;
   504 with CurrentHedgehog^.Gear^ do
   515 with CurrentHedgehog^.Gear^ do
   505     begin
   516     begin
   506     Message:= Message or gm_Slot;
   517     Message:= Message or gm_Slot;
   507     MsgParam:= slot
   518     MsgParam:= slot
   508     end
   519     end
   570 
   581 
   571 end;
   582 end;
   572 
   583 
   573 procedure chNewGrave;
   584 procedure chNewGrave;
   574 begin
   585 begin
   575 if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit;
   586 if CheckNoTeamOrHH or isPaused then exit;
       
   587 
       
   588 if ReadyTimeLeft > 1 then begin ReadyTimeLeft:= 1; exit end;
   576 
   589 
   577 if not CurrentTeam^.ExtDriven then SendIPC('g');
   590 if not CurrentTeam^.ExtDriven then SendIPC('g');
   578 
   591 
   579 AddGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), gtGrave, 0, _0, _0, 0)
   592 AddGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), gtGrave, 0, _0, _0, 0)
   580 end;
   593 end;
   581 
   594 
   582 procedure doPut(putX, putY: LongInt; fromAI: boolean);
   595 procedure doPut(putX, putY: LongInt; fromAI: boolean);
   583 begin
   596 begin
   584 if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit;
   597 if CheckNoTeamOrHH or isPaused then exit;
       
   598 if ReadyTimeLeft > 1 then begin ReadyTimeLeft:= 1; exit end;
       
   599 bShowFinger:= false;
   585 if not CurrentTeam^.ExtDriven and bShowAmmoMenu then
   600 if not CurrentTeam^.ExtDriven and bShowAmmoMenu then
   586     begin
   601     begin
   587     bSelected:= true;
   602     bSelected:= true;
   588     exit
   603     exit
   589     end;
   604     end;
   783 end;
   798 end;
   784 
   799 
   785 procedure chPause(var s: shortstring);
   800 procedure chPause(var s: shortstring);
   786 begin
   801 begin
   787 s:= s; // avoid compiler hint
   802 s:= s; // avoid compiler hint
       
   803 if ReadyTimeLeft > 1 then begin ReadyTimeLeft:= 1; exit end;
   788 if gameType <> gmtNet then
   804 if gameType <> gmtNet then
   789     isPaused:= not isPaused;
   805     isPaused:= not isPaused;
   790 SDL_ShowCursor(ord(isPaused))
   806 SDL_ShowCursor(ord(isPaused))
   791 end;
   807 end;
   792 
   808