clear hat if load fails
authornemo
Mon, 09 Dec 2013 23:13:47 -0500
changeset 9774 65cfbf379bdf
parent 9773 d6f8b9cb729e
child 9775 2b154a2a8852
clear hat if load fails
hedgewars/uStore.pas
share/hedgewars/Data/Graphics/amRubber.png
--- a/hedgewars/uStore.pas	Mon Dec 09 23:13:17 2013 -0500
+++ b/hedgewars/uStore.pas	Mon Dec 09 23:13:47 2013 -0500
@@ -642,14 +642,18 @@
 procedure LoadHedgehogHat(var HH: THedgehog; newHat: shortstring);
 var texsurf: PSDL_Surface;
 begin
+    // free the mem of any previously assigned texture.  This was previously only if the new one could be loaded, but, NoHat is usually a better choice
+    if HH.HatTex <> nil then
+        begin
+        FreeTexture(HH.HatTex);
+        HH.HatTex:= nil
+        end;
     texsurf:= LoadDataImage(ptHats, newHat, ifNone);
 AddFileLog('Hat => '+newHat);
     // only do something if the hat could be loaded
     if texsurf <> nil then
         begin
 AddFileLog('Got Hat');
-        // free the mem of any previously assigned texture
-        FreeTexture(HH.HatTex);
 
         // assign new hat to hedgehog
         HH.HatTex:= Surface2Tex(texsurf, true);
Binary file share/hedgewars/Data/Graphics/amRubber.png has changed