hedgewars/uCommandHandlers.pas
changeset 4522 0f590eefd531
parent 4437 05192cdbce9b
child 4528 630f4ab0c926
equal deleted inserted replaced
4521:96066d42c3f9 4522:0f590eefd531
   153 if CheckNoTeamOrHH or isPaused then exit;
   153 if CheckNoTeamOrHH or isPaused then exit;
   154 if not CurrentTeam^.ExtDriven then SendIPC('L');
   154 if not CurrentTeam^.ExtDriven then SendIPC('L');
   155 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   155 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   156 bShowFinger:= false;
   156 bShowFinger:= false;
   157 with CurrentHedgehog^.Gear^ do
   157 with CurrentHedgehog^.Gear^ do
   158     Message:= Message or gmLeft
   158     Message:= Message or (gmLeft and InputMask)
   159 end;
   159 end;
   160 
   160 
   161 procedure chLeft_m(var s: shortstring);
   161 procedure chLeft_m(var s: shortstring);
   162 begin
   162 begin
   163 s:= s; // avoid compiler hint
   163 s:= s; // avoid compiler hint
   164 if CheckNoTeamOrHH then exit;
   164 if CheckNoTeamOrHH then exit;
   165 if not CurrentTeam^.ExtDriven then SendIPC('l');
   165 if not CurrentTeam^.ExtDriven then SendIPC('l');
   166 with CurrentHedgehog^.Gear^ do
   166 with CurrentHedgehog^.Gear^ do
   167     Message:= Message and not gmLeft
   167     Message:= Message and not (gmLeft and InputMask)
   168 end;
   168 end;
   169 
   169 
   170 procedure chRight_p(var s: shortstring);
   170 procedure chRight_p(var s: shortstring);
   171 begin
   171 begin
   172 s:= s; // avoid compiler hint
   172 s:= s; // avoid compiler hint
   173 if CheckNoTeamOrHH or isPaused then exit;
   173 if CheckNoTeamOrHH or isPaused then exit;
   174 if not CurrentTeam^.ExtDriven then SendIPC('R');
   174 if not CurrentTeam^.ExtDriven then SendIPC('R');
   175 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   175 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   176 bShowFinger:= false;
   176 bShowFinger:= false;
   177 with CurrentHedgehog^.Gear^ do
   177 with CurrentHedgehog^.Gear^ do
   178     Message:= Message or gmRight
   178     Message:= Message or (gmRight and InputMask)
   179 end;
   179 end;
   180 
   180 
   181 procedure chRight_m(var s: shortstring);
   181 procedure chRight_m(var s: shortstring);
   182 begin
   182 begin
   183 s:= s; // avoid compiler hint
   183 s:= s; // avoid compiler hint
   184 if CheckNoTeamOrHH then exit;
   184 if CheckNoTeamOrHH then exit;
   185 if not CurrentTeam^.ExtDriven then SendIPC('r');
   185 if not CurrentTeam^.ExtDriven then SendIPC('r');
   186 with CurrentHedgehog^.Gear^ do
   186 with CurrentHedgehog^.Gear^ do
   187     Message:= Message and not gmRight
   187     Message:= Message and not (gmRight and InputMask)
   188 end;
   188 end;
   189 
   189 
   190 procedure chUp_p(var s: shortstring);
   190 procedure chUp_p(var s: shortstring);
   191 begin
   191 begin
   192 s:= s; // avoid compiler hint
   192 s:= s; // avoid compiler hint
   193 if CheckNoTeamOrHH or isPaused then exit;
   193 if CheckNoTeamOrHH or isPaused then exit;
   194 if not CurrentTeam^.ExtDriven then SendIPC('U');
   194 if not CurrentTeam^.ExtDriven then SendIPC('U');
   195 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   195 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   196 bShowFinger:= false;
   196 bShowFinger:= false;
   197 with CurrentHedgehog^.Gear^ do
   197 with CurrentHedgehog^.Gear^ do
   198     Message:= Message or gmUp
   198     Message:= Message or (gmUp and InputMask)
   199 end;
   199 end;
   200 
   200 
   201 procedure chUp_m(var s: shortstring);
   201 procedure chUp_m(var s: shortstring);
   202 begin
   202 begin
   203 s:= s; // avoid compiler hint
   203 s:= s; // avoid compiler hint
   204 if CheckNoTeamOrHH then exit;
   204 if CheckNoTeamOrHH then exit;
   205 if not CurrentTeam^.ExtDriven then SendIPC('u');
   205 if not CurrentTeam^.ExtDriven then SendIPC('u');
   206 with CurrentHedgehog^.Gear^ do
   206 with CurrentHedgehog^.Gear^ do
   207     Message:= Message and not gmUp
   207     Message:= Message and not (gmUp and InputMask);
   208 end;
   208 end;
   209 
   209 
   210 procedure chDown_p(var s: shortstring);
   210 procedure chDown_p(var s: shortstring);
   211 begin
   211 begin
   212 s:= s; // avoid compiler hint
   212 s:= s; // avoid compiler hint
   213 if CheckNoTeamOrHH or isPaused then exit;
   213 if CheckNoTeamOrHH or isPaused then exit;
   214 if not CurrentTeam^.ExtDriven then SendIPC('D');
   214 if not CurrentTeam^.ExtDriven then SendIPC('D');
   215 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   215 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   216 bShowFinger:= false;
   216 bShowFinger:= false;
   217 with CurrentHedgehog^.Gear^ do
   217 with CurrentHedgehog^.Gear^ do
   218     Message:= Message or gmDown
   218     Message:= Message or (gmDown and InputMask)
   219 end;
   219 end;
   220 
   220 
   221 procedure chDown_m(var s: shortstring);
   221 procedure chDown_m(var s: shortstring);
   222 begin
   222 begin
   223 s:= s; // avoid compiler hint
   223 s:= s; // avoid compiler hint
   224 if CheckNoTeamOrHH then exit;
   224 if CheckNoTeamOrHH then exit;
   225 if not CurrentTeam^.ExtDriven then SendIPC('d');
   225 if not CurrentTeam^.ExtDriven then SendIPC('d');
   226 with CurrentHedgehog^.Gear^ do
   226 with CurrentHedgehog^.Gear^ do
   227     Message:= Message and not gmDown
   227     Message:= Message and not (gmDown and InputMask)
   228 end;
   228 end;
   229 
   229 
   230 procedure chPrecise_p(var s: shortstring);
   230 procedure chPrecise_p(var s: shortstring);
   231 begin
   231 begin
   232 s:= s; // avoid compiler hint
   232 s:= s; // avoid compiler hint
   233 if CheckNoTeamOrHH or isPaused then exit;
   233 if CheckNoTeamOrHH or isPaused then exit;
   234 if not CurrentTeam^.ExtDriven then SendIPC('Z');
   234 if not CurrentTeam^.ExtDriven then SendIPC('Z');
   235 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   235 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   236 bShowFinger:= false;
   236 bShowFinger:= false;
   237 with CurrentHedgehog^.Gear^ do
   237 with CurrentHedgehog^.Gear^ do
   238     Message:= Message or gmPrecise
   238     Message:= Message or (gmPrecise and InputMask);
   239 end;
   239 end;
   240 
   240 
   241 procedure chPrecise_m(var s: shortstring);
   241 procedure chPrecise_m(var s: shortstring);
   242 begin
   242 begin
   243 s:= s; // avoid compiler hint
   243 s:= s; // avoid compiler hint
   244 if CheckNoTeamOrHH then exit;
   244 if CheckNoTeamOrHH then exit;
   245 if not CurrentTeam^.ExtDriven then SendIPC('z');
   245 if not CurrentTeam^.ExtDriven then SendIPC('z');
   246 with CurrentHedgehog^.Gear^ do
   246 with CurrentHedgehog^.Gear^ do
   247     Message:= Message and not gmPrecise
   247     Message:= Message and not (gmPrecise and InputMask);
   248 end;
   248 end;
   249 
   249 
   250 procedure chLJump(var s: shortstring);
   250 procedure chLJump(var s: shortstring);
   251 begin
   251 begin
   252 s:= s; // avoid compiler hint
   252 s:= s; // avoid compiler hint
   253 if CheckNoTeamOrHH or isPaused then exit;
   253 if CheckNoTeamOrHH or isPaused then exit;
   254 if not CurrentTeam^.ExtDriven then SendIPC('j');
   254 if not CurrentTeam^.ExtDriven then SendIPC('j');
   255 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   255 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   256 bShowFinger:= false;
   256 bShowFinger:= false;
   257 with CurrentHedgehog^.Gear^ do
   257 with CurrentHedgehog^.Gear^ do
   258     Message:= Message or gmLJump
   258     Message:= Message or (gmLJump and InputMask)
   259 end;
   259 end;
   260 
   260 
   261 procedure chHJump(var s: shortstring);
   261 procedure chHJump(var s: shortstring);
   262 begin
   262 begin
   263 s:= s; // avoid compiler hint
   263 s:= s; // avoid compiler hint
   264 if CheckNoTeamOrHH or isPaused then exit;
   264 if CheckNoTeamOrHH or isPaused then exit;
   265 if not CurrentTeam^.ExtDriven then SendIPC('J');
   265 if not CurrentTeam^.ExtDriven then SendIPC('J');
   266 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   266 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   267 bShowFinger:= false;
   267 bShowFinger:= false;
   268 with CurrentHedgehog^.Gear^ do
   268 with CurrentHedgehog^.Gear^ do
   269     Message:= Message or gmHJump
   269     Message:= Message or (gmHJump and InputMask)
   270 end;
   270 end;
   271 
   271 
   272 procedure chAttack_p(var s: shortstring);
   272 procedure chAttack_p(var s: shortstring);
   273 begin
   273 begin
   274 s:= s; // avoid compiler hint
   274 s:= s; // avoid compiler hint
   280     {$IFDEF DEBUGFILE}AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State));{$ENDIF}
   280     {$IFDEF DEBUGFILE}AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State));{$ENDIF}
   281     if ((State and gstHHDriven) <> 0) then
   281     if ((State and gstHHDriven) <> 0) then
   282         begin
   282         begin
   283         FollowGear:= CurrentHedgehog^.Gear;
   283         FollowGear:= CurrentHedgehog^.Gear;
   284         if not CurrentTeam^.ExtDriven then SendIPC('A');
   284         if not CurrentTeam^.ExtDriven then SendIPC('A');
   285         Message:= Message or gmAttack
   285         Message:= Message or (gmAttack and InputMask)
   286         end
   286         end
   287     end
   287     end
   288 end;
   288 end;
   289 
   289 
   290 procedure chAttack_m(var s: shortstring);
   290 procedure chAttack_m(var s: shortstring);
   293 if CheckNoTeamOrHH then exit;
   293 if CheckNoTeamOrHH then exit;
   294 with CurrentHedgehog^.Gear^ do
   294 with CurrentHedgehog^.Gear^ do
   295     begin
   295     begin
   296     if not CurrentTeam^.ExtDriven and
   296     if not CurrentTeam^.ExtDriven and
   297         ((Message and gmAttack) <> 0) then SendIPC('a');
   297         ((Message and gmAttack) <> 0) then SendIPC('a');
   298     Message:= Message and not gmAttack
   298     Message:= Message and not (gmAttack and InputMask)
   299     end
   299     end
   300 end;
   300 end;
   301 
   301 
   302 procedure chSwitch(var s: shortstring);
   302 procedure chSwitch(var s: shortstring);
   303 begin
   303 begin
   305 if CheckNoTeamOrHH or isPaused then exit;
   305 if CheckNoTeamOrHH or isPaused then exit;
   306 if not CurrentTeam^.ExtDriven then SendIPC('S');
   306 if not CurrentTeam^.ExtDriven then SendIPC('S');
   307 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   307 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   308 bShowFinger:= false;
   308 bShowFinger:= false;
   309 with CurrentHedgehog^.Gear^ do
   309 with CurrentHedgehog^.Gear^ do
   310     Message:= Message or gmSwitch
   310     Message:= Message or (gmSwitch and InputMask)
   311 end;
   311 end;
   312 
   312 
   313 procedure chNextTurn(var s: shortstring);
   313 procedure chNextTurn(var s: shortstring);
   314 begin
   314 begin
   315     s:= s; // avoid compiler hint
   315     s:= s; // avoid compiler hint
   328 if not CurrentTeam^.ExtDriven then SendIPC(s);
   328 if not CurrentTeam^.ExtDriven then SendIPC(s);
   329 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   329 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   330 bShowFinger:= false;
   330 bShowFinger:= false;
   331 with CurrentHedgehog^.Gear^ do
   331 with CurrentHedgehog^.Gear^ do
   332     begin
   332     begin
   333     Message:= Message or gmTimer;
   333     Message:= Message or (gmTimer and InputMask);
   334     MsgParam:= byte(s[1]) - ord('0')
   334     MsgParam:= byte(s[1]) - ord('0')
   335     end
   335     end
   336 end;
   336 end;
   337 
   337 
   338 procedure chSlot(var s: shortstring);
   338 procedure chSlot(var s: shortstring);
   344 if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79));
   344 if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79));
   345 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   345 if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
   346 bShowFinger:= false;
   346 bShowFinger:= false;
   347 with CurrentHedgehog^.Gear^ do
   347 with CurrentHedgehog^.Gear^ do
   348     begin
   348     begin
   349     Message:= Message or gmSlot;
   349     Message:= Message or (gmSlot and InputMask);
   350     MsgParam:= slot
   350     MsgParam:= slot
   351     end
   351     end
   352 end;
   352 end;
   353 
   353 
   354 procedure chSetWeapon(var s: shortstring);
   354 procedure chSetWeapon(var s: shortstring);
   359 
   359 
   360     if not CurrentTeam^.ExtDriven then SendIPC('w' + s);
   360     if not CurrentTeam^.ExtDriven then SendIPC('w' + s);
   361 
   361 
   362     with CurrentHedgehog^.Gear^ do
   362     with CurrentHedgehog^.Gear^ do
   363     begin
   363     begin
   364         Message:= Message or gmWeapon;
   364         Message:= Message or (gmWeapon and InputMask);
   365         MsgParam:= byte(s[1]);
   365         MsgParam:= byte(s[1]);
   366     end;
   366     end;
   367 end;
   367 end;
   368 
   368 
   369 procedure chTaunt(var s: shortstring);
   369 procedure chTaunt(var s: shortstring);
   374 
   374 
   375 if not CurrentTeam^.ExtDriven then SendIPC('t' + s);
   375 if not CurrentTeam^.ExtDriven then SendIPC('t' + s);
   376 
   376 
   377 with CurrentHedgehog^.Gear^ do
   377 with CurrentHedgehog^.Gear^ do
   378     begin
   378     begin
   379     Message:= Message or gmAnimate;
   379     Message:= Message or (gmAnimate and InputMask);
   380     MsgParam:= byte(s[1])
   380     MsgParam:= byte(s[1])
   381     end
   381     end
   382 end;
   382 end;
   383 
   383 
   384 procedure chPut(var s: shortstring);
   384 procedure chPut(var s: shortstring);