hedgewars/uStore.pas
changeset 4925 3d90fd7f738a
parent 4920 bc3c077e15a2
child 4933 86bd82d58a0b
--- a/hedgewars/uStore.pas	Sat Feb 05 22:22:16 2011 +0100
+++ b/hedgewars/uStore.pas	Sun Feb 06 00:47:00 2011 +0100
@@ -343,9 +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);
-        // these two lines lines crash when run multiple times?
-        //if (NameTex <> nil) then
-        //    FreeTexture(NameTex);
+        if (NameTex <> nil) then
+            FreeTexture(NameTex);
         NameTex:= Surface2Tex(tmpsurf, false);
         SDL_FreeSurface(tmpsurf)
     end;
@@ -355,9 +354,8 @@
 begin
     tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels);
     tmpsurf:= doSurfaceConversion(tmpsurf);
-    // these two lines lines crash when run multiple times?
-    //if (CountTexz[i] <> nil) then
-    //    FreeTexture(CountTexz[i]);
+    if (CountTexz[i] <> nil) then
+        FreeTexture(CountTexz[i]);
     CountTexz[i]:= Surface2Tex(tmpsurf, false);
     SDL_FreeSurface(tmpsurf)
 end;
@@ -951,6 +949,8 @@
 end;
 
 procedure initModule;
+var ai: TAmmoType;
+    i: LongInt;
 begin
     RegisterVariable('fullscr', vtCommand, @chFullScr, true);
 
@@ -966,6 +966,17 @@
     SupportNPOTT:= false;
     Step:= 0;
     ProgrTex:= nil;
+
+    // init all ammo name texture pointers
+    for ai:= Low(TAmmoType) to High(TAmmoType) do
+    begin
+        Ammoz[ai].NameTex := nil;
+    end;
+    // init all count texture pointers
+    for i:= Low(CountTexz) to High(CountTexz) do
+    begin
+        CountTexz[i] := nil;
+    end;
 end;
 
 procedure freeModule;