hedgewars/uLand.pas
changeset 766 cdc8f75ab7bc
parent 760 23aaafa40b4e
child 767 697728ffe39f
--- a/hedgewars/uLand.pas	Sun Jan 27 17:04:54 2008 +0000
+++ b/hedgewars/uLand.pas	Sun Jan 27 17:27:13 2008 +0000
@@ -25,11 +25,12 @@
 
 var  Land: TLandArray;
      LandSurface: PSDL_Surface;
-     LandTexture: PTexture;
+     LandTexture: PTexture = nil;
 
 procedure GenMap;
-function GenPreview: TPreview;
+function  GenPreview: TPreview;
 procedure CheckLandDigest(s: shortstring);
+procedure UpdateLandTexture;
 
 implementation
 uses uConsole, uStore, uMisc, uRandom, uTeams, uLandObjects, uSHA, uIO;
@@ -532,7 +533,7 @@
 AddObjects(tmpsurf, LandSurface);
 SDL_FreeSurface(tmpsurf);
 
-LandTexture:= Surface2Tex(LandSurface);
+UpdateLandTexture;
 AddProgress
 end;
 
@@ -554,7 +555,7 @@
 BlitImageAndGenerateCollisionInfo(1024, 0, tmpsurf, LandSurface);
 SDL_FreeSurface(tmpsurf);
 
-LandTexture:= Surface2Tex(LandSurface)
+UpdateLandTexture
 end;
 
 procedure LoadMap;
@@ -592,7 +593,7 @@
 if SDL_MustLock(LandSurface) then
    SDL_UnlockSurface(LandSurface);
 
-LandTexture:= Surface2Tex(LandSurface)
+UpdateLandTexture
 end;
 
 procedure GenMap;
@@ -628,6 +629,12 @@
 GenPreview:= Preview
 end;
 
+procedure UpdateLandTexture;
+begin
+if LandTexture <> nil then FreeTexture(LandTexture);
+LandTexture:= Surface2Tex(LandSurface)
+end;
+
 initialization
 
 end.