hedgewars/uTeams.pas
changeset 11532 bf86c6cb9341
parent 11471 458d90012c22
child 11539 c22d292e7266
equal deleted inserted replaced
11531:d1cf1ff6cabb 11532:bf86c6cb9341
   117 procedure SwitchHedgehog;
   117 procedure SwitchHedgehog;
   118 var c, i, t: LongWord;
   118 var c, i, t: LongWord;
   119     PrevHH, PrevTeam : LongWord;
   119     PrevHH, PrevTeam : LongWord;
   120 begin
   120 begin
   121 TargetPoint.X:= NoPointX;
   121 TargetPoint.X:= NoPointX;
   122 TryDo(CurrentTeam <> nil, 'nil Team', true);
   122 if checkFails(CurrentTeam <> nil, 'nil Team', true) then exit;
   123 with CurrentHedgehog^ do
   123 with CurrentHedgehog^ do
   124     if (PreviousTeam <> nil) and PlacingHogs and Unplaced then
   124     if (PreviousTeam <> nil) and PlacingHogs and Unplaced then
   125         begin
   125         begin
   126         Unplaced:= false;
   126         Unplaced:= false;
   127         if Gear <> nil then
   127         if Gear <> nil then
   353 
   353 
   354 function AddTeam(TeamColor: Longword): PTeam;
   354 function AddTeam(TeamColor: Longword): PTeam;
   355 var team: PTeam;
   355 var team: PTeam;
   356     c, t: LongInt;
   356     c, t: LongInt;
   357 begin
   357 begin
   358 TryDo(TeamsCount < cMaxTeams, 'Too many teams', true);
   358 if checkFails(TeamsCount < cMaxTeams, 'Too many teams', true) then exit(nil);
   359 New(team);
   359 New(team);
   360 TryDo(team <> nil, 'AddTeam: team = nil', true);
   360 if checkFails(team <> nil, 'AddTeam: team = nil', true) then exit(nil);
   361 FillChar(team^, sizeof(TTeam), 0);
   361 FillChar(team^, sizeof(TTeam), 0);
   362 team^.AttackBar:= 2;
   362 team^.AttackBar:= 2;
   363 team^.CurrHedgehog:= 0;
   363 team^.CurrHedgehog:= 0;
   364 team^.Flag:= 'hedgewars';
   364 team^.Flag:= 'hedgewars';
   365 
   365 
   549     Gear: PGear;
   549     Gear: PGear;
   550 begin
   550 begin
   551 s:= '';
   551 s:= '';
   552 if (not isDeveloperMode) then
   552 if (not isDeveloperMode) then
   553     exit;
   553     exit;
   554 TryDo((CurrentTeam <> nil), 'Can''t add hedgehogs yet, add a team first!', true);
   554 if checkFails((CurrentTeam <> nil), 'Can''t add hedgehogs yet, add a team first!', true) then exit;
   555 with CurrentTeam^ do
   555 with CurrentTeam^ do
   556     begin
   556     begin
   557     TryDo(HedgehogsNumber<=cMaxHHIndex, 'Can''t add hedgehog to "' + TeamName + '"! (already ' + intToStr(HedgehogsNumber) + ' hogs)', true);
   557     if checkFails(HedgehogsNumber<=cMaxHHIndex, 'Can''t add hedgehog to "' + TeamName + '"! (already ' + intToStr(HedgehogsNumber) + ' hogs)', true) then exit;
   558     SplitBySpace(id, s);
   558     SplitBySpace(id, s);
   559     SwitchCurrentHedgehog(@Hedgehogs[HedgehogsNumber]);
   559     SwitchCurrentHedgehog(@Hedgehogs[HedgehogsNumber]);
   560     CurrentHedgehog^.BotLevel:= StrToInt(id);
   560     CurrentHedgehog^.BotLevel:= StrToInt(id);
   561     CurrentHedgehog^.Team:= CurrentTeam;
   561     CurrentHedgehog^.Team:= CurrentTeam;
   562     Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0);
   562     Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0);
   563     SplitBySpace(s, id);
   563     SplitBySpace(s, id);
   564     Gear^.Health:= StrToInt(s);
   564     Gear^.Health:= StrToInt(s);
   565     TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true);
   565     if checkFails(Gear^.Health > 0, 'Invalid hedgehog health', true) then exit;
   566     if (GameFlags and gfSharedAmmo) <> 0 then
   566     if (GameFlags and gfSharedAmmo) <> 0 then
   567         CurrentHedgehog^.AmmoStore:= Clan^.ClanIndex
   567         CurrentHedgehog^.AmmoStore:= Clan^.ClanIndex
   568     else if (GameFlags and gfPerHogAmmo) <> 0 then
   568     else if (GameFlags and gfPerHogAmmo) <> 0 then
   569         begin
   569         begin
   570         AddAmmoStore;
   570         AddAmmoStore;