Fixes memory leak -Burp
authortiyuri@gmail.com
Thu, 26 Aug 2010 14:46:30 +0100
changeset 3773 f552c7b439fa
parent 3772 a03e6b68a3e7
child 3774 af0e68ca273e
Fixes memory leak -Burp
hedgewars/uGears.pas
hedgewars/uStore.pas
hedgewars/uTeams.pas
hedgewars/uWorld.pas
--- a/hedgewars/uGears.pas	Thu Aug 26 14:32:29 2010 +0100
+++ b/hedgewars/uGears.pas	Thu Aug 26 14:46:30 2010 +0100
@@ -1549,7 +1549,11 @@
     gear^.dX := _0;
     gear^.dY := _0;
     gear^.State := gstWait;
-    inc(CurrentHedgehog^.Team^.stats.AIKills);
+    with CurrentHedgehog^ do begin
+        inc(Team^.stats.AIKills);
+        if Team^.AIKillsTex <> nil then FreeTexture(Team^.AIKillsTex);
+        Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16);
+    end;
     FindPlace(gear, false, 0, LAND_WIDTH); 
     RenderHealth(PHedgehog(gear^.Hedgehog)^);
     RecountTeamHealth(PHedgehog(gear^.Hedgehog)^.Team);
--- a/hedgewars/uStore.pas	Thu Aug 26 14:32:29 2010 +0100
+++ b/hedgewars/uStore.pas	Thu Aug 26 14:46:30 2010 +0100
@@ -259,6 +259,8 @@
         FlagTex:= Surface2Tex(texsurf, false);
         SDL_FreeSurface(texsurf);
 
+        AIKillsTex := RenderStringTex(inttostr(stats.AIKills), Clan^.Color, fnt16);
+
         dec(drY, r.h + 2);
         DrawHealthY:= drY;
         for i:= 0 to 7 do
--- a/hedgewars/uTeams.pas	Thu Aug 26 14:32:29 2010 +0100
+++ b/hedgewars/uTeams.pas	Thu Aug 26 14:46:30 2010 +0100
@@ -63,6 +63,7 @@
             CrosshairTex,
             GraveTex,
             HealthTex,
+            AIKillsTex,
             FlagTex: PTexture;
             Flag: shortstring;
             GraveName: shortstring;
--- a/hedgewars/uWorld.pas	Thu Aug 26 14:32:29 2010 +0100
+++ b/hedgewars/uWorld.pas	Thu Aug 26 14:46:30 2010 +0100
@@ -782,7 +782,7 @@
       // draw ai kill counter for gfAISurvival
       if (GameFlags and gfAISurvival) <> 0 then begin
           DrawTexture(TeamHealthBarWidth + 22, cScreenHeight + DrawHealthY,
-              RenderStringTex(''+inttostr(stats.AIKills)+'', Clan^.Color, fnt16));
+              AIKillsTex);
       end;
 
       // if highlighted, draw flag and other contents again to keep their colors