Refactor definition of "local" clans
authorWuzzy <Wuzzy2@mail.ru>
Sun, 26 May 2019 14:16:35 +0200
changeset 15073 1a754860b0e5
parent 15072 a9873c81b5e6
child 15074 e3b3fa42a93b
Refactor definition of "local" clans
hedgewars/uGearsUtils.pas
hedgewars/uTeams.pas
hedgewars/uTypes.pas
hedgewars/uVariables.pas
hedgewars/uWorld.pas
--- a/hedgewars/uGearsUtils.pas	Sat May 25 18:18:42 2019 +0300
+++ b/hedgewars/uGearsUtils.pas	Sun May 26 14:16:35 2019 +0200
@@ -1869,7 +1869,7 @@
 
 function IsHogLocal(HH: PHedgehog): boolean;
 begin
-    IsHogLocal:= (not (HH^.Team^.ExtDriven or (HH^.BotLevel > 0))) or (HH^.Team^.Clan^.ClanIndex = LocalClan) or (GameType = gmtDemo);
+    IsHogLocal:= (not (HH^.Team^.ExtDriven or (HH^.BotLevel > 0))) or (HH^.Team^.Clan^.LocalOrAlly) or (GameType = gmtDemo);
 end;
 
 end.
--- a/hedgewars/uTeams.pas	Sat May 25 18:18:42 2019 +0300
+++ b/hedgewars/uTeams.pas	Sun May 26 14:16:35 2019 +0200
@@ -522,6 +522,7 @@
         Color:= TeamColor;
         TagTeamIndex:= 0;
         Flawless:= true;
+        LocalOrAlly:= false;
         DeathLogged:= false;
         StatsHandled:= false;
         end
@@ -562,7 +563,7 @@
         begin
         if (not ExtDriven) and (Hedgehogs[0].BotLevel = 0) then
             begin
-            LocalClan:= Clan^.ClanIndex;
+            Clan^.LocalOrAlly:= true;
             LocalTeam:= t;
             LocalAmmo:= Hedgehogs[0].AmmoStore
             end;
@@ -1082,7 +1083,6 @@
 CurrentHedgehog:= nil;
 TeamsCount:= 0;
 ClansCount:= 0;
-LocalClan:= -1;
 LocalTeam:= -1;
 LocalAmmo:= -1;
 TeamsGameOver:= false;
--- a/hedgewars/uTypes.pas	Sat May 25 18:18:42 2019 +0300
+++ b/hedgewars/uTypes.pas	Sun May 26 14:16:35 2019 +0200
@@ -476,6 +476,7 @@
             StatsHandled : boolean; // true if clan's rank has been handled for stats screen
             Flawless: boolean;
             Passive: boolean; // informational. Must be set to true if all of the teams are passive
+            LocalOrAlly: boolean; // true if at least 1 team in the clan is a local team. A local team is a non-extdriven team controlled by a human
             end;
 
      cdeclPtr = procedure; cdecl;
--- a/hedgewars/uVariables.pas	Sat May 25 18:18:42 2019 +0300
+++ b/hedgewars/uVariables.pas	Sun May 26 14:16:35 2019 +0200
@@ -2557,7 +2557,6 @@
     VisibleTeamsCount: Longword; // number of teams visible in team bar
     ClansArray, SpawnClansArray: TClansArray;
     ClansCount: Longword;
-    LocalClan: LongInt;  // last non-bot, non-extdriven clan
     LocalTeam: LongInt;  // last non-bot, non-extdriven clan first team
     LocalAmmo: LongInt;  // last non-bot, non-extdriven clan's first team's ammo index, updated to next upcoming hog for per-hog-ammo
     CurMinAngle, CurMaxAngle: Longword;
--- a/hedgewars/uWorld.pas	Sat May 25 18:18:42 2019 +0300
+++ b/hedgewars/uWorld.pas	Sun May 26 14:16:35 2019 +0200
@@ -173,10 +173,6 @@
             ClansArray[t]:= cp;
             ClansArray[t]^.ClanIndex:= t;
             ClansArray[0]^.ClanIndex:= 0;
-            if (LocalClan = t) then
-                LocalClan:= 0
-            else if (LocalClan = 0) then
-                LocalClan:= t
             end;
         end;
     CurrentTeam:= ClansArray[0]^.Teams[0];