hedgewars/CCHandlers.inc
changeset 351 29bc9c36ad5f
parent 324 f4c109c82a0c
child 358 236bbd12d4d9
equal deleted inserted replaced
350:c3ccec3834e8 351:29bc9c36ad5f
    15  * along with this program; if not, write to the Free Software
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    17  *)
    17  *)
    18 
    18 
    19 function CheckNoTeamOrHH: boolean;
    19 function CheckNoTeamOrHH: boolean;
    20 begin
    20 var Result: boolean;
    21 Result:= (CurrentTeam = nil) or (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear = nil);
    21 begin
       
    22 Result:= (CurrentTeam = nil) or (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear = nil);
    22 {$IFDEF DEBUGFILE}
    23 {$IFDEF DEBUGFILE}
    23 if Result then
    24 if Result then
    24    if CurrentTeam = nil then AddFileLog('CONSOLE: CurTeam = nil')
    25    if CurrentTeam = nil then AddFileLog('CONSOLE: CurTeam = nil')
    25                         else AddFileLog('CONSOLE: CurTeam <> nil, Gear = nil')
    26                         else AddFileLog('CONSOLE: CurTeam <> nil, Gear = nil');
    26 {$ENDIF}
    27 {$ENDIF}
       
    28 CheckNoTeamOrHH:= Result
    27 end;
    29 end;
    28 ////////////////////////////////////////////////////////////////////////////////
    30 ////////////////////////////////////////////////////////////////////////////////
    29 procedure chQuit(var s: shortstring);
    31 procedure chQuit(var s: shortstring);
    30 begin
    32 begin
    31 SendIPC('Q');
    33 SendIPC('Q');
    51    begin
    53    begin
    52    inc(TeamsCount);
    54    inc(TeamsCount);
    53    TryDo(TeamsCount <= 5, 'Too many teams', true);
    55    TryDo(TeamsCount <= 5, 'Too many teams', true);
    54    AddTeam
    56    AddTeam
    55    end;
    57    end;
    56    
    58 
    57 if GameType in [gmtDemo, gmtSave] then CurrentTeam.ExtDriven:= true
    59 if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true
    58 end;
    60 end;
    59 
    61 
    60 procedure chTeamLocal(var s: shortstring);
    62 procedure chTeamLocal(var s: shortstring);
    61 begin
    63 begin
    62 if not isDeveloperMode then exit;
    64 if not isDeveloperMode then exit;
    63 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true);
    65 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true);
    64 CurrentTeam.ExtDriven:= true
    66 CurrentTeam^.ExtDriven:= true
    65 end;
    67 end;
    66 
    68 
    67 procedure chName(var id: shortstring);
    69 procedure chName(var id: shortstring);
    68 var s: shortstring;
    70 var s: shortstring;
    69 begin
    71 begin
    70 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/name"', true);
    72 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/name"', true);
    71 SplitBySpace(id, s);
    73 SplitBySpace(id, s);
    72 if s[1]='"' then Delete(s, 1, 1);
    74 if s[1]='"' then Delete(s, 1, 1);
    73 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
    75 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
    74 if id = 'team' then CurrentTeam.TeamName:= s
    76 if id = 'team' then CurrentTeam^.TeamName:= s
    75 else if (id[1] = 'h') and (id[2] = 'h')
    77 else if (id[1] = 'h') and (id[2] = 'h')
    76      and (id[3] >= '0') and (id[3] <= chr(ord('0')+cMaxHHIndex)) then
    78      and (id[3] >= '0') and (id[3] <= chr(ord('0')+cMaxHHIndex)) then
    77    CurrentTeam.Hedgehogs[byte(id[3])-48].Name:= s
    79    CurrentTeam^.Hedgehogs[byte(id[3])-48].Name:= s
    78 else OutError(errmsgUnknownVariable + ' "' + id + '"')
    80 else OutError(errmsgUnknownVariable + ' "' + id + '"', false)
    79 end;
    81 end;
    80 
    82 
    81 procedure chGrave(var s: shortstring);
    83 procedure chGrave(var s: shortstring);
    82 begin
    84 begin
    83 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true);
    85 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true);
    84 if s[1]='"' then Delete(s, 1, 1);
    86 if s[1]='"' then Delete(s, 1, 1);
    85 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
    87 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
    86 CurrentTeam.GraveName:= s
    88 CurrentTeam^.GraveName:= s
    87 end;
    89 end;
    88 
    90 
    89 procedure chFort(var s: shortstring);
    91 procedure chFort(var s: shortstring);
    90 begin
    92 begin
    91 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true);
    93 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true);
    92 if s[1]='"' then Delete(s, 1, 1);
    94 if s[1]='"' then Delete(s, 1, 1);
    93 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
    95 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
    94 CurrentTeam.FortName:= s
    96 CurrentTeam^.FortName:= s
    95 end;
    97 end;
    96 
    98 
    97 procedure chColor(var id: shortstring);
    99 procedure chColor(var id: shortstring);
    98 var c: integer;
   100 var c: integer;
    99 begin
   101 begin
   100 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/color"', true);
   102 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/color"', true);
   101 val(id, CurrentTeam.Color, c);
   103 val(id, CurrentTeam^.Color, c);
   102 CurrentTeam.AdjColor:= CurrentTeam.Color;
   104 CurrentTeam^.AdjColor:= CurrentTeam^.Color;
   103 AdjustColor(CurrentTeam.AdjColor)
   105 AdjustColor(CurrentTeam^.AdjColor)
   104 end;
   106 end;
   105 
   107 
   106 procedure chAddHH(var id: shortstring);
   108 procedure chAddHH(var id: shortstring);
   107 var s: shortstring;
   109 var s: shortstring;
   108     c: integer;
   110     c: integer;
   111 if (not isDeveloperMode)or(CurrentTeam=nil) then exit;
   113 if (not isDeveloperMode)or(CurrentTeam=nil) then exit;
   112 with CurrentTeam^ do
   114 with CurrentTeam^ do
   113      begin
   115      begin
   114      SplitBySpace(id, s);
   116      SplitBySpace(id, s);
   115      val(id, Hedgehogs[HedgehogsNumber].BotLevel, c);
   117      val(id, Hedgehogs[HedgehogsNumber].BotLevel, c);
   116      Gear:= AddGear(0, 0, gtHedgehog, 0);
   118      Gear:= AddGear(0, 0, gtHedgehog, 0, 0, 0, 0);
   117      Gear.Hedgehog:= @Hedgehogs[HedgehogsNumber];
   119      Gear^.Hedgehog:= @Hedgehogs[HedgehogsNumber];
   118      val(s, Gear.Health, c);
   120      val(s, Gear^.Health, c);
   119      TryDo(Gear.Health > 0, 'Invalid hedgehog health', true);
   121      TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true);
   120      PHedgehog(Gear.Hedgehog).Team:= CurrentTeam;
   122      PHedgehog(Gear^.Hedgehog)^.Team:= CurrentTeam;
   121      Hedgehogs[HedgehogsNumber].AmmoStore:= 0;
   123      Hedgehogs[HedgehogsNumber].AmmoStore:= 0;
   122      Hedgehogs[HedgehogsNumber].Gear:= Gear;
   124      Hedgehogs[HedgehogsNumber].Gear:= Gear;
   123      inc(HedgehogsNumber)
   125      inc(HedgehogsNumber)
   124      end
   126      end
   125 end;
   127 end;
   136 if CurrentTeam = nil then exit;
   138 if CurrentTeam = nil then exit;
   137 SplitBySpace(id, s);
   139 SplitBySpace(id, s);
   138 if s[1]='"' then Delete(s, 1, 1);
   140 if s[1]='"' then Delete(s, 1, 1);
   139 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
   141 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
   140 b:= KeyNameToCode(id);
   142 b:= KeyNameToCode(id);
   141 if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"')
   143 if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"', false)
   142          else CurrentTeam.Binds[b]:= s
   144          else CurrentTeam^.Binds[b]:= s
   143 end;
   145 end;
   144 
   146 
   145 procedure chLeft_p(var s: shortstring);
   147 procedure chLeft_p(var s: shortstring);
   146 begin
   148 begin
   147 if CheckNoTeamOrHH then exit;
   149 if CheckNoTeamOrHH then exit;
   148 bShowFinger:= false;
   150 bShowFinger:= false;
   149 if not CurrentTeam.ExtDriven then SendIPC('L');
   151 if not CurrentTeam^.ExtDriven then SendIPC('L');
   150 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
   152 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
   151     Message:= Message or gm_Left
   153     Message:= Message or gm_Left
   152 end;
   154 end;
   153 
   155 
   154 procedure chLeft_m(var s: shortstring);
   156 procedure chLeft_m(var s: shortstring);
   155 begin
   157 begin
   156 if CheckNoTeamOrHH then exit;
   158 if CheckNoTeamOrHH then exit;
   157 if not CurrentTeam.ExtDriven then SendIPC('l');
   159 if not CurrentTeam^.ExtDriven then SendIPC('l');
   158 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
   160 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
   159      Message:= Message and not gm_Left
   161      Message:= Message and not gm_Left
   160 end;
   162 end;
   161 
   163 
   162 procedure chRight_p(var s: shortstring);
   164 procedure chRight_p(var s: shortstring);
   163 begin
   165 begin
   164 if CheckNoTeamOrHH then exit;
   166 if CheckNoTeamOrHH then exit;
   165 bShowFinger:= false;
   167 bShowFinger:= false;
   166 if not CurrentTeam.ExtDriven then SendIPC('R');
   168 if not CurrentTeam^.ExtDriven then SendIPC('R');
   167 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
   169 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
   168     Message:= Message or gm_Right
   170     Message:= Message or gm_Right
   169 end;
   171 end;
   170 
   172 
   171 procedure chRight_m(var s: shortstring);
   173 procedure chRight_m(var s: shortstring);
   172 begin
   174 begin
   173 if CheckNoTeamOrHH then exit;
   175 if CheckNoTeamOrHH then exit;
   174 if not CurrentTeam.ExtDriven then SendIPC('r');
   176 if not CurrentTeam^.ExtDriven then SendIPC('r');
   175 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
   177 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
   176      Message:= Message and not gm_Right
   178      Message:= Message and not gm_Right
   177 end;
   179 end;
   178 
   180 
   179 procedure chUp_p(var s: shortstring);
   181 procedure chUp_p(var s: shortstring);
   180 begin
   182 begin
   181 if CheckNoTeamOrHH then exit;
   183 if CheckNoTeamOrHH then exit;
   182 bShowFinger:= false;
   184 bShowFinger:= false;
   183 if not CurrentTeam.ExtDriven then SendIPC('U');
   185 if not CurrentTeam^.ExtDriven then SendIPC('U');
   184 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
   186 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
   185     Message:= Message or gm_Up
   187     Message:= Message or gm_Up
   186 end;
   188 end;
   187 
   189 
   188 procedure chUp_m(var s: shortstring);
   190 procedure chUp_m(var s: shortstring);
   189 begin
   191 begin
   190 if CheckNoTeamOrHH then exit;
   192 if CheckNoTeamOrHH then exit;
   191 if not CurrentTeam.ExtDriven then SendIPC('u');
   193 if not CurrentTeam^.ExtDriven then SendIPC('u');
   192 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
   194 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
   193      Message:= Message and not gm_Up
   195      Message:= Message and not gm_Up
   194 end;
   196 end;
   195 
   197 
   196 procedure chDown_p(var s: shortstring);
   198 procedure chDown_p(var s: shortstring);
   197 begin
   199 begin
   198 if CheckNoTeamOrHH then exit;
   200 if CheckNoTeamOrHH then exit;
   199 bShowFinger:= false;
   201 bShowFinger:= false;
   200 if not CurrentTeam.ExtDriven then SendIPC('D');
   202 if not CurrentTeam^.ExtDriven then SendIPC('D');
   201 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
   203 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
   202     Message:= Message or gm_Down
   204     Message:= Message or gm_Down
   203 end;
   205 end;
   204 
   206 
   205 procedure chDown_m(var s: shortstring);
   207 procedure chDown_m(var s: shortstring);
   206 begin
   208 begin
   207 if CheckNoTeamOrHH then exit;
   209 if CheckNoTeamOrHH then exit;
   208 if not CurrentTeam.ExtDriven then SendIPC('d');
   210 if not CurrentTeam^.ExtDriven then SendIPC('d');
   209 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
   211 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
   210      Message:= Message and not gm_Down
   212      Message:= Message and not gm_Down
   211 end;
   213 end;
   212 
   214 
   213 procedure chLJump(var s: shortstring);
   215 procedure chLJump(var s: shortstring);
   214 begin
   216 begin
   215 if CheckNoTeamOrHH then exit;
   217 if CheckNoTeamOrHH then exit;
   216 bShowFinger:= false;
   218 bShowFinger:= false;
   217 if not CurrentTeam.ExtDriven then SendIPC('j');
   219 if not CurrentTeam^.ExtDriven then SendIPC('j');
   218 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
   220 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
   219     Message:= Message or gm_LJump
   221     Message:= Message or gm_LJump
   220 end;
   222 end;
   221 
   223 
   222 procedure chHJump(var s: shortstring);
   224 procedure chHJump(var s: shortstring);
   223 begin
   225 begin
   224 if CheckNoTeamOrHH then exit;
   226 if CheckNoTeamOrHH then exit;
   225 bShowFinger:= false;
   227 bShowFinger:= false;
   226 if not CurrentTeam.ExtDriven then SendIPC('J');
   228 if not CurrentTeam^.ExtDriven then SendIPC('J');
   227 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
   229 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
   228     Message:= Message or gm_HJump
   230     Message:= Message or gm_HJump
   229 end;
   231 end;
   230 
   232 
   231 procedure chAttack_p(var s: shortstring);
   233 procedure chAttack_p(var s: shortstring);
   232 begin
   234 begin
   233 if CheckNoTeamOrHH then exit;
   235 if CheckNoTeamOrHH then exit;
   234 bShowFinger:= false;
   236 bShowFinger:= false;
   235 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
   237 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
   236      begin
   238      begin
   237      {$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear.State = '+inttostr(State));{$ENDIF}
   239      {$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear^.State = '+inttostr(State));{$ENDIF}
   238      if ((State and gstHHDriven)<>0)and((State and (gstAttacked or gstHHChooseTarget or gstMoving)) = 0) then
   240      if ((State and gstHHDriven)<>0)and((State and (gstAttacked or gstHHChooseTarget or gstMoving)) = 0) then
   239         begin
   241         begin
   240         FollowGear:= CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear;
   242         FollowGear:= CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear;
   241         if not CurrentTeam.ExtDriven then SendIPC('A');
   243         if not CurrentTeam^.ExtDriven then SendIPC('A');
   242         Message:= Message or gm_Attack
   244         Message:= Message or gm_Attack
   243         end
   245         end
   244      end
   246      end
   245 end;
   247 end;
   246 
   248 
   247 procedure chAttack_m(var s: shortstring);
   249 procedure chAttack_m(var s: shortstring);
   248 begin
   250 begin
   249 if CheckNoTeamOrHH then exit;
   251 if CheckNoTeamOrHH then exit;
   250 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
   252 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
   251      begin
   253      begin
   252      if not CurrentTeam.ExtDriven and
   254      if not CurrentTeam^.ExtDriven and
   253         ((Message and gm_Attack) <> 0) then SendIPC('a');
   255         ((Message and gm_Attack) <> 0) then SendIPC('a');
   254      Message:= Message and not gm_Attack
   256      Message:= Message and not gm_Attack
   255      end
   257      end
   256 end;
   258 end;
   257 
   259 
   258 procedure chSwitch(var s: shortstring);
   260 procedure chSwitch(var s: shortstring);
   259 begin
   261 begin
   260 if CheckNoTeamOrHH then exit;
   262 if CheckNoTeamOrHH then exit;
   261 if not CurrentTeam.ExtDriven then SendIPC('S');
   263 if not CurrentTeam^.ExtDriven then SendIPC('S');
   262 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
   264 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
   263      Message:= Message or gm_Switch
   265      Message:= Message or gm_Switch
   264 end;
   266 end;
   265 
   267 
   266 procedure chNextTurn(var s: shortstring);
   268 procedure chNextTurn(var s: shortstring);
   267 begin
   269 begin
   268 if AllInactive then
   270 if AllInactive then
   269    begin
   271    begin
   270    if not CurrentTeam.ExtDriven then SendIPC('N');
   272    if not CurrentTeam^.ExtDriven then SendIPC('N');
   271    {$IFDEF DEBUGFILE}AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));{$ENDIF}
   273    {$IFDEF DEBUGFILE}AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));{$ENDIF}
   272    SwitchHedgehog;
   274    SwitchHedgehog;
   273    end
   275    end
   274 end;
   276 end;
   275 
   277 
   281 
   283 
   282 procedure chTimer(var s: shortstring);
   284 procedure chTimer(var s: shortstring);
   283 begin
   285 begin
   284 if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or (CurrentTeam = nil) then exit;
   286 if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or (CurrentTeam = nil) then exit;
   285 bShowFinger:= false;
   287 bShowFinger:= false;
   286 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
   288 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do
   287      if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0 then
   289      if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0 then
   288         begin
   290         begin
   289         Ammo[CurSlot, CurAmmo].Timer:= 1000 * (byte(s[1]) - 48);
   291         Ammo^[CurSlot, CurAmmo].Timer:= 1000 * (byte(s[1]) - 48);
   290         with CurrentTeam^ do
   292         with CurrentTeam^ do
   291              ApplyAmmoChanges(Hedgehogs[CurrHedgehog]);
   293              ApplyAmmoChanges(Hedgehogs[CurrHedgehog]);
   292         if not CurrentTeam.ExtDriven then SendIPC(s);
   294         if not CurrentTeam^.ExtDriven then SendIPC(s);
   293         end
   295         end
   294 end;
   296 end;
   295 
   297 
   296 procedure chSlot(var s: shortstring);
   298 procedure chSlot(var s: shortstring);
   297 var slot: LongWord;
   299 var slot: LongWord;
   299 begin
   301 begin
   300 if (s[0] <> #1) or CheckNoTeamOrHH then exit;
   302 if (s[0] <> #1) or CheckNoTeamOrHH then exit;
   301 bShowFinger:= false;
   303 bShowFinger:= false;
   302 slot:= byte(s[1]) - 49;
   304 slot:= byte(s[1]) - 49;
   303 if slot > cMaxSlotIndex then exit;
   305 if slot > cMaxSlotIndex then exit;
   304 if not CurrentTeam.ExtDriven then SendIPC(char(byte(s[1]) + 79));
   306 if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79));
   305 with CurrentTeam^ do
   307 with CurrentTeam^ do
   306      begin
   308      begin
   307      with Hedgehogs[CurrHedgehog] do
   309      with Hedgehogs[CurrHedgehog] do
   308           begin
   310           begin
   309           if ((Gear.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0)
   311           if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0)
   310              or ((Gear.State and gstHHDriven) = 0) then exit; // во время стрельбы исключает смену оружия
   312              or ((Gear^.State and gstHHDriven) = 0) then exit; // во время стрельбы исключает смену оружия
   311           if CurAmmoGear = nil then begin caSlot:= @CurSlot; caAmmo:= @CurAmmo end
   313           if CurAmmoGear = nil then begin caSlot:= @CurSlot; caAmmo:= @CurAmmo end
   312                                else begin caSlot:= @AltSlot; caAmmo:= @AltAmmo end;
   314                                else begin caSlot:= @AltSlot; caAmmo:= @AltAmmo end;
   313           if caSlot^ = slot then
   315           if caSlot^ = slot then
   314              begin
   316              begin
   315              inc(caAmmo^);
   317              inc(caAmmo^);
   316              if (caAmmo^ > cMaxSlotAmmoIndex) or (Ammo[slot, caAmmo^].Count = 0) then caAmmo^:= 0
   318              if (caAmmo^ > cMaxSlotAmmoIndex) or (Ammo^[slot, caAmmo^].Count = 0) then caAmmo^:= 0
   317              end else
   319              end else
   318              if Ammo[slot, 0].Count > 0 then
   320              if Ammo^[slot, 0].Count > 0 then
   319                 begin
   321                 begin
   320                 caSlot^:= slot;
   322                 caSlot^:= slot;
   321                 caAmmo^:= 0;
   323                 caAmmo^:= 0;
   322                 end;
   324                 end;
   323           end;
   325           end;
   331 if bShowAmmoMenu then
   333 if bShowAmmoMenu then
   332    begin
   334    begin
   333    bSelected:= true;
   335    bSelected:= true;
   334    exit
   336    exit
   335    end;
   337    end;
   336 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^,
   338 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^,
   337      CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
   339      CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do
   338      if (State and gstHHChooseTarget) <> 0 then
   340      if (State and gstHHChooseTarget) <> 0 then
   339         begin
   341         begin
   340         isCursorVisible:= false;
   342         isCursorVisible:= false;
   341         if not CurrentTeam.ExtDriven then
   343         if not CurrentTeam^.ExtDriven then
   342            begin
   344            begin
   343            SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y);
   345            SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y);
   344            dec(TargetPoint.X, WorldDx);
   346            dec(TargetPoint.X, WorldDx);
   345            dec(TargetPoint.Y, WorldDy);
   347            dec(TargetPoint.Y, WorldDy);
   346            SendIPCXY('p', TargetPoint.X, TargetPoint.Y);
   348            SendIPCXY('p', TargetPoint.X, TargetPoint.Y);
   347            end;
   349            end;
   348         State:= State and not gstHHChooseTarget;
   350         State:= State and not gstHHChooseTarget;
   349         if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then
   351         if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then
   350            Message:= Message or gm_Attack;
   352            Message:= Message or gm_Attack;
   351         end else if CurrentTeam.ExtDriven then OutError('got /put while not being in choose target mode', false)
   353         end else if CurrentTeam^.ExtDriven then OutError('got /put while not being in choose target mode', false)
   352 end;
   354 end;
   353 
   355 
   354 procedure chCapture(var s: shortstring);
   356 procedure chCapture(var s: shortstring);
   355 begin
   357 begin
   356 flagMakeCapture:= true
   358 flagMakeCapture:= true
   357 end;
   359 end;
   358 
   360 
   359 procedure chSkip(var s: shortstring);
   361 procedure chSkip(var s: shortstring);
   360 begin
   362 begin
   361 if not CurrentTeam.ExtDriven then SendIPC(',');
   363 if not CurrentTeam^.ExtDriven then SendIPC(',');
   362 TurnTimeLeft:= 0
   364 TurnTimeLeft:= 0
   363 end;
   365 end;
   364 
   366 
   365 procedure chSetMap(var s: shortstring);
   367 procedure chSetMap(var s: shortstring);
   366 begin
   368 begin
   396 with CurrentTeam^ do
   398 with CurrentTeam^ do
   397      with Hedgehogs[CurrHedgehog] do
   399      with Hedgehogs[CurrHedgehog] do
   398           begin
   400           begin
   399           bSelected:= false;
   401           bSelected:= false;
   400           if bShowAmmoMenu then bShowAmmoMenu:= false
   402           if bShowAmmoMenu then bShowAmmoMenu:= false
   401           else if ((Gear.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0)
   403           else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0)
   402                or ((Gear.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true
   404                or ((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true
   403           end
   405           end
   404 end;
   406 end;
   405 
   407 
   406 procedure chFullScr(var s: shortstring);
   408 procedure chFullScr(var s: shortstring);
   407 var flags: Longword;
   409 var flags: Longword;
   410 {$ENDIF}
   412 {$ENDIF}
   411 begin
   413 begin
   412 if Length(s) = 0 then cFullScreen:= not cFullScreen
   414 if Length(s) = 0 then cFullScreen:= not cFullScreen
   413                  else cFullScreen:= s = '1';
   415                  else cFullScreen:= s = '1';
   414 
   416 
   415 flags:= SDL_HWSURFACE or SDL_DOUBLEBUF or SDL_HWACCEL;
   417 flags:= SDL_HWSURFACE or SDL_hwFloatBUF or SDL_HWACCEL;
   416 if cFullScreen then flags:= flags or SDL_FULLSCREEN
   418 if cFullScreen then flags:= flags or SDL_FULLSCREEN
   417                else SDL_WM_SetCaption('Hedgewars', nil);
   419                else SDL_WM_SetCaption('Hedgewars', nil);
   418 SDL_FreeSurface(SDLPrimSurface);
   420 SDL_FreeSurface(SDLPrimSurface);
   419 SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
   421 SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
   420 
   422 
   421 {$IFDEF DEBUGFILE}
   423 {$IFDEF DEBUGFILE}
   422 AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf))));
   424 AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf))));
   423 {$ENDIF}
   425 {$ENDIF}
   424 TryDo(SDLPrimSurface <> nil, errmsgCreateSurface, true);
   426 TryDo(SDLPrimSurface <> nil, errmsgCreateSurface, true);
   425 PixelFormat:= SDLPrimSurface.format
   427 PixelFormat:= SDLPrimSurface^.format
   426 end;
   428 end;
   427 
   429 
   428 procedure chVol_p(var s: shortstring);
   430 procedure chVol_p(var s: shortstring);
   429 begin
   431 begin
   430 inc(cVolumeDelta, 3)
   432 inc(cVolumeDelta, 3)
   437 
   439 
   438 procedure chFindhh(var s: shortstring);
   440 procedure chFindhh(var s: shortstring);
   439 begin
   441 begin
   440 if CheckNoTeamOrHH then exit;
   442 if CheckNoTeamOrHH then exit;
   441 bShowFinger:= true;
   443 bShowFinger:= true;
   442 FollowGear:= CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear
   444 FollowGear:= CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear
   443 end;
   445 end;
   444 
   446 
   445 procedure chPause(var s: shortstring);
   447 procedure chPause(var s: shortstring);
   446 begin
   448 begin
   447 isPaused:= not isPaused;
   449 isPaused:= not isPaused;
   448 SDL_ShowCursor(ord(isPaused))
   450 SDL_ShowCursor(ord(isPaused))
   449 end;
   451 end;
   450