hedgewars/uCommandHandlers.pas
changeset 7805 2a249a4faf5b
parent 7790 040fc517fece
child 7829 c1dc7839d7b9
equal deleted inserted replaced
7804:9122461ae32b 7805:2a249a4faf5b
    35 begin
    35 begin
    36 case s[1] of
    36 case s[1] of
    37     'R': if ReadyTimeLeft > 1 then 
    37     'R': if ReadyTimeLeft > 1 then 
    38         begin
    38         begin
    39         ReadyTimeLeft:= 1;
    39         ReadyTimeLeft:= 1;
    40         if not CurrentTeam^.ExtDriven then
    40         if not isExternalSource then
    41             SendIPC('c'+s);
    41             SendIPC('c'+s);
    42         end
    42         end
    43     end
    43     end
    44 end;
    44 end;
    45 
    45 
   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 CurrentTeam^.ExtDriven then
   221 if not isExternalSource then
   222     SendIPC(_S'L');
   222     SendIPC(_S'L');
   223 bShowFinger:= false;
   223 bShowFinger:= false;
   224 with CurrentHedgehog^.Gear^ do
   224 with CurrentHedgehog^.Gear^ do
   225     Message:= Message or (gmLeft and InputMask);
   225     Message:= Message or (gmLeft and InputMask);
   226     ScriptCall('onLeft');
   226     ScriptCall('onLeft');
   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 CurrentTeam^.ExtDriven then
   234 if not isExternalSource then
   235     SendIPC(_S'l');
   235     SendIPC(_S'l');
   236 with CurrentHedgehog^.Gear^ do
   236 with CurrentHedgehog^.Gear^ do
   237     Message:= Message and (not (gmLeft and InputMask));
   237     Message:= Message and (not (gmLeft and InputMask));
   238     ScriptCall('onLeftUp');
   238     ScriptCall('onLeftUp');
   239 end;
   239 end;
   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 CurrentTeam^.ExtDriven then
   246 if not isExternalSource then
   247     SendIPC(_S'R');
   247     SendIPC(_S'R');
   248 bShowFinger:= false;
   248 bShowFinger:= false;
   249 with CurrentHedgehog^.Gear^ do
   249 with CurrentHedgehog^.Gear^ do
   250     Message:= Message or (gmRight and InputMask);
   250     Message:= Message or (gmRight and InputMask);
   251     ScriptCall('onRight');
   251     ScriptCall('onRight');
   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 CurrentTeam^.ExtDriven then
   259 if not isExternalSource then
   260     SendIPC(_S'r');
   260     SendIPC(_S'r');
   261 with CurrentHedgehog^.Gear^ do
   261 with CurrentHedgehog^.Gear^ do
   262     Message:= Message and (not (gmRight and InputMask));
   262     Message:= Message and (not (gmRight and InputMask));
   263     ScriptCall('onRightUp');
   263     ScriptCall('onRightUp');
   264 end;
   264 end;
   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 CurrentTeam^.ExtDriven then
   271 if not isExternalSource then
   272     SendIPC(_S'U');
   272     SendIPC(_S'U');
   273 bShowFinger:= false;
   273 bShowFinger:= false;
   274 with CurrentHedgehog^.Gear^ do
   274 with CurrentHedgehog^.Gear^ do
   275     Message:= Message or (gmUp and InputMask);
   275     Message:= Message or (gmUp and InputMask);
   276     ScriptCall('onUp');
   276     ScriptCall('onUp');
   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 CurrentTeam^.ExtDriven then
   284 if not isExternalSource then
   285     SendIPC(_S'u');
   285     SendIPC(_S'u');
   286 with CurrentHedgehog^.Gear^ do
   286 with CurrentHedgehog^.Gear^ do
   287     Message:= Message and (not (gmUp and InputMask));
   287     Message:= Message and (not (gmUp and InputMask));
   288     ScriptCall('onUpUp');
   288     ScriptCall('onUpUp');
   289 end;
   289 end;
   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 CurrentTeam^.ExtDriven then
   296 if not isExternalSource then
   297     SendIPC(_S'D');
   297     SendIPC(_S'D');
   298 bShowFinger:= false;
   298 bShowFinger:= false;
   299 with CurrentHedgehog^.Gear^ do
   299 with CurrentHedgehog^.Gear^ do
   300     Message:= Message or (gmDown and InputMask);
   300     Message:= Message or (gmDown and InputMask);
   301     ScriptCall('onDown');
   301     ScriptCall('onDown');
   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 CurrentTeam^.ExtDriven then
   309 if not isExternalSource then
   310     SendIPC(_S'd');
   310     SendIPC(_S'd');
   311 with CurrentHedgehog^.Gear^ do
   311 with CurrentHedgehog^.Gear^ do
   312     Message:= Message and (not (gmDown and InputMask));
   312     Message:= Message and (not (gmDown and InputMask));
   313     ScriptCall('onDownUp');
   313     ScriptCall('onDownUp');
   314 end;
   314 end;
   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 CurrentTeam^.ExtDriven then
   321 if not isExternalSource then
   322     SendIPC(_S'Z');
   322     SendIPC(_S'Z');
   323 bShowFinger:= false;
   323 bShowFinger:= false;
   324 with CurrentHedgehog^.Gear^ do
   324 with CurrentHedgehog^.Gear^ do
   325     Message:= Message or (gmPrecise and InputMask);
   325     Message:= Message or (gmPrecise and InputMask);
   326     ScriptCall('onPrecise');
   326     ScriptCall('onPrecise');
   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 CurrentTeam^.ExtDriven then
   334 if not isExternalSource then
   335     SendIPC(_S'z');
   335     SendIPC(_S'z');
   336 with CurrentHedgehog^.Gear^ do
   336 with CurrentHedgehog^.Gear^ do
   337     Message:= Message and (not (gmPrecise and InputMask));
   337     Message:= Message and (not (gmPrecise and InputMask));
   338     ScriptCall('onPreciseUp');
   338     ScriptCall('onPreciseUp');
   339 end;
   339 end;
   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 CurrentTeam^.ExtDriven then
   346 if not isExternalSource then
   347     SendIPC(_S'j');
   347     SendIPC(_S'j');
   348 bShowFinger:= false;
   348 bShowFinger:= false;
   349 with CurrentHedgehog^.Gear^ do
   349 with CurrentHedgehog^.Gear^ do
   350     Message:= Message or (gmLJump and InputMask);
   350     Message:= Message or (gmLJump and InputMask);
   351     ScriptCall('onLJump');
   351     ScriptCall('onLJump');
   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 CurrentTeam^.ExtDriven then
   359 if not isExternalSource then
   360     SendIPC(_S'J');
   360     SendIPC(_S'J');
   361 bShowFinger:= false;
   361 bShowFinger:= false;
   362 with CurrentHedgehog^.Gear^ do
   362 with CurrentHedgehog^.Gear^ do
   363     Message:= Message or (gmHJump and InputMask);
   363     Message:= Message or (gmHJump and InputMask);
   364     ScriptCall('onHJump');
   364     ScriptCall('onHJump');
   374     begin
   374     begin
   375     AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State));
   375     AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State));
   376     if ((State and gstHHDriven) <> 0) then
   376     if ((State and gstHHDriven) <> 0) then
   377         begin
   377         begin
   378         FollowGear:= CurrentHedgehog^.Gear;
   378         FollowGear:= CurrentHedgehog^.Gear;
   379         if not CurrentTeam^.ExtDriven then
   379         if not isExternalSource then
   380             SendIPC(_S'A');
   380             SendIPC(_S'A');
   381         Message:= Message or (gmAttack and InputMask);
   381         Message:= Message or (gmAttack and InputMask);
   382         ScriptCall('onAttack');
   382         ScriptCall('onAttack');
   383         end
   383         end
   384     end
   384     end
   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 CurrentTeam^.ExtDriven and
   394     if not isExternalSource and
   395         ((Message and gmAttack) <> 0) then
   395         ((Message and gmAttack) <> 0) then
   396             SendIPC(_S'a');
   396             SendIPC(_S'a');
   397     Message:= Message and (not (gmAttack and InputMask));
   397     Message:= Message and (not (gmAttack and InputMask));
   398     ScriptCall('onAttackUp');
   398     ScriptCall('onAttackUp');
   399     end
   399     end
   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 CurrentTeam^.ExtDriven then
   407 if not isExternalSource then
   408     SendIPC(_S'S');
   408     SendIPC(_S'S');
   409 bShowFinger:= false;
   409 bShowFinger:= false;
   410 with CurrentHedgehog^.Gear^ do
   410 with CurrentHedgehog^.Gear^ do
   411     Message:= Message or (gmSwitch and InputMask);
   411     Message:= Message or (gmSwitch and InputMask);
   412     ScriptCall('onSwitch');
   412     ScriptCall('onSwitch');
   426         with gi^ do CheckSum:= CheckSum xor X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac;
   426         with gi^ do CheckSum:= CheckSum xor X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac;
   427         AddRandomness(CheckSum);
   427         AddRandomness(CheckSum);
   428         gi := gi^.NextGear
   428         gi := gi^.NextGear
   429         end;
   429         end;
   430 
   430 
   431     if not CurrentTeam^.ExtDriven then
   431     if not isExternalSource then
   432         begin
   432         begin
   433         s[0]:= #5;
   433         s[0]:= #5;
   434         s[1]:= 'N';
   434         s[1]:= 'N';
   435         SDLNet_Write32(CheckSum, @s[2]);
   435         SDLNet_Write32(CheckSum, @s[2]);
   436         SendIPC(s)
   436         SendIPC(s)
   445 if CheckNoTeamOrHH then
   445 if CheckNoTeamOrHH then
   446     exit;
   446     exit;
   447 
   447 
   448 TryDo((s[0] = #1) and (s[1] >= '1') and (s[1] <= '5'), 'Malformed /timer', true);
   448 TryDo((s[0] = #1) and (s[1] >= '1') and (s[1] <= '5'), 'Malformed /timer', true);
   449 
   449 
   450 if not CurrentTeam^.ExtDriven then
   450 if not isExternalSource then
   451     SendIPC(s);
   451     SendIPC(s);
   452 bShowFinger:= false;
   452 bShowFinger:= false;
   453 with CurrentHedgehog^.Gear^ do
   453 with CurrentHedgehog^.Gear^ do
   454     begin
   454     begin
   455     Message:= Message or (gmTimer and InputMask);
   455     Message:= Message or (gmTimer and InputMask);
   465 if (s[0] <> #1) or CheckNoTeamOrHH then
   465 if (s[0] <> #1) or CheckNoTeamOrHH then
   466     exit;
   466     exit;
   467 slot:= byte(s[1]) - 49;
   467 slot:= byte(s[1]) - 49;
   468 if slot > cMaxSlotIndex then
   468 if slot > cMaxSlotIndex then
   469     exit;
   469     exit;
   470 if not CurrentTeam^.ExtDriven then
   470 if not isExternalSource then
   471     begin
   471     begin
   472     ss[0]:= #1;
   472     ss[0]:= #1;
   473     ss[1]:= char(byte(s[1]) + 79);
   473     ss[1]:= char(byte(s[1]) + 79);
   474     SendIPC(ss);
   474     SendIPC(ss);
   475     end;
   475     end;
   487     if CheckNoTeamOrHH then
   487     if CheckNoTeamOrHH then
   488         exit;
   488         exit;
   489 
   489 
   490     TryDo((s[0] = #1) and (s[1] <= char(High(TAmmoType))), 'Malformed /setweap', true);
   490     TryDo((s[0] = #1) and (s[1] <= char(High(TAmmoType))), 'Malformed /setweap', true);
   491 
   491 
   492     if not CurrentTeam^.ExtDriven then
   492     if not isExternalSource then
   493         SendIPC('w' + s);
   493         SendIPC('w' + s);
   494 
   494 
   495     with CurrentHedgehog^.Gear^ do
   495     with CurrentHedgehog^.Gear^ do
   496         begin
   496         begin
   497         Message:= Message or (gmWeapon and InputMask);
   497         Message:= Message or (gmWeapon and InputMask);
   506     exit;
   506     exit;
   507 
   507 
   508 if TWave(s[1]) > High(TWave) then
   508 if TWave(s[1]) > High(TWave) then
   509     exit;
   509     exit;
   510 
   510 
   511 if not CurrentTeam^.ExtDriven then
   511 if not isExternalSource then
   512     SendIPC('t' + s);
   512     SendIPC('t' + s);
   513 
   513 
   514 with CurrentHedgehog^.Gear^ do
   514 with CurrentHedgehog^.Gear^ do
   515     begin
   515     begin
   516     Message:= Message or (gmAnimate and InputMask);
   516     Message:= Message or (gmAnimate and InputMask);