Step 2: painted maps loading correctly
authorunc0rr
Fri, 08 Aug 2008 19:39:22 +0000
changeset 1181 3ae244bffef9
parent 1180 e56317fdf78d
child 1182 e2e13aa055c1
Step 2: painted maps loading correctly
hedgewars/uLand.pas
hedgewars/uLandObjects.pas
--- a/hedgewars/uLand.pas	Fri Aug 08 19:34:55 2008 +0000
+++ b/hedgewars/uLand.pas	Fri Aug 08 19:39:22 2008 +0000
@@ -568,27 +568,17 @@
 procedure LoadMap;
 var x, y: Longword;
     p: PByteArray;
-    LandSurface: PSDL_Surface;
+    tmpsurf: PSDL_Surface;
 begin
 WriteLnToConsole('Loading land from file...');
 AddProgress;
-LandSurface:= LoadImage(Pathz[ptMapCurrent] + '/map', true, true, true);
-TryDo((LandSurface^.w = 2048) and (LandSurface^.h = 1024), 'Map dimensions should be 2048x1024!', true);
-
-if SDL_MustLock(LandSurface) then
-	SDLTry(SDL_LockSurface(LandSurface) >= 0, true);
-
-TryDo(LandSurface^.format^.BytesPerPixel = 4, 'Map should be 32bit', true);
+tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', true, true, true);
+TryDo((tmpsurf^.w = 2048) and (tmpsurf^.h = 1024), 'Map dimensions should be 2048x1024!', true);
 
-for y:= 0 to 1023 do
-	begin
-	for x:= 0 to 2047 do
-		if (PLongword(@(p^[x * 4]))^ and $FF000000) <> 0 then Land[y, x]:= COLOR_LAND;
-	p:= @(p^[LandSurface^.pitch]);
-	end;
+TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Map should be 32bit', true);
 
-if SDL_MustLock(LandSurface) then
-	SDL_UnlockSurface(LandSurface);
+BlitImageAndGenerateCollisionInfo(0, 0, tmpsurf);
+SDL_FreeSurface(tmpsurf);
 
 UpdateLandTexture(0, 1023)
 end;
--- a/hedgewars/uLandObjects.pas	Fri Aug 08 19:34:55 2008 +0000
+++ b/hedgewars/uLandObjects.pas	Fri Aug 08 19:39:22 2008 +0000
@@ -81,7 +81,7 @@
 for y:= 0 to Pred(Image^.h) do
 	begin
 	for x:= 0 to Pred(Image^.w) do
-		//if LandPixels[cpY + y, cpX + x] = 0 then
+		if LandPixels[cpY + y, cpX + x] = 0 then
 			begin
 			LandPixels[cpY + y, cpX + x]:= PLongword(@(p^[x * 4]))^;
 			if (PLongword(@(p^[x * 4]))^ and $FF000000) <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND;