hedgewars/uTeams.pas
changeset 13597 f7cbf7d8298d
parent 13499 c41b16ac2e05
child 13642 3d14950641a4
equal deleted inserted replaced
13596:7699987d9f70 13597:f7cbf7d8298d
   493                 if th > MaxTeamHealth then
   493                 if th > MaxTeamHealth then
   494                     MaxTeamHealth:= th
   494                     MaxTeamHealth:= th
   495                 end
   495                 end
   496             else
   496             else
   497                 Hedgehogs[0].Gear^.Health:= h;
   497                 Hedgehogs[0].Gear^.Health:= h;
       
   498             // Prevent overflow
       
   499             if (Hedgehogs[0].Gear^.Health < 0) or (Hedgehogs[0].Gear^.Health > cMaxHogHealth) then
       
   500                 Hedgehogs[0].Gear^.Health:= cMaxHogHealth;
   498             Hedgehogs[0].InitialHealth:= Hedgehogs[0].Gear^.Health
   501             Hedgehogs[0].InitialHealth:= Hedgehogs[0].Gear^.Health
   499             end;
   502             end;
   500         end;
   503         end;
   501 
   504 
   502 RecountAllTeamsHealth
   505 RecountAllTeamsHealth
   612     CurrentHedgehog^.BotLevel:= StrToInt(id);
   615     CurrentHedgehog^.BotLevel:= StrToInt(id);
   613     CurrentHedgehog^.Team:= CurrentTeam;
   616     CurrentHedgehog^.Team:= CurrentTeam;
   614     Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0);
   617     Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0);
   615     SplitBySpace(s, id);
   618     SplitBySpace(s, id);
   616     Gear^.Health:= StrToInt(s);
   619     Gear^.Health:= StrToInt(s);
   617     if checkFails(Gear^.Health > 0, 'Invalid hedgehog health', true) then exit;
   620     if checkFails((Gear^.Health > 0) and (Gear^.Health <= cMaxHogHealth), 'Invalid hedgehog health (must be between 1 and '+IntToStr(cMaxHogHealth)+')', true) then exit;
   618     if (GameFlags and gfSharedAmmo) <> 0 then
   621     if (GameFlags and gfSharedAmmo) <> 0 then
   619         CurrentHedgehog^.AmmoStore:= Clan^.ClanIndex
   622         CurrentHedgehog^.AmmoStore:= Clan^.ClanIndex
   620     else if (GameFlags and gfPerHogAmmo) <> 0 then
   623     else if (GameFlags and gfPerHogAmmo) <> 0 then
   621         begin
   624         begin
   622         AddAmmoStore;
   625         AddAmmoStore;