Add landbacktex to a few maps, just to see how it looks.
authornemo
Fri, 07 Oct 2011 23:57:14 -0400
changeset 6096 a00dbbf49d6c
parent 6095 332d45c08592
child 6097 db10abae541f
Add landbacktex to a few maps, just to see how it looks.
hedgewars/uGears.pas
hedgewars/uLand.pas
hedgewars/uLandGraphics.pas
share/hedgewars/Data/Maps/Battlefield/CMakeLists.txt
share/hedgewars/Data/Maps/Battlefield/mask.png
share/hedgewars/Data/Maps/Blizzard/mask.png
share/hedgewars/Data/Maps/Blox/CMakeLists.txt
share/hedgewars/Data/Maps/Blox/mask.png
share/hedgewars/Data/Maps/Cake/CMakeLists.txt
share/hedgewars/Data/Maps/Cake/mask.png
share/hedgewars/Data/Maps/Castle/CMakeLists.txt
share/hedgewars/Data/Maps/Castle/mask.png
share/hedgewars/Data/Maps/EarthRise/CMakeLists.txt
share/hedgewars/Data/Maps/EarthRise/mask.png
share/hedgewars/Data/Themes/Blox/LandBackTex.png
share/hedgewars/Data/Themes/Cake/LandBackTex.png
--- a/hedgewars/uGears.pas	Sat Oct 08 03:07:04 2011 +0200
+++ b/hedgewars/uGears.pas	Fri Oct 07 23:57:14 2011 -0400
@@ -1241,11 +1241,8 @@
     cArtillery:= true;
 
 if not hasBorder and ((Theme = 'Snow') or (Theme = 'Christmas')) then
-    begin
     for i:= 0 to Pred(vobCount*2) do
         AddGear(GetRandom(LAND_WIDTH+1024)-512, LAND_HEIGHT - GetRandom(LAND_HEIGHT div 2), gtFlake, 0, _0, _0, 0);
-    //disableLandBack:= true
-    end
 end;
 
 procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord);
--- a/hedgewars/uLand.pas	Sat Oct 08 03:07:04 2011 +0200
+++ b/hedgewars/uLand.pas	Fri Oct 07 23:57:14 2011 -0400
@@ -1142,36 +1142,50 @@
     if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps);
     end;
 
-    if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then
-    begin
-        cpX:= (LAND_WIDTH - tmpsurf^.w) div 2;
-        cpY:= LAND_HEIGHT - tmpsurf^.h;
-        if SDL_MustLock(tmpsurf) then
-            SDLTry(SDL_LockSurface(tmpsurf) >= 0, true);
+
+if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then
+begin
+    disableLandBack:= true;
 
-            p:= tmpsurf^.pixels;
-            for y:= 0 to Pred(tmpsurf^.h) do
+    cpX:= (LAND_WIDTH - tmpsurf^.w) div 2;
+    cpY:= LAND_HEIGHT - tmpsurf^.h;
+    if SDL_MustLock(tmpsurf) then
+        SDLTry(SDL_LockSurface(tmpsurf) >= 0, true);
+
+        p:= tmpsurf^.pixels;
+        for y:= 0 to Pred(tmpsurf^.h) do
+        begin
+            for x:= 0 to Pred(tmpsurf^.w) do
             begin
-                for x:= 0 to Pred(tmpsurf^.w) do
-                begin
-                    if ((AMask and p^[x]) = 0) then  // Tiy was having trouble generating transparent black
-                        Land[cpY + y, cpX + x]:= 0
-                    else if p^[x] = (AMask or RMask) then
-                        Land[cpY + y, cpX + x]:= lfIndestructible
-                    else if p^[x] = (AMask or BMask) then
-                        Land[cpY + y, cpX + x]:= lfBasic or lfIce
-                    else if p^[x] = $FFFFFFFF then
-                        Land[cpY + y, cpX + x]:= lfBasic;
-                end;
-                p:= @(p^[tmpsurf^.pitch div 4]);
+                if ((AMask and p^[x]) = 0) then
+                    Land[cpY + y, cpX + x]:= 0
+                else if p^[x] = $FFFFFFFF then
+                    Land[cpY + y, cpX + x]:= lfObject
+                else if p^[x] = (AMask or RMask) then
+                    Land[cpY + y, cpX + x]:= lfIndestructible
+                else if p^[x] = AMask then
+                    begin
+                    Land[cpY + y, cpX + x]:= lfBasic;
+                    disableLandBack:= false
+                    end
+                else if p^[x] = (AMask or BMask) then
+                    Land[cpY + y, cpX + x]:= lfObject or lfIce
             end;
+            p:= @(p^[tmpsurf^.pitch div 4]);
+        end;
 
-        if SDL_MustLock(tmpsurf) then
-            SDL_UnlockSurface(tmpsurf);
-    end;
-    if (tmpsurf <> nil) then
-        SDL_FreeSurface(tmpsurf);
-    tmpsurf:= nil;
+    if SDL_MustLock(tmpsurf) then
+        SDL_UnlockSurface(tmpsurf);
+    if not disableLandBack then
+        begin
+        // freed in freeModule() below
+        LandBackSurface:= LoadImage(UserPathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
+        if LandBackSurface = nil then LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent)
+        end;
+end;
+if (tmpsurf <> nil) then
+    SDL_FreeSurface(tmpsurf);
+tmpsurf:= nil;
 end;
 
 procedure LoadMap;
--- a/hedgewars/uLandGraphics.pas	Sat Oct 08 03:07:04 2011 +0200
+++ b/hedgewars/uLandGraphics.pas	Fri Oct 07 23:57:14 2011 -0400
@@ -180,7 +180,7 @@
 t:= y + dy;
 if (t and LAND_HEIGHT_MASK) = 0 then
     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
-        if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
+        if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
             if (cReducedQuality and rqBlurryLand) = 0 then
                 LandPixels[t, i]:= 0
             else
@@ -189,7 +189,7 @@
 t:= y - dy;
 if (t and LAND_HEIGHT_MASK) = 0 then
     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
-        if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
+        if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
             if (cReducedQuality and rqBlurryLand) = 0 then
                 LandPixels[t, i]:= 0
             else
@@ -198,7 +198,7 @@
 t:= y + dx;
 if (t and LAND_HEIGHT_MASK) = 0 then
     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
-        if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
+        if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
             if (cReducedQuality and rqBlurryLand) = 0 then
                 LandPixels[t, i]:= 0
             else
@@ -207,7 +207,7 @@
 t:= y - dx;
 if (t and LAND_HEIGHT_MASK) = 0 then
     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
-        if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
+        if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
             if (cReducedQuality and rqBlurryLand) = 0 then
                 LandPixels[t, i]:= 0
             else
@@ -223,86 +223,89 @@
 t:= y + dy;
 if (t and LAND_HEIGHT_MASK) = 0 then
    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
-       begin
-       if (cReducedQuality and rqBlurryLand) = 0 then
+       if (Land[t, i] and lfIndestructible) = 0 then
            begin
-           by:= t; bx:= i;
-           end
-       else
-           begin
-           by:= t div 2; bx:= i div 2;
+           if (cReducedQuality and rqBlurryLand) = 0 then
+               begin
+               by:= t; bx:= i;
+               end
+           else
+               begin
+               by:= t div 2; bx:= i div 2;
+               end;
+           if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then
+               begin
+               inc(cnt);
+               LandPixels[by, bx]:= LandBackPixel(i, t)
+               end
+           else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then 
+               LandPixels[by, bx]:= 0
            end;
-       if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
-           begin
-           inc(cnt);
-           LandPixels[by, bx]:= LandBackPixel(i, t)
-           end
-       else
-           if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then
-              LandPixels[by, bx]:= 0
-       end;
 
 t:= y - dy;
 if (t and LAND_HEIGHT_MASK) = 0 then
    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
-       begin
-       if (cReducedQuality and rqBlurryLand) = 0 then
+       if (Land[t, i] and lfIndestructible) = 0 then
            begin
-           by:= t; bx:= i;
-           end
-       else
-           begin
-           by:= t div 2; bx:= i div 2;
+           if (cReducedQuality and rqBlurryLand) = 0 then
+               begin
+               by:= t; bx:= i;
+               end
+           else
+               begin
+               by:= t div 2; bx:= i div 2;
+               end;
+           if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then
+               begin
+               inc(cnt);
+               LandPixels[by, bx]:= LandBackPixel(i, t)
+               end
+           else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then 
+               LandPixels[by, bx]:= 0
            end;
-       if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
-           begin
-           inc(cnt);
-           LandPixels[by, bx]:= LandBackPixel(i, t)
-           end
-       else if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then
-              LandPixels[by, bx]:= 0
-       end;
 
 t:= y + dx;
 if (t and LAND_HEIGHT_MASK) = 0 then
    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
-       begin
-       if (cReducedQuality and rqBlurryLand) = 0 then
+       if (Land[t, i] and lfIndestructible) = 0 then
            begin
-           by:= t; bx:= i;
-           end
-       else
-           begin
-           by:= t div 2; bx:= i div 2;
+           if (cReducedQuality and rqBlurryLand) = 0 then
+               begin
+               by:= t; bx:= i;
+               end
+           else
+               begin
+               by:= t div 2; bx:= i div 2;
+               end;
+           if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then
+               begin
+               inc(cnt);
+               LandPixels[by, bx]:= LandBackPixel(i, t)
+               end
+           else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then 
+               LandPixels[by, bx]:= 0
            end;
-       if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
-           begin
-           inc(cnt);
-           LandPixels[by, bx]:= LandBackPixel(i, t)
-           end
-       else if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then
-           LandPixels[by, bx]:= 0
-       end;
 t:= y - dx;
 if (t and LAND_HEIGHT_MASK) = 0 then
    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
-       begin
-       if (cReducedQuality and rqBlurryLand) = 0 then
+       if (Land[t, i] and lfIndestructible) = 0 then
            begin
-           by:= t; bx:= i;
-           end
-       else
-           begin
-           by:= t div 2; bx:= i div 2;
+           if (cReducedQuality and rqBlurryLand) = 0 then
+               begin
+               by:= t; bx:= i;
+               end
+           else
+               begin
+               by:= t div 2; bx:= i div 2;
+               end;
+           if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then
+               begin
+               inc(cnt);
+               LandPixels[by, bx]:= LandBackPixel(i, t)
+               end
+           else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then 
+               LandPixels[by, bx]:= 0
            end;
-       if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
-           begin
-           inc(cnt);
-           LandPixels[by, bx]:= LandBackPixel(i, t)
-           end
-       else if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then
-           LandPixels[by, bx]:= 0
-       end;
 FillLandCircleLinesBG:= cnt;
 end;
 
@@ -455,18 +458,21 @@
     for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do
         for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do
             begin
-            if (cReducedQuality and rqBlurryLand) = 0 then
-                begin
-                by:= ty; bx:= tx;
-                end
-            else
+            if (Land[ty, tx] and lfIndestructible) = 0 then
                 begin
-                by:= ty div 2; bx:= tx div 2;
-                end;
-            if ((Land[ty, tx] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then 
-                LandPixels[by, bx]:= LandBackPixel(tx, ty)
-            else if ((Land[ty, tx] and lfObject) <> 0) or (disableLandBack and ((Land[ty, tx] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then 
-                LandPixels[by, bx]:= 0
+                if (cReducedQuality and rqBlurryLand) = 0 then
+                    begin
+                    by:= ty; bx:= tx;
+                    end
+                else
+                    begin
+                    by:= ty div 2; bx:= tx div 2;
+                    end;
+                if ((Land[ty, tx] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then
+                    LandPixels[by, bx]:= LandBackPixel(tx, ty)
+                else if ((Land[ty, tx] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then 
+                    LandPixels[by, bx]:= 0
+                end
             end;
     inc(y, dY)
     end;
@@ -582,12 +588,10 @@
                 begin
                 by:= ty div 2; bx:= tx div 2;
                 end;
-            if ((Land[ty, tx] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
-                    LandPixels[by, bx]:= LandBackPixel(tx, ty)
-            else if ((Land[ty, tx] and lfObject) <> 0) or (disableLandBack and ((Land[ty, tx] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then
-                LandPixels[by, bx]:= 0;
-
-            Land[ty, tx]:= 0;
+            if ((Land[ty, tx] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then
+                LandPixels[by, bx]:= LandBackPixel(tx, ty)
+            else if ((Land[ty, tx] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then
+                LandPixels[by, bx]:= 0
             end
         end;
     for t:= 0 to 7 do
@@ -913,12 +917,12 @@
 
 
 // Return true if outside of land or not the value tested, used right now for some X/Y movement that does not use normal hedgehog movement in GSHandlers.inc
-function CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean;
+function CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean; inline;
 begin
      CheckLandValue:= ((X and LAND_WIDTH_MASK <> 0) or (Y and LAND_HEIGHT_MASK <> 0)) or ((Land[Y, X] and LandFlag) = 0)
 end;
 
-function LandBackPixel(x, y: LongInt): LongWord;
+function LandBackPixel(x, y: LongInt): LongWord; inline;
 var p: PLongWordArray;
 begin
     if LandBackSurface = nil then LandBackPixel:= 0
--- a/share/hedgewars/Data/Maps/Battlefield/CMakeLists.txt	Sat Oct 08 03:07:04 2011 +0200
+++ b/share/hedgewars/Data/Maps/Battlefield/CMakeLists.txt	Fri Oct 07 23:57:14 2011 -0400
@@ -1,5 +1,6 @@
 install(FILES
 	map.png
+	mask.png
 	map.cfg
 	preview.png
 	DESTINATION ${SHAREPATH}Data/Maps/Battlefield)
Binary file share/hedgewars/Data/Maps/Battlefield/mask.png has changed
Binary file share/hedgewars/Data/Maps/Blizzard/mask.png has changed
--- a/share/hedgewars/Data/Maps/Blox/CMakeLists.txt	Sat Oct 08 03:07:04 2011 +0200
+++ b/share/hedgewars/Data/Maps/Blox/CMakeLists.txt	Fri Oct 07 23:57:14 2011 -0400
@@ -1,5 +1,6 @@
 install(FILES
 	map.png
+	mask.png
 	map.cfg
 	preview.png
 	DESTINATION ${SHAREPATH}Data/Maps/Blox)
Binary file share/hedgewars/Data/Maps/Blox/mask.png has changed
--- a/share/hedgewars/Data/Maps/Cake/CMakeLists.txt	Sat Oct 08 03:07:04 2011 +0200
+++ b/share/hedgewars/Data/Maps/Cake/CMakeLists.txt	Fri Oct 07 23:57:14 2011 -0400
@@ -1,5 +1,6 @@
 install(FILES
 	map.png
+	mask.png
 	map.cfg
 	preview.png
 	DESTINATION ${SHAREPATH}Data/Maps/Cake)
Binary file share/hedgewars/Data/Maps/Cake/mask.png has changed
--- a/share/hedgewars/Data/Maps/Castle/CMakeLists.txt	Sat Oct 08 03:07:04 2011 +0200
+++ b/share/hedgewars/Data/Maps/Castle/CMakeLists.txt	Fri Oct 07 23:57:14 2011 -0400
@@ -1,5 +1,6 @@
 install(FILES
 	map.png
+	mask.png
 	map.cfg
 	preview.png
 	DESTINATION ${SHAREPATH}Data/Maps/Castle)
Binary file share/hedgewars/Data/Maps/Castle/mask.png has changed
--- a/share/hedgewars/Data/Maps/EarthRise/CMakeLists.txt	Sat Oct 08 03:07:04 2011 +0200
+++ b/share/hedgewars/Data/Maps/EarthRise/CMakeLists.txt	Fri Oct 07 23:57:14 2011 -0400
@@ -1,5 +1,6 @@
 install(FILES
 	map.png
+	mask.png
 	map.cfg
 	preview.png
 	DESTINATION ${SHAREPATH}Data/Maps/EarthRise)
Binary file share/hedgewars/Data/Maps/EarthRise/mask.png has changed
Binary file share/hedgewars/Data/Themes/Blox/LandBackTex.png has changed
Binary file share/hedgewars/Data/Themes/Cake/LandBackTex.png has changed