hedgewars/uCommandHandlers.pas
branchwebgl
changeset 8026 4a4f21070479
parent 7946 a99a79bbd857
child 8096 453917e94e55
equal deleted inserted replaced
8023:7de85783b823 8026:4a4f21070479
   183 CursorMovementY:= 1;
   183 CursorMovementY:= 1;
   184 end;
   184 end;
   185 
   185 
   186 procedure chCurD_m(var s: shortstring);
   186 procedure chCurD_m(var s: shortstring);
   187 begin
   187 begin
   188 s:= s; // avoid compiler hint
   188 s:=s; // avoid compiler hint
   189 CursorMovementY:= 0;
   189 CursorMovementY:= 0;
   190 end;
   190 end;
   191 
   191 
   192 procedure chCurL_p(var s: shortstring);
   192 procedure chCurL_p(var s: shortstring);
   193 begin
   193 begin
   194 s:= s; // avoid compiler hint
   194 s:=s; // avoid compiler hint
   195 CursorMovementX:= -1;
   195 CursorMovementX:= -1;
   196 end;
   196 end;
   197 
   197 
   198 procedure chCurL_m(var s: shortstring);
   198 procedure chCurL_m(var s: shortstring);
   199 begin
   199 begin
   200 s:= s; // avoid compiler hint
   200 s:=s; // avoid compiler hint
   201 CursorMovementX:= 0;
   201 CursorMovementX:= 0;
   202 end;
   202 end;
   203 
   203 
   204 procedure chCurR_p(var s: shortstring);
   204 procedure chCurR_p(var s: shortstring);
   205 begin
   205 begin
   206 s:= s; // avoid compiler hint
   206 s:=s; // avoid compiler hint
   207 CursorMovementX:= 1;
   207 CursorMovementX:= 1;
   208 end;
   208 end;
   209 
   209 
   210 procedure chCurR_m(var s: shortstring);
   210 procedure chCurR_m(var s: shortstring);
   211 begin
   211 begin
   212 s:= s; // avoid compiler hint
   212 s:=s; // avoid compiler hint
   213 CursorMovementX:= 0;
   213 CursorMovementX:= 0;
   214 end;
   214 end;
   215 
   215 
   216 procedure chLeft_p(var s: shortstring);
   216 procedure chLeft_p(var s: shortstring);
   217 begin
   217 begin
   218 s:= s; // avoid compiler hint
   218 s:=s; // avoid compiler hint
   219 if CheckNoTeamOrHH or isPaused then
   219 if CheckNoTeamOrHH or isPaused then
   220     exit;
   220     exit;
   221 if not isExternalSource then
   221 if not isExternalSource then
   222     SendIPC(_S'L');
   222     SendIPC(_S'L');
   223 bShowFinger:= false;
   223 bShowFinger:= false;
   226     ScriptCall('onLeft');
   226     ScriptCall('onLeft');
   227 end;
   227 end;
   228 
   228 
   229 procedure chLeft_m(var s: shortstring);
   229 procedure chLeft_m(var s: shortstring);
   230 begin
   230 begin
   231 s:= s; // avoid compiler hint
   231 s:=s; // avoid compiler hint
   232 if CheckNoTeamOrHH then
   232 if CheckNoTeamOrHH then
   233     exit;
   233     exit;
   234 if not isExternalSource then
   234 if not isExternalSource then
   235     SendIPC(_S'l');
   235     SendIPC(_S'l');
   236 with CurrentHedgehog^.Gear^ do
   236 with CurrentHedgehog^.Gear^ do
   238     ScriptCall('onLeftUp');
   238     ScriptCall('onLeftUp');
   239 end;
   239 end;
   240 
   240 
   241 procedure chRight_p(var s: shortstring);
   241 procedure chRight_p(var s: shortstring);
   242 begin
   242 begin
   243 s:= s; // avoid compiler hint
   243 s:=s; // avoid compiler hint
   244 if CheckNoTeamOrHH or isPaused then
   244 if CheckNoTeamOrHH or isPaused then
   245     exit;
   245     exit;
   246 if not isExternalSource then
   246 if not isExternalSource then
   247     SendIPC(_S'R');
   247     SendIPC(_S'R');
   248 bShowFinger:= false;
   248 bShowFinger:= false;
   251     ScriptCall('onRight');
   251     ScriptCall('onRight');
   252 end;
   252 end;
   253 
   253 
   254 procedure chRight_m(var s: shortstring);
   254 procedure chRight_m(var s: shortstring);
   255 begin
   255 begin
   256 s:= s; // avoid compiler hint
   256 s:=s; // avoid compiler hint
   257 if CheckNoTeamOrHH then
   257 if CheckNoTeamOrHH then
   258     exit;
   258     exit;
   259 if not isExternalSource then
   259 if not isExternalSource then
   260     SendIPC(_S'r');
   260     SendIPC(_S'r');
   261 with CurrentHedgehog^.Gear^ do
   261 with CurrentHedgehog^.Gear^ do
   263     ScriptCall('onRightUp');
   263     ScriptCall('onRightUp');
   264 end;
   264 end;
   265 
   265 
   266 procedure chUp_p(var s: shortstring);
   266 procedure chUp_p(var s: shortstring);
   267 begin
   267 begin
   268 s:= s; // avoid compiler hint
   268 s:=s; // avoid compiler hint
   269 if CheckNoTeamOrHH or isPaused then
   269 if CheckNoTeamOrHH or isPaused then
   270     exit;
   270     exit;
   271 if not isExternalSource then
   271 if not isExternalSource then
   272     SendIPC(_S'U');
   272     SendIPC(_S'U');
   273 bShowFinger:= false;
   273 bShowFinger:= false;
   276     ScriptCall('onUp');
   276     ScriptCall('onUp');
   277 end;
   277 end;
   278 
   278 
   279 procedure chUp_m(var s: shortstring);
   279 procedure chUp_m(var s: shortstring);
   280 begin
   280 begin
   281 s:= s; // avoid compiler hint
   281 s:=s; // avoid compiler hint
   282 if CheckNoTeamOrHH then
   282 if CheckNoTeamOrHH then
   283     exit;
   283     exit;
   284 if not isExternalSource then
   284 if not isExternalSource then
   285     SendIPC(_S'u');
   285     SendIPC(_S'u');
   286 with CurrentHedgehog^.Gear^ do
   286 with CurrentHedgehog^.Gear^ do
   288     ScriptCall('onUpUp');
   288     ScriptCall('onUpUp');
   289 end;
   289 end;
   290 
   290 
   291 procedure chDown_p(var s: shortstring);
   291 procedure chDown_p(var s: shortstring);
   292 begin
   292 begin
   293 s:= s; // avoid compiler hint
   293 s:=s; // avoid compiler hint
   294 if CheckNoTeamOrHH or isPaused then
   294 if CheckNoTeamOrHH or isPaused then
   295     exit;
   295     exit;
   296 if not isExternalSource then
   296 if not isExternalSource then
   297     SendIPC(_S'D');
   297     SendIPC(_S'D');
   298 bShowFinger:= false;
   298 bShowFinger:= false;
   301     ScriptCall('onDown');
   301     ScriptCall('onDown');
   302 end;
   302 end;
   303 
   303 
   304 procedure chDown_m(var s: shortstring);
   304 procedure chDown_m(var s: shortstring);
   305 begin
   305 begin
   306 s:= s; // avoid compiler hint
   306 s:=s; // avoid compiler hint
   307 if CheckNoTeamOrHH then
   307 if CheckNoTeamOrHH then
   308     exit;
   308     exit;
   309 if not isExternalSource then
   309 if not isExternalSource then
   310     SendIPC(_S'd');
   310     SendIPC(_S'd');
   311 with CurrentHedgehog^.Gear^ do
   311 with CurrentHedgehog^.Gear^ do
   313     ScriptCall('onDownUp');
   313     ScriptCall('onDownUp');
   314 end;
   314 end;
   315 
   315 
   316 procedure chPrecise_p(var s: shortstring);
   316 procedure chPrecise_p(var s: shortstring);
   317 begin
   317 begin
   318 s:= s; // avoid compiler hint
   318 s:=s; // avoid compiler hint
   319 if CheckNoTeamOrHH or isPaused then
   319 if CheckNoTeamOrHH or isPaused then
   320     exit;
   320     exit;
   321 if not isExternalSource then
   321 if not isExternalSource then
   322     SendIPC(_S'Z');
   322     SendIPC(_S'Z');
   323 bShowFinger:= false;
   323 bShowFinger:= false;
   326     ScriptCall('onPrecise');
   326     ScriptCall('onPrecise');
   327 end;
   327 end;
   328 
   328 
   329 procedure chPrecise_m(var s: shortstring);
   329 procedure chPrecise_m(var s: shortstring);
   330 begin
   330 begin
   331 s:= s; // avoid compiler hint
   331 s:=s; // avoid compiler hint
   332 if CheckNoTeamOrHH then
   332 if CheckNoTeamOrHH then
   333     exit;
   333     exit;
   334 if not isExternalSource then
   334 if not isExternalSource then
   335     SendIPC(_S'z');
   335     SendIPC(_S'z');
   336 with CurrentHedgehog^.Gear^ do
   336 with CurrentHedgehog^.Gear^ do
   338     ScriptCall('onPreciseUp');
   338     ScriptCall('onPreciseUp');
   339 end;
   339 end;
   340 
   340 
   341 procedure chLJump(var s: shortstring);
   341 procedure chLJump(var s: shortstring);
   342 begin
   342 begin
   343 s:= s; // avoid compiler hint
   343 s:=s; // avoid compiler hint
   344 if CheckNoTeamOrHH or isPaused then
   344 if CheckNoTeamOrHH or isPaused then
   345     exit;
   345     exit;
   346 if not isExternalSource then
   346 if not isExternalSource then
   347     SendIPC(_S'j');
   347     SendIPC(_S'j');
   348 bShowFinger:= false;
   348 bShowFinger:= false;
   351     ScriptCall('onLJump');
   351     ScriptCall('onLJump');
   352 end;
   352 end;
   353 
   353 
   354 procedure chHJump(var s: shortstring);
   354 procedure chHJump(var s: shortstring);
   355 begin
   355 begin
   356 s:= s; // avoid compiler hint
   356 s:=s; // avoid compiler hint
   357 if CheckNoTeamOrHH or isPaused then
   357 if CheckNoTeamOrHH or isPaused then
   358     exit;
   358     exit;
   359 if not isExternalSource then
   359 if not isExternalSource then
   360     SendIPC(_S'J');
   360     SendIPC(_S'J');
   361 bShowFinger:= false;
   361 bShowFinger:= false;
   364     ScriptCall('onHJump');
   364     ScriptCall('onHJump');
   365 end;
   365 end;
   366 
   366 
   367 procedure chAttack_p(var s: shortstring);
   367 procedure chAttack_p(var s: shortstring);
   368 begin
   368 begin
   369 s:= s; // avoid compiler hint
   369 s:=s; // avoid compiler hint
   370 if CheckNoTeamOrHH or isPaused then
   370 if CheckNoTeamOrHH or isPaused then
   371     exit;
   371     exit;
   372 bShowFinger:= false;
   372 bShowFinger:= false;
   373 with CurrentHedgehog^.Gear^ do
   373 with CurrentHedgehog^.Gear^ do
   374     begin
   374     begin
   384     end
   384     end
   385 end;
   385 end;
   386 
   386 
   387 procedure chAttack_m(var s: shortstring);
   387 procedure chAttack_m(var s: shortstring);
   388 begin
   388 begin
   389 s:= s; // avoid compiler hint
   389 s:=s; // avoid compiler hint
   390 if CheckNoTeamOrHH then
   390 if CheckNoTeamOrHH then
   391     exit;
   391     exit;
   392 with CurrentHedgehog^.Gear^ do
   392 with CurrentHedgehog^.Gear^ do
   393     begin
   393     begin
   394     if not isExternalSource and
   394     if not isExternalSource and
   399     end
   399     end
   400 end;
   400 end;
   401 
   401 
   402 procedure chSwitch(var s: shortstring);
   402 procedure chSwitch(var s: shortstring);
   403 begin
   403 begin
   404 s:= s; // avoid compiler hint
   404 s:=s; // avoid compiler hint
   405 if CheckNoTeamOrHH or isPaused then
   405 if CheckNoTeamOrHH or isPaused then
   406     exit;
   406     exit;
   407 if not isExternalSource then
   407 if not isExternalSource then
   408     SendIPC(_S'S');
   408     SendIPC(_S'S');
   409 bShowFinger:= false;
   409 bShowFinger:= false;
   411     Message:= Message or (gmSwitch and InputMask);
   411     Message:= Message or (gmSwitch and InputMask);
   412     ScriptCall('onSwitch');
   412     ScriptCall('onSwitch');
   413 end;
   413 end;
   414 
   414 
   415 procedure chNextTurn(var s: shortstring);
   415 procedure chNextTurn(var s: shortstring);
   416 var gi: PGear;
   416 var i  : Longword;
   417 begin
   417     gi : PGear;
   418     s:= s; // avoid compiler hint
   418 begin
       
   419     s:=s; // avoid compiler hint
   419 
   420 
   420     TryDo(AllInactive, '/nextturn called when not all gears are inactive', true);
   421     TryDo(AllInactive, '/nextturn called when not all gears are inactive', true);
   421 
   422 
   422     CheckSum:= CheckSum xor GameTicks;
   423     CheckSum:= CheckSum xor GameTicks;
   423     gi := GearsList;
   424     gi := GearsList;
   520     end
   521     end
   521 end;
   522 end;
   522 
   523 
   523 procedure chPut(var s: shortstring);
   524 procedure chPut(var s: shortstring);
   524 begin
   525 begin
   525     s:= s; // avoid compiler hint
   526     s:=s; // avoid compiler hint
   526     doPut(0, 0, false);
   527     doPut(0, 0, false);
   527 end;
   528 end;
   528 
   529 
   529 procedure chCapture(var s: shortstring);
   530 procedure chCapture(var s: shortstring);
   530 begin
   531 begin
   531 s:= s; // avoid compiler hint
   532 s:=s; // avoid compiler hint
   532 flagMakeCapture:= true
   533 flagMakeCapture:= true
   533 end;
   534 end;
   534 
   535 
   535 procedure chRecord(var s: shortstring);
   536 procedure chRecord(var s: shortstring);
   536 begin
   537 begin
   584     end
   585     end
   585     end;
   586     end;
   586 
   587 
   587 procedure chAmmoMenu(var s: shortstring);
   588 procedure chAmmoMenu(var s: shortstring);
   588 begin
   589 begin
   589 s:= s; // avoid compiler hint
   590 s:=s; // avoid compiler hint
   590 if CheckNoTeamOrHH then
   591 if CheckNoTeamOrHH then
   591     bShowAmmoMenu:= true
   592     bShowAmmoMenu:= true
   592 else
   593 else
   593     begin
   594     begin
   594     with CurrentTeam^ do
   595     with CurrentTeam^ do
   609     end
   610     end
   610 end;
   611 end;
   611 
   612 
   612 procedure chVol_p(var s: shortstring);
   613 procedure chVol_p(var s: shortstring);
   613 begin
   614 begin
   614 s:= s; // avoid compiler hint
   615 s:=s; // avoid compiler hint
   615 inc(cVolumeDelta, 3)
   616 inc(cVolumeDelta, 3)
   616 end;
   617 end;
   617 
   618 
   618 procedure chVol_m(var s: shortstring);
   619 procedure chVol_m(var s: shortstring);
   619 begin
   620 begin
   620 s:= s; // avoid compiler hint
   621 s:=s; // avoid compiler hint
   621 dec(cVolumeDelta, 3)
   622 dec(cVolumeDelta, 3)
   622 end;
   623 end;
   623 
   624 
   624 procedure chFindhh(var s: shortstring);
   625 procedure chFindhh(var s: shortstring);
   625 begin
   626 begin
   626 s:= s; // avoid compiler hint
   627 s:=s; // avoid compiler hint
   627 if CheckNoTeamOrHH or isPaused then
   628 if CheckNoTeamOrHH or isPaused then
   628     exit;
   629     exit;
   629 
   630 
   630 if autoCameraOn then
   631 if autoCameraOn then
   631     begin
   632     begin
   643     end
   644     end
   644 end;
   645 end;
   645 
   646 
   646 procedure chPause(var s: shortstring);
   647 procedure chPause(var s: shortstring);
   647 begin
   648 begin
   648 s:= s; // avoid compiler hint
   649 s:=s; // avoid compiler hint
   649 if gameType <> gmtNet then
   650 if gameType <> gmtNet then
   650     isPaused:= not isPaused;
   651     isPaused:= not isPaused;
   651 
   652 
   652 if isPaused then
   653 if isPaused then
   653     SDL_ShowCursor(1)
   654     SDL_ShowCursor(1)
   655     SDL_ShowCursor(ord(GameState = gsConfirm))
   656     SDL_ShowCursor(ord(GameState = gsConfirm))
   656 end;
   657 end;
   657 
   658 
   658 procedure chRotateMask(var s: shortstring);
   659 procedure chRotateMask(var s: shortstring);
   659 begin
   660 begin
   660 s:= s; // avoid compiler hint
   661 s:=s; // avoid compiler hint
   661 if ((GameFlags and gfInvulnerable) = 0) then
   662 if ((GameFlags and gfInvulnerable) = 0) then
   662     cTagsMask:= cTagsMasks[cTagsMask]
   663     cTagsMask:= cTagsMasks[cTagsMask]
   663 else
   664 else
   664     cTagsMask:= cTagsMasksNoHealth[cTagsMask];
   665     cTagsMask:= cTagsMasksNoHealth[cTagsMask];
   665 end;
   666 end;
   666 
   667 
   667 procedure chSpeedup_p(var s: shortstring);
   668 procedure chSpeedup_p(var s: shortstring);
   668 begin
   669 begin
   669 s:= s; // avoid compiler hint
   670 s:=s; // avoid compiler hint
   670 SpeedStart:= RealTicks;
   671 SpeedStart:= RealTicks;
   671 isSpeed:= true
   672 isSpeed:= true
   672 end;
   673 end;
   673 
   674 
   674 procedure chSpeedup_m(var s: shortstring);
   675 procedure chSpeedup_m(var s: shortstring);
   675 begin
   676 begin
   676 s:= s; // avoid compiler hint
   677 s:=s; // avoid compiler hint
   677 isSpeed:= false
   678 isSpeed:= false
   678 end;
   679 end;
   679 
   680 
   680 procedure chZoomIn(var s: shortstring);
   681 procedure chZoomIn(var s: shortstring);
   681 begin
   682 begin
   682     s:= s; // avoid compiler hint
   683     s:=s; // avoid compiler hint
   683     if ZoomValue < cMinZoomLevel then
   684     if ZoomValue < cMinZoomLevel then
   684         ZoomValue:= ZoomValue + cZoomDelta;
   685         ZoomValue:= ZoomValue + cZoomDelta;
   685 end;
   686 end;
   686 
   687 
   687 procedure chZoomOut(var s: shortstring);
   688 procedure chZoomOut(var s: shortstring);
   688 begin
   689 begin
   689     s:= s; // avoid compiler hint
   690     s:=s; // avoid compiler hint
   690     if ZoomValue > cMaxZoomLevel then
   691     if ZoomValue > cMaxZoomLevel then
   691         ZoomValue:= ZoomValue - cZoomDelta;
   692         ZoomValue:= ZoomValue - cZoomDelta;
   692 end;
   693 end;
   693 
   694 
   694 procedure chZoomReset(var s: shortstring);
   695 procedure chZoomReset(var s: shortstring);
   695 begin
   696 begin
   696     s:= s; // avoid compiler hint
   697     s:=s; // avoid compiler hint
   697     ZoomValue:= cDefaultZoomLevel;
   698     ZoomValue:= cDefaultZoomLevel;
   698 end;
   699 end;
   699 
   700 
   700 procedure chMapGen(var s: shortstring);
   701 procedure chMapGen(var s: shortstring);
   701 begin
   702 begin