hedgewars/uCommandHandlers.pas
changeset 7068 b1b7eb9c8cc9
parent 7058 56596f3531d9
child 7103 1c1afb5a1565
equal deleted inserted replaced
7067:f98ec3aecf4e 7068:b1b7eb9c8cc9
    69 procedure chConfirm(var s: shortstring);
    69 procedure chConfirm(var s: shortstring);
    70 begin
    70 begin
    71     s:= s; // avoid compiler hint
    71     s:= s; // avoid compiler hint
    72     if GameState = gsConfirm then
    72     if GameState = gsConfirm then
    73     begin
    73     begin
    74         SendIPCc('Q');
    74         SendIPC(_S'Q');
    75         GameState:= gsExit
    75         GameState:= gsExit
    76     end
    76     end
    77 else
    77 else
    78     ParseCommand('chat team', true);
    78     ParseCommand('chat team', true);
    79 end;
    79 end;
    80 
    80 
    81 procedure chHalt (var s: shortstring);
    81 procedure chHalt (var s: shortstring);
    82 begin
    82 begin
    83     s:= s; // avoid compiler hint
    83     s:= s; // avoid compiler hint
    84     SendIPCc('H');
    84     SendIPC(_S'H');
    85     GameState:= gsExit
    85     GameState:= gsExit
    86 end;
    86 end;
    87 
    87 
    88 procedure chCheckProto(var s: shortstring);
    88 procedure chCheckProto(var s: shortstring);
    89 var i: LongInt;
    89 var i: LongInt;
   216 begin
   216 begin
   217 s:= s; // avoid compiler hint
   217 s:= s; // avoid compiler hint
   218 if CheckNoTeamOrHH or isPaused then
   218 if CheckNoTeamOrHH or isPaused then
   219     exit;
   219     exit;
   220 if not CurrentTeam^.ExtDriven then
   220 if not CurrentTeam^.ExtDriven then
   221     SendIPCc('L');
   221     SendIPC(_S'L');
   222 bShowFinger:= false;
   222 bShowFinger:= false;
   223 with CurrentHedgehog^.Gear^ do
   223 with CurrentHedgehog^.Gear^ do
   224     Message:= Message or (gmLeft and InputMask);
   224     Message:= Message or (gmLeft and InputMask);
   225     ScriptCall('onLeft');
   225     ScriptCall('onLeft');
   226 end;
   226 end;
   229 begin
   229 begin
   230 s:= s; // avoid compiler hint
   230 s:= s; // avoid compiler hint
   231 if CheckNoTeamOrHH then
   231 if CheckNoTeamOrHH then
   232     exit;
   232     exit;
   233 if not CurrentTeam^.ExtDriven then
   233 if not CurrentTeam^.ExtDriven then
   234     SendIPCc('l');
   234     SendIPC(_S'l');
   235 with CurrentHedgehog^.Gear^ do
   235 with CurrentHedgehog^.Gear^ do
   236     Message:= Message and (not (gmLeft and InputMask));
   236     Message:= Message and (not (gmLeft and InputMask));
   237     ScriptCall('onLeftUp');
   237     ScriptCall('onLeftUp');
   238 end;
   238 end;
   239 
   239 
   241 begin
   241 begin
   242 s:= s; // avoid compiler hint
   242 s:= s; // avoid compiler hint
   243 if CheckNoTeamOrHH or isPaused then
   243 if CheckNoTeamOrHH or isPaused then
   244     exit;
   244     exit;
   245 if not CurrentTeam^.ExtDriven then
   245 if not CurrentTeam^.ExtDriven then
   246     SendIPCc('R');
   246     SendIPC(_S'R');
   247 bShowFinger:= false;
   247 bShowFinger:= false;
   248 with CurrentHedgehog^.Gear^ do
   248 with CurrentHedgehog^.Gear^ do
   249     Message:= Message or (gmRight and InputMask);
   249     Message:= Message or (gmRight and InputMask);
   250     ScriptCall('onRight');
   250     ScriptCall('onRight');
   251 end;
   251 end;
   254 begin
   254 begin
   255 s:= s; // avoid compiler hint
   255 s:= s; // avoid compiler hint
   256 if CheckNoTeamOrHH then
   256 if CheckNoTeamOrHH then
   257     exit;
   257     exit;
   258 if not CurrentTeam^.ExtDriven then
   258 if not CurrentTeam^.ExtDriven then
   259     SendIPCc('r');
   259     SendIPC(_S'r');
   260 with CurrentHedgehog^.Gear^ do
   260 with CurrentHedgehog^.Gear^ do
   261     Message:= Message and (not (gmRight and InputMask));
   261     Message:= Message and (not (gmRight and InputMask));
   262     ScriptCall('onRightUp');
   262     ScriptCall('onRightUp');
   263 end;
   263 end;
   264 
   264 
   266 begin
   266 begin
   267 s:= s; // avoid compiler hint
   267 s:= s; // avoid compiler hint
   268 if CheckNoTeamOrHH or isPaused then
   268 if CheckNoTeamOrHH or isPaused then
   269     exit;
   269     exit;
   270 if not CurrentTeam^.ExtDriven then
   270 if not CurrentTeam^.ExtDriven then
   271     SendIPCc('U');
   271     SendIPC(_S'U');
   272 bShowFinger:= false;
   272 bShowFinger:= false;
   273 with CurrentHedgehog^.Gear^ do
   273 with CurrentHedgehog^.Gear^ do
   274     Message:= Message or (gmUp and InputMask);
   274     Message:= Message or (gmUp and InputMask);
   275     ScriptCall('onUp');
   275     ScriptCall('onUp');
   276 end;
   276 end;
   279 begin
   279 begin
   280 s:= s; // avoid compiler hint
   280 s:= s; // avoid compiler hint
   281 if CheckNoTeamOrHH then
   281 if CheckNoTeamOrHH then
   282     exit;
   282     exit;
   283 if not CurrentTeam^.ExtDriven then
   283 if not CurrentTeam^.ExtDriven then
   284     SendIPCc('u');
   284     SendIPC(_S'u');
   285 with CurrentHedgehog^.Gear^ do
   285 with CurrentHedgehog^.Gear^ do
   286     Message:= Message and (not (gmUp and InputMask));
   286     Message:= Message and (not (gmUp and InputMask));
   287     ScriptCall('onUpUp');
   287     ScriptCall('onUpUp');
   288 end;
   288 end;
   289 
   289 
   291 begin
   291 begin
   292 s:= s; // avoid compiler hint
   292 s:= s; // avoid compiler hint
   293 if CheckNoTeamOrHH or isPaused then
   293 if CheckNoTeamOrHH or isPaused then
   294     exit;
   294     exit;
   295 if not CurrentTeam^.ExtDriven then
   295 if not CurrentTeam^.ExtDriven then
   296     SendIPCc('D');
   296     SendIPC(_S'D');
   297 bShowFinger:= false;
   297 bShowFinger:= false;
   298 with CurrentHedgehog^.Gear^ do
   298 with CurrentHedgehog^.Gear^ do
   299     Message:= Message or (gmDown and InputMask);
   299     Message:= Message or (gmDown and InputMask);
   300     ScriptCall('onDown');
   300     ScriptCall('onDown');
   301 end;
   301 end;
   304 begin
   304 begin
   305 s:= s; // avoid compiler hint
   305 s:= s; // avoid compiler hint
   306 if CheckNoTeamOrHH then
   306 if CheckNoTeamOrHH then
   307     exit;
   307     exit;
   308 if not CurrentTeam^.ExtDriven then
   308 if not CurrentTeam^.ExtDriven then
   309     SendIPCc('d');
   309     SendIPC(_S'd');
   310 with CurrentHedgehog^.Gear^ do
   310 with CurrentHedgehog^.Gear^ do
   311     Message:= Message and (not (gmDown and InputMask));
   311     Message:= Message and (not (gmDown and InputMask));
   312     ScriptCall('onDownUp');
   312     ScriptCall('onDownUp');
   313 end;
   313 end;
   314 
   314 
   316 begin
   316 begin
   317 s:= s; // avoid compiler hint
   317 s:= s; // avoid compiler hint
   318 if CheckNoTeamOrHH or isPaused then
   318 if CheckNoTeamOrHH or isPaused then
   319     exit;
   319     exit;
   320 if not CurrentTeam^.ExtDriven then
   320 if not CurrentTeam^.ExtDriven then
   321     SendIPCc('Z');
   321     SendIPC(_S'Z');
   322 bShowFinger:= false;
   322 bShowFinger:= false;
   323 with CurrentHedgehog^.Gear^ do
   323 with CurrentHedgehog^.Gear^ do
   324     Message:= Message or (gmPrecise and InputMask);
   324     Message:= Message or (gmPrecise and InputMask);
   325     ScriptCall('onPrecise');
   325     ScriptCall('onPrecise');
   326 end;
   326 end;
   329 begin
   329 begin
   330 s:= s; // avoid compiler hint
   330 s:= s; // avoid compiler hint
   331 if CheckNoTeamOrHH then
   331 if CheckNoTeamOrHH then
   332     exit;
   332     exit;
   333 if not CurrentTeam^.ExtDriven then
   333 if not CurrentTeam^.ExtDriven then
   334     SendIPCc('z');
   334     SendIPC(_S'z');
   335 with CurrentHedgehog^.Gear^ do
   335 with CurrentHedgehog^.Gear^ do
   336     Message:= Message and (not (gmPrecise and InputMask));
   336     Message:= Message and (not (gmPrecise and InputMask));
   337     ScriptCall('onPreciseUp');
   337     ScriptCall('onPreciseUp');
   338 end;
   338 end;
   339 
   339 
   341 begin
   341 begin
   342 s:= s; // avoid compiler hint
   342 s:= s; // avoid compiler hint
   343 if CheckNoTeamOrHH or isPaused then
   343 if CheckNoTeamOrHH or isPaused then
   344     exit;
   344     exit;
   345 if not CurrentTeam^.ExtDriven then
   345 if not CurrentTeam^.ExtDriven then
   346     SendIPCc('j');
   346     SendIPC(_S'j');
   347 bShowFinger:= false;
   347 bShowFinger:= false;
   348 with CurrentHedgehog^.Gear^ do
   348 with CurrentHedgehog^.Gear^ do
   349     Message:= Message or (gmLJump and InputMask);
   349     Message:= Message or (gmLJump and InputMask);
   350     ScriptCall('onLJump');
   350     ScriptCall('onLJump');
   351 end;
   351 end;
   354 begin
   354 begin
   355 s:= s; // avoid compiler hint
   355 s:= s; // avoid compiler hint
   356 if CheckNoTeamOrHH or isPaused then
   356 if CheckNoTeamOrHH or isPaused then
   357     exit;
   357     exit;
   358 if not CurrentTeam^.ExtDriven then
   358 if not CurrentTeam^.ExtDriven then
   359     SendIPCc('J');
   359     SendIPC(_S'J');
   360 bShowFinger:= false;
   360 bShowFinger:= false;
   361 with CurrentHedgehog^.Gear^ do
   361 with CurrentHedgehog^.Gear^ do
   362     Message:= Message or (gmHJump and InputMask);
   362     Message:= Message or (gmHJump and InputMask);
   363     ScriptCall('onHJump');
   363     ScriptCall('onHJump');
   364 end;
   364 end;
   374     AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State));
   374     AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State));
   375     if ((State and gstHHDriven) <> 0) then
   375     if ((State and gstHHDriven) <> 0) then
   376         begin
   376         begin
   377         FollowGear:= CurrentHedgehog^.Gear;
   377         FollowGear:= CurrentHedgehog^.Gear;
   378         if not CurrentTeam^.ExtDriven then
   378         if not CurrentTeam^.ExtDriven then
   379             SendIPCc('A');
   379             SendIPC(_S'A');
   380         Message:= Message or (gmAttack and InputMask);
   380         Message:= Message or (gmAttack and InputMask);
   381         ScriptCall('onAttack');
   381         ScriptCall('onAttack');
   382         end
   382         end
   383     end
   383     end
   384 end;
   384 end;
   390     exit;
   390     exit;
   391 with CurrentHedgehog^.Gear^ do
   391 with CurrentHedgehog^.Gear^ do
   392     begin
   392     begin
   393     if not CurrentTeam^.ExtDriven and
   393     if not CurrentTeam^.ExtDriven and
   394         ((Message and gmAttack) <> 0) then
   394         ((Message and gmAttack) <> 0) then
   395             SendIPCc('a');
   395             SendIPC(_S'a');
   396     Message:= Message and (not (gmAttack and InputMask));
   396     Message:= Message and (not (gmAttack and InputMask));
   397     ScriptCall('onAttackUp');
   397     ScriptCall('onAttackUp');
   398     end
   398     end
   399 end;
   399 end;
   400 
   400 
   402 begin
   402 begin
   403 s:= s; // avoid compiler hint
   403 s:= s; // avoid compiler hint
   404 if CheckNoTeamOrHH or isPaused then
   404 if CheckNoTeamOrHH or isPaused then
   405     exit;
   405     exit;
   406 if not CurrentTeam^.ExtDriven then
   406 if not CurrentTeam^.ExtDriven then
   407     SendIPCc('S');
   407     SendIPC(_S'S');
   408 bShowFinger:= false;
   408 bShowFinger:= false;
   409 with CurrentHedgehog^.Gear^ do
   409 with CurrentHedgehog^.Gear^ do
   410     Message:= Message or (gmSwitch and InputMask);
   410     Message:= Message or (gmSwitch and InputMask);
   411     ScriptCall('onSwitch');
   411     ScriptCall('onSwitch');
   412 end;
   412 end;
   415 begin
   415 begin
   416     s:= s; // avoid compiler hint
   416     s:= s; // avoid compiler hint
   417     TryDo(AllInactive, '/nextturn called when not all gears are inactive', true);
   417     TryDo(AllInactive, '/nextturn called when not all gears are inactive', true);
   418 
   418 
   419     if not CurrentTeam^.ExtDriven then
   419     if not CurrentTeam^.ExtDriven then
   420         SendIPCc('N');
   420         SendIPC(_S'N');
   421     AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));
   421     AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));
   422 end;
   422 end;
   423 
   423 
   424 procedure chTimer(var s: shortstring);
   424 procedure chTimer(var s: shortstring);
   425 begin
   425 begin
   437     end
   437     end
   438 end;
   438 end;
   439 
   439 
   440 procedure chSlot(var s: shortstring);
   440 procedure chSlot(var s: shortstring);
   441 var slot: LongWord;
   441 var slot: LongWord;
       
   442     ss: shortstring;
   442 begin
   443 begin
   443 if (s[0] <> #1) or CheckNoTeamOrHH then
   444 if (s[0] <> #1) or CheckNoTeamOrHH then
   444     exit;
   445     exit;
   445 slot:= byte(s[1]) - 49;
   446 slot:= byte(s[1]) - 49;
   446 if slot > cMaxSlotIndex then
   447 if slot > cMaxSlotIndex then
   447     exit;
   448     exit;
   448 if not CurrentTeam^.ExtDriven then
   449 if not CurrentTeam^.ExtDriven then
   449     SendIPCc(char(byte(s[1]) + 79));
   450     begin
       
   451     ss[0]:= #1;
       
   452     ss[1]:= char(byte(s[1]) + 79);
       
   453     SendIPC(ss);
       
   454     end;
   450 bShowFinger:= false;
   455 bShowFinger:= false;
   451 with CurrentHedgehog^.Gear^ do
   456 with CurrentHedgehog^.Gear^ do
   452     begin
   457     begin
   453     Message:= Message or (gmSlot and InputMask);
   458     Message:= Message or (gmSlot and InputMask);
   454     MsgParam:= slot; 
   459     MsgParam:= slot;