--- a/hedgewars/hwengine.pas Tue Feb 01 15:30:08 2011 +0100
+++ b/hedgewars/hwengine.pas Tue Feb 01 19:49:10 2011 +0100
@@ -379,7 +379,7 @@
//uGame does not need to be freed
//uFloat does not need to be freed
uCollisions.freeModule; //stub
- uChat.freeModule; //stub
+ uChat.freeModule;
uAmmos.freeModule;
uAIMisc.freeModule; //stub
//uAIAmmoTests does not need to be freed
--- a/hedgewars/uCaptions.pas Tue Feb 01 15:30:08 2011 +0100
+++ b/hedgewars/uCaptions.pas Tue Feb 01 19:49:10 2011 +0100
@@ -66,7 +66,13 @@
end;
procedure freeModule;
+var
+ group: TCapGroup;
begin
+ for group:= Low(TCapGroup) to High(TCapGroup) do
+ begin
+ FreeTexture(Captions[group].Tex);
+ end;
end;
end.
--- a/hedgewars/uChat.pas Tue Feb 01 15:30:08 2011 +0100
+++ b/hedgewars/uChat.pas Tue Feb 01 19:49:10 2011 +0100
@@ -370,7 +370,13 @@
end;
procedure freeModule;
+var i: ShortInt;
begin
+ FreeTexture(InputStr.Tex);
+ for i:= 0 to MaxStrIndex do
+ begin
+ FreeTexture(Strs[i].Tex);
+ end;
end;
end.
--- a/hedgewars/uStore.pas Tue Feb 01 15:30:08 2011 +0100
+++ b/hedgewars/uStore.pas Tue Feb 01 19:49:10 2011 +0100
@@ -329,7 +329,6 @@
InitHealth;
-// TODO: are those textures ever freed?
PauseTexture:= RenderStringTex(trmsg[sidPaused], cYellowColor, fntBig);
ConfirmTexture:= RenderStringTex(trmsg[sidConfirm], cYellowColor, fntBig);
SyncTexture:= RenderStringTex(trmsg[sidSync], cYellowColor, fntBig);
@@ -344,6 +343,8 @@
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, Str2PChar(trAmmo[NameId]), cWhiteColorChannels);
TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true);
tmpsurf:= doSurfaceConversion(tmpsurf);
+ if (NameTex <> nil) then
+ FreeTexture(NameTex);
NameTex:= Surface2Tex(tmpsurf, false);
SDL_FreeSurface(tmpsurf)
end;
@@ -353,6 +354,8 @@
begin
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels);
tmpsurf:= doSurfaceConversion(tmpsurf);
+ if (CountTexz[i] <> nil) then
+ FreeTexture(CountTexz[i]);
CountTexz[i]:= Surface2Tex(tmpsurf, false);
SDL_FreeSurface(tmpsurf)
end;
@@ -366,6 +369,8 @@
procedure StoreRelease;
var ii: TSprite;
+ ai: TAmmoType;
+ i, t: LongInt;
begin
for ii:= Low(TSprite) to High(TSprite) do
begin
@@ -378,6 +383,38 @@
SDL_FreeSurface(MissionIcons);
FreeTexture(ropeIconTex);
FreeTexture(HHTexture);
+ FreeTexture(PauseTexture);
+ FreeTexture(ConfirmTexture);
+ FreeTexture(SyncTexture);
+ // free all ammo name textures
+ for ai:= Low(TAmmoType) to High(TAmmoType) do
+ begin
+ FreeTexture(Ammoz[ai].NameTex);
+ end;
+ // free all count textures
+ for i:= Low(CountTexz) to High(CountTexz) do
+ begin
+ FreeTexture(CountTexz[i]);
+ end;
+ // free all team and hedgehog textures
+ for t:= 0 to Pred(TeamsCount) do
+ begin
+ if TeamsArray[t] <> nil then
+ begin
+ FreeTexture(TeamsArray[t]^.NameTagTex);
+ FreeTexture(TeamsArray[t]^.CrosshairTex);
+ FreeTexture(TeamsArray[t]^.GraveTex);
+ FreeTexture(TeamsArray[t]^.HealthTex);
+ FreeTexture(TeamsArray[t]^.AIKillsTex);
+ FreeTexture(TeamsArray[t]^.FlagTex);
+ for i:= 0 to cMaxHHIndex do
+ begin
+ FreeTexture(TeamsArray[t]^.Hedgehogs[i].NameTagTex);
+ FreeTexture(TeamsArray[t]^.Hedgehogs[i].HealthTagTex);
+ FreeTexture(TeamsArray[t]^.Hedgehogs[i].HatTex);
+ end;
+ end;
+ end;
{$IFNDEF S3D_DISABLED}
if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then
begin
--- a/hedgewars/uTextures.pas Tue Feb 01 15:30:08 2011 +0100
+++ b/hedgewars/uTextures.pas Tue Feb 01 19:49:10 2011 +0100
@@ -159,6 +159,8 @@
SetTextureParameters(enableClamp);
end;
+// deletes texture and frees the memory allocated for it.
+// if nil is passed nothing is done
procedure FreeTexture(tex: PTexture);
begin
if tex <> nil then
@@ -184,4 +186,4 @@
while TextureList <> nil do FreeTexture(TextureList);
end;
-end.
\ No newline at end of file
+end.
--- a/hedgewars/uWorld.pas Tue Feb 01 15:30:08 2011 +0100
+++ b/hedgewars/uWorld.pas Tue Feb 01 19:49:10 2011 +0100
@@ -1324,6 +1324,9 @@
procedure freeModule;
begin
stereoDepth:= stereoDepth; // avoid hint
+ FreeTexture(fpsTexture);
+ FreeTexture(timeTexture);
+ FreeTexture(missionTex);
end;
end.