Add one king per team instead of clan, kill off clan if all kings are dead. untested.
authornemo
Fri, 05 Feb 2010 13:12:31 +0000
changeset 2758 033aa644578f
parent 2757 8dbfe782218c
child 2759 03988f64e146
Add one king per team instead of clan, kill off clan if all kings are dead. untested.
hedgewars/uGears.pas
hedgewars/uTeams.pas
--- a/hedgewars/uGears.pas	Fri Feb 05 11:47:57 2010 +0000
+++ b/hedgewars/uGears.pas	Fri Feb 05 13:12:31 2010 +0000
@@ -427,6 +427,7 @@
 procedure DeleteGear(Gear: PGear);
 var team: PTeam;
 	t,i: Longword;
+    k: boolean;
 begin
 DeleteCI(Gear);
 
@@ -458,8 +459,15 @@
 			FreeActionsList; // to avoid ThinkThread on drawned gear
 
         if PHedgehog(Gear^.Hedgehog)^.King then
+            begin
+            // are there any other kings left? Just doing nil check.  Presumably a mortally wounded king will get reaped soon enough
+            k:= false;
             for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
-                TeamGoneEffect(team^.Clan^.Teams[i]^);
+                if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then k:= true;
+            if not k then
+                for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
+                    TeamGoneEffect(team^.Clan^.Teams[i]^)
+            end;
 
 		PHedgehog(Gear^.Hedgehog)^.Gear:= nil;
 		inc(KilledHHs);
--- a/hedgewars/uTeams.pas	Fri Feb 05 11:47:57 2010 +0000
+++ b/hedgewars/uTeams.pas	Fri Feb 05 13:12:31 2010 +0000
@@ -306,24 +306,19 @@
     th: LongInt;
 begin
 
-// Some initial King buffs
-if (GameFlags and gfKing) <> 0 then
-   for i:= 0 to Pred(ClansCount) do 
-      begin
-      with ClansArray[i]^.Teams[0]^.Hedgehogs[0] do
-         begin
-         King:= true;
-         Hat:= 'crown';
-         Gear^.Health:= hwRound(int2hwFloat(Gear^.Health)*_1_5);
-         end
-      end;
-
 for t:= 0 to Pred(TeamsCount) do
    with TeamsArray[t]^ do
       begin
       if (not ExtDriven) and (Hedgehogs[0].BotLevel = 0) then
           LocalClan:= Clan^.ClanIndex + 1;
       th:= 0;
+      // Some initial King buffs
+      if (GameFlags and gfKing) <> 0 then
+          begin
+          Hedgehogs[0].King:= true;
+          Hedgehogs[0].Hat:= 'crown';
+          inc(Hedgehogs[0].Gear^.Health, hwRound(int2hwFloat(Hedgehogs[0].Gear^.Health)*_1_5))
+          end;
       for i:= 0 to cMaxHHIndex do
           if Hedgehogs[i].Gear <> nil then
              inc(th, Hedgehogs[i].Gear^.Health);