hedgewars/uTeams.pas
changeset 10634 35d059bd0932
parent 10581 f0b4c14a3c62
child 10635 8e8b320eefad
--- a/hedgewars/uTeams.pas	Sun Dec 07 14:36:28 2014 -0500
+++ b/hedgewars/uTeams.pas	Mon Dec 08 09:35:14 2014 -0500
@@ -852,28 +852,31 @@
         for h:= 0 to cMaxHHIndex do
             with TeamsArray[i]^.Hedgehogs[h] do
                 begin
+                if Gear <> nil then
+                    DeleteGear(Gear);
                 if GearHidden <> nil then
-                    Dispose(GearHidden);
+                    DeleteGear(GearHidden);
 
-                FreeTexture(NameTagTex);
-                FreeTexture(HealthTagTex);
-                FreeTexture(HatTex);
+                FreeAndNilTexture(NameTagTex);
+                FreeAndNilTexture(HealthTagTex);
+                FreeAndNilTexture(HatTex)
                 end;
 
         with TeamsArray[i]^ do
             begin
-            FreeTexture(NameTagTex);
-            FreeTexture(GraveTex);
-            FreeTexture(AIKillsTex);
-            FreeTexture(FlagTex);
+            FreeAndNilTexture(NameTagTex);
+            FreeAndNilTexture(OwnerTex);
+            FreeAndNilTexture(GraveTex);
+            FreeAndNilTexture(AIKillsTex);
+            FreeAndNilTexture(FlagTex);
             end;
 
-        Dispose(TeamsArray[i]);
-    end;
+        Dispose(TeamsArray[i])
+        end;
     for i:= 0 to Pred(ClansCount) do
         begin
-        FreeTexture(ClansArray[i]^.HealthTex);
-        Dispose(ClansArray[i]);
+        FreeAndNilTexture(ClansArray[i]^.HealthTex);
+        Dispose(ClansArray[i])
         end
     end;
 TeamsCount:= 0;