640 end; |
640 end; |
641 |
641 |
642 procedure LoadHedgehogHat(var HH: THedgehog; newHat: shortstring); |
642 procedure LoadHedgehogHat(var HH: THedgehog; newHat: shortstring); |
643 var texsurf: PSDL_Surface; |
643 var texsurf: PSDL_Surface; |
644 begin |
644 begin |
|
645 // 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 |
|
646 if HH.HatTex <> nil then |
|
647 begin |
|
648 FreeTexture(HH.HatTex); |
|
649 HH.HatTex:= nil |
|
650 end; |
645 texsurf:= LoadDataImage(ptHats, newHat, ifNone); |
651 texsurf:= LoadDataImage(ptHats, newHat, ifNone); |
646 AddFileLog('Hat => '+newHat); |
652 AddFileLog('Hat => '+newHat); |
647 // only do something if the hat could be loaded |
653 // only do something if the hat could be loaded |
648 if texsurf <> nil then |
654 if texsurf <> nil then |
649 begin |
655 begin |
650 AddFileLog('Got Hat'); |
656 AddFileLog('Got Hat'); |
651 // free the mem of any previously assigned texture |
|
652 FreeTexture(HH.HatTex); |
|
653 |
657 |
654 // assign new hat to hedgehog |
658 // assign new hat to hedgehog |
655 HH.HatTex:= Surface2Tex(texsurf, true); |
659 HH.HatTex:= Surface2Tex(texsurf, true); |
656 |
660 |
657 // cleanup: free temporary surface mem |
661 // cleanup: free temporary surface mem |