hedgewars/uTeams.pas
branchqmlfrontend
changeset 11544 b69f5f22a3ba
parent 11539 c22d292e7266
child 11734 f48408dcea36
equal deleted inserted replaced
11481:caa1e84c3ac2 11544:b69f5f22a3ba
   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;
   606     Color:= StrToInt(cs);
   606     Color:= StrToInt(cs);
   607 
   607 
   608     // color is always little endian so the mask must be constant also in big endian archs
   608     // color is always little endian so the mask must be constant also in big endian archs
   609     Color:= Color or $FF000000;
   609     Color:= Color or $FF000000;
   610     AddTeam(Color);
   610     AddTeam(Color);
   611     CurrentTeam^.TeamName:= ts;
   611     
   612     CurrentTeam^.PlayerHash:= s;
   612     if CurrentTeam <> nil then
   613     loadTeamBinds(ts);
   613         begin
   614 
   614         CurrentTeam^.TeamName:= ts;
   615     if GameType in [gmtDemo, gmtSave, gmtRecord] then
   615         CurrentTeam^.PlayerHash:= s;
   616         CurrentTeam^.ExtDriven:= true;
   616         loadTeamBinds(ts);
   617 
   617 
   618     CurrentTeam^.voicepack:= AskForVoicepack('Default')
   618         if GameType in [gmtDemo, gmtSave, gmtRecord] then
       
   619             CurrentTeam^.ExtDriven:= true;
       
   620 
       
   621         CurrentTeam^.voicepack:= AskForVoicepack('Default')
       
   622         end
   619     end
   623     end
   620 end;
   624 end;
   621 
   625 
   622 procedure chSetHHCoords(var x: shortstring);
   626 procedure chSetHHCoords(var x: shortstring);
   623 var y: shortstring;
   627 var y: shortstring;