account for dying king
authornemo
Fri, 05 Feb 2010 13:30:47 +0000
changeset 2759 03988f64e146
parent 2758 033aa644578f
child 2760 420fe0344e5f
account for dying king
hedgewars/uGears.pas
--- a/hedgewars/uGears.pas	Fri Feb 05 13:12:31 2010 +0000
+++ b/hedgewars/uGears.pas	Fri Feb 05 13:30:47 2010 +0000
@@ -426,8 +426,7 @@
 
 procedure DeleteGear(Gear: PGear);
 var team: PTeam;
-	t,i: Longword;
-    k: boolean;
+	t,i,k: Longword;
 begin
 DeleteCI(Gear);
 
@@ -461,10 +460,10 @@
         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;
+            k:= 0;
             for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
-                if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then k:= true;
-            if not k then
+                if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then inc(k);
+            if k < 2 then // current dying king is count of 1
                 for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
                     TeamGoneEffect(team^.Clan^.Teams[i]^)
             end;