This prevents girders from erasing landbacktex (square windows in tunnels and such), at the cost of requiring lfBasic and lfObject to be treated the same apart from graphically
authornemo
Fri, 30 Sep 2011 22:33:28 -0400
changeset 6077 d8fa5a85d24f
parent 6076 e1b4771f6472
child 6078 8c0cc07731e5
This prevents girders from erasing landbacktex (square windows in tunnels and such), at the cost of requiring lfBasic and lfObject to be treated the same apart from graphically
hedgewars/uConsts.pas
hedgewars/uLandGraphics.pas
--- a/hedgewars/uConsts.pas	Sat Oct 01 03:06:51 2011 +0200
+++ b/hedgewars/uConsts.pas	Fri Sep 30 22:33:28 2011 -0400
@@ -91,7 +91,7 @@
 // TODO - set lfBasic for all solid land, ensure all uses of the flags can handle multiple flag bits
     lfBasic          = $8000;  // white
     lfIndestructible = $4000;  // red
-    lfObject         = $2000;  // no idea
+    lfObject         = $2000;  // no idea - lfObject and lfBasic are only to be different *graphically*  in all other ways they should be treated the same
     lfDamaged        = $1000;  // no idea
 
     cMaxPower     = 1500;
--- a/hedgewars/uLandGraphics.pas	Sat Oct 01 03:06:51 2011 +0200
+++ b/hedgewars/uLandGraphics.pas	Fri Sep 30 22:33:28 2011 -0400
@@ -647,7 +647,7 @@
 end;
 
 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; indestructible: boolean): boolean;
-var X, Y, bpp, h, w, row, col, numFramesFirstCol: LongInt;
+var X, Y, bpp, h, w, row, col, gx, gy, numFramesFirstCol: LongInt;
     p: PByteArray;
     Image: PSDL_Surface;
 begin
@@ -702,14 +702,23 @@
             for x:= 0 to Pred(w) do
                 if PLongword(@(p^[x * 4]))^ <> 0 then
                    begin
+                   if (cReducedQuality and rqBlurryLand) = 0 then
+                       begin
+                       gX:= cpX + x;
+                       gY:= cpY + y;
+                       end
+                   else
+                       begin
+                       gX:= (cpX + x) div 2;
+                       gY:= (cpY + y) div 2;
+                       end;
                    if indestructible then
                        Land[cpY + y, cpX + x]:= lfIndestructible
+                   else if (LandPixels[gY, gX] and AMask) shr AShift = 255 then  // This test assumes lfBasic and lfObject differ only graphically
+                       Land[cpY + y, cpX + x]:= lfBasic
                    else
                        Land[cpY + y, cpX + x]:= lfObject;
-                   if (cReducedQuality and rqBlurryLand) = 0 then
-                       LandPixels[cpY + y, cpX + x]:= PLongword(@(p^[x * 4]))^
-                   else
-                       LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= PLongword(@(p^[x * 4]))^
+                   LandPixels[gY, gX]:= PLongword(@(p^[x * 4]))^
                    end;
             p:= @(p^[Image^.pitch]);
             end;