don't keep around those right-side fort files which are just mirror images of left-side forts. generate them at run-time instead. note: inlining changes and deleting files - so consider clean build/install
authorsheepluva
Mon, 13 Jul 2015 11:01:01 +0200
changeset 11006 cb06b7985261
parent 11005 71927bdb776a
child 11007 ec02f4070ef2
don't keep around those right-side fort files which are just mirror images of left-side forts. generate them at run-time instead. note: inlining changes and deleting files - so consider clean build/install
hedgewars/uLand.pas
hedgewars/uLandObjects.pas
share/hedgewars/Data/Forts/CakeR.png
share/hedgewars/Data/Forts/CastleR.png
share/hedgewars/Data/Forts/EvilChickenR.png
share/hedgewars/Data/Forts/FlowerhogR.png
share/hedgewars/Data/Forts/HydrantR.png
share/hedgewars/Data/Forts/LegoR.png
share/hedgewars/Data/Forts/PlaneR.png
share/hedgewars/Data/Forts/StatueR.png
share/hedgewars/Data/Forts/SteelTowerR.png
share/hedgewars/Data/Forts/TankR.png
share/hedgewars/Data/Forts/UFOR.png
share/hedgewars/Data/Forts/WoodR.png
--- a/hedgewars/uLand.pas	Mon Jul 13 06:19:51 2015 +0200
+++ b/hedgewars/uLand.pas	Mon Jul 13 11:01:01 2015 +0200
@@ -372,8 +372,16 @@
 BlitImageAndGenerateCollisionInfo(leftX+150, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
 SDL_FreeSurface(tmpsurf);
 
-tmpsurf:= LoadDataImage(ptForts, ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
-BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
+// not critical because if no R we can fallback to mirrored L
+tmpsurf:= LoadDataImage(ptForts, ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifTransparent or ifIgnoreCaps);
+// fallback
+if tmpsurf = nil then
+    begin
+    tmpsurf:= LoadDataImage(ptForts, ClansArray[1]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
+    BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf, 0, true);
+    end
+else
+    BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
 SDL_FreeSurface(tmpsurf);
 end;
 
--- a/hedgewars/uLandObjects.pas	Mon Jul 13 06:19:51 2015 +0200
+++ b/hedgewars/uLandObjects.pas	Mon Jul 13 11:01:01 2015 +0200
@@ -26,7 +26,8 @@
 procedure FreeLandObjects();
 procedure LoadThemeConfig;
 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface); inline;
-procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; LandFlags: Word);
+procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; LandFlags: Word); inline;
+procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; LandFlags: Word; Flip: boolean);
 procedure BlitImageUsingMask(cpX, cpY: Longword;  Image, Mask: PSDL_Surface);
 procedure AddOnLandObjects(Surface: PSDL_Surface);
 procedure SetLand(var LandWord: Word; Pixel: LongWord); inline;
@@ -92,12 +93,17 @@
 
 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface); inline;
 begin
-    BlitImageAndGenerateCollisionInfo(cpX, cpY, Width, Image, 0);
+    BlitImageAndGenerateCollisionInfo(cpX, cpY, Width, Image, 0, false);
 end;
 
-procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; LandFlags: Word);
+procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; LandFlags: Word); inline;
+begin
+    BlitImageAndGenerateCollisionInfo(cpX, cpY, Width, Image, LandFlags, false);
+end;
+
+procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; LandFlags: Word; Flip: boolean);
 var p: PLongwordArray;
-    x, y: Longword;
+    px, x, y: Longword;
     bpp: LongInt;
 begin
 WriteToConsole('Generating collision info... ');
@@ -115,21 +121,29 @@
 for y:= 0 to Pred(Image^.h) do
     begin
     for x:= 0 to Pred(Width) do
-        if (p^[x] and AMask) <> 0 then
+        begin
+        // map image pixels per line backwards if in flip mode
+        if Flip then
+            px:= Pred(Image^.w) - x
+        else
+            px:= x;
+
+        if (p^[px] and AMask) <> 0 then
             begin
             if (cReducedQuality and rqBlurryLand) = 0 then
                 begin
                 if (LandPixels[cpY + y, cpX + x] = 0)
-                or (((p^[x] and AMask) <> 0) and (((LandPixels[cpY + y, cpX + x] and AMask) shr AShift) < 255)) then
-                    LandPixels[cpY + y, cpX + x]:= p^[x];
+                or (((p^[px] and AMask) <> 0) and (((LandPixels[cpY + y, cpX + x] and AMask) shr AShift) < 255)) then
+                    LandPixels[cpY + y, cpX + x]:= p^[px];
                 end
             else
                 if LandPixels[(cpY + y) div 2, (cpX + x) div 2] = 0 then
-                    LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= p^[x];
+                    LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= p^[px];
 
-            if (Land[cpY + y, cpX + x] <= lfAllObjMask) and ((p^[x] and AMask) <> 0) then
+            if (Land[cpY + y, cpX + x] <= lfAllObjMask) and ((p^[px] and AMask) <> 0) then
                 Land[cpY + y, cpX + x]:= lfObject or LandFlags
             end;
+        end;
     p:= PLongwordArray(@(p^[Image^.pitch shr 2]))
     end;
 
Binary file share/hedgewars/Data/Forts/CakeR.png has changed
Binary file share/hedgewars/Data/Forts/CastleR.png has changed
Binary file share/hedgewars/Data/Forts/EvilChickenR.png has changed
Binary file share/hedgewars/Data/Forts/FlowerhogR.png has changed
Binary file share/hedgewars/Data/Forts/HydrantR.png has changed
Binary file share/hedgewars/Data/Forts/LegoR.png has changed
Binary file share/hedgewars/Data/Forts/PlaneR.png has changed
Binary file share/hedgewars/Data/Forts/StatueR.png has changed
Binary file share/hedgewars/Data/Forts/SteelTowerR.png has changed
Binary file share/hedgewars/Data/Forts/TankR.png has changed
Binary file share/hedgewars/Data/Forts/UFOR.png has changed
Binary file share/hedgewars/Data/Forts/WoodR.png has changed