hedgewars/uGears.pas
changeset 2758 033aa644578f
parent 2745 11fce231f24a
child 2759 03988f64e146
--- 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);