hedgewars/uTeams.pas
changeset 1058 c53c5c4e7b48
parent 1011 4fe2c4c57d10
child 1066 1f1b3686a2b0
equal deleted inserted replaced
1057:6b5785287f42 1058:c53c5c4e7b48
    77     TeamsCount: Longword = 0;
    77     TeamsCount: Longword = 0;
    78     ClansArray: array[0..Pred(cMaxTeams)] of PClan;
    78     ClansArray: array[0..Pred(cMaxTeams)] of PClan;
    79     ClansCount: Longword = 0;
    79     ClansCount: Longword = 0;
    80     CurMinAngle, CurMaxAngle: Longword;
    80     CurMinAngle, CurMaxAngle: Longword;
    81 
    81 
    82 function AddTeam(TeamColor: Longword): PTeam;
    82 function  AddTeam(TeamColor: Longword): PTeam;
    83 procedure SwitchHedgehog;
    83 procedure SwitchHedgehog;
       
    84 procedure AfterSwitchHedgehog;
    84 procedure InitTeams;
    85 procedure InitTeams;
    85 function  TeamSize(p: PTeam): Longword;
    86 function  TeamSize(p: PTeam): Longword;
    86 procedure RecountTeamHealth(team: PTeam);
    87 procedure RecountTeamHealth(team: PTeam);
    87 procedure RestoreTeamsFromSave;
    88 procedure RestoreTeamsFromSave;
    88 function CheckForWin: boolean;
    89 function  CheckForWin: boolean;
    89 
    90 
    90 implementation
    91 implementation
    91 uses uMisc, uWorld, uAI, uLocale, uConsole, uAmmos, uSound;
    92 uses uMisc, uWorld, uAI, uLocale, uConsole, uAmmos, uSound;
    92 const MaxTeamHealth: LongInt = 0;
    93 const MaxTeamHealth: LongInt = 0;
    93 
    94 
   138 SendStats
   139 SendStats
   139 end;
   140 end;
   140 
   141 
   141 procedure SwitchHedgehog;
   142 procedure SwitchHedgehog;
   142 var c: LongWord;
   143 var c: LongWord;
   143     g: PGear;
       
   144     PrevHH, PrevTeam: LongWord;
   144     PrevHH, PrevTeam: LongWord;
   145 begin
   145 begin
   146 FreeActionsList;
   146 FreeActionsList;
   147 TargetPoint.X:= NoPointX;
   147 TargetPoint.X:= NoPointX;
   148 TryDo(CurrentTeam <> nil, 'nil Team', true);
   148 TryDo(CurrentTeam <> nil, 'nil Team', true);
   157         InsertGearToList(Gear)
   157         InsertGearToList(Gear)
   158         end;
   158         end;
   159 
   159 
   160 c:= CurrentTeam^.Clan^.ClanIndex;
   160 c:= CurrentTeam^.Clan^.ClanIndex;
   161 repeat
   161 repeat
   162   c:= Succ(c) mod ClansCount;
   162 	inc(c);
   163   with ClansArray[c]^ do
   163 	if c = ClansCount then
   164     repeat
   164 		begin
   165     PrevTeam:= CurrTeam;
   165 		inc(TotalRounds);
   166     CurrTeam:= Succ(CurrTeam) mod TeamsNumber;
   166 		c:= 0
   167     CurrentTeam:= Teams[CurrTeam];
   167 		end;
   168     with CurrentTeam^ do
   168 
   169       begin
   169 	with ClansArray[c]^ do
   170       PrevHH:= CurrHedgehog;
   170 		repeat
   171       repeat
   171 			PrevTeam:= CurrTeam;
   172         CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber;
   172 			CurrTeam:= Succ(CurrTeam) mod TeamsNumber;
   173       until (Hedgehogs[CurrHedgehog].Gear <> nil) or (CurrHedgehog = PrevHH)
   173 			CurrentTeam:= Teams[CurrTeam];
   174       end
   174 			with CurrentTeam^ do
   175     until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) or (PrevTeam = CurrTeam);
   175 				begin
       
   176 				PrevHH:= CurrHedgehog;
       
   177 				repeat
       
   178 					CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber;
       
   179 				until (Hedgehogs[CurrHedgehog].Gear <> nil) or (CurrHedgehog = PrevHH)
       
   180 			end
       
   181 		until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) or (PrevTeam = CurrTeam);
   176 until CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil;
   182 until CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil;
   177 
   183 
   178 CurrentHedgehog:= @(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]);
   184 CurrentHedgehog:= @(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog])
       
   185 end;
       
   186 
       
   187 procedure AfterSwitchHedgehog;
       
   188 var g: PGear;
       
   189 begin
   179 SwitchNotHoldedAmmo(CurrentHedgehog^);
   190 SwitchNotHoldedAmmo(CurrentHedgehog^);
   180 with CurrentHedgehog^ do
   191 with CurrentHedgehog^ do
   181      begin
   192      begin
   182      with Gear^ do
   193      with Gear^ do
   183           begin
   194           begin