(svn r14488) -Fix: Synchronize drawing of spritelayouts in DrawTileLayout (Houses), IndustryDrawTileLayout, DrawStationTile, DrawTile_Station and DrawTile_Track (Waypoint).
authorfrosch
Sat, 18 Oct 2008 17:21:56 +0000
changeset 10257 2c37b72eec95
parent 10256 d69ddb1a8422
child 10258 a3a74c4d0917
(svn r14488) -Fix: Synchronize drawing of spritelayouts in DrawTileLayout (Houses), IndustryDrawTileLayout, DrawStationTile, DrawTile_Station and DrawTile_Track (Waypoint).
Now transparency options, PALETTE_MODIFIER_TRANSPARENT and SPRITE_MODIFIER_OPAQUE should work for all of them.
src/newgrf_house.cpp
src/newgrf_industrytiles.cpp
src/rail_cmd.cpp
src/station_cmd.cpp
--- a/src/newgrf_house.cpp	Sat Oct 18 17:20:31 2008 +0000
+++ b/src/newgrf_house.cpp	Sat Oct 18 17:21:56 2008 +0000
@@ -421,7 +421,7 @@
 	return group->g.callback.result;
 }
 
-void DrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte stage, HouseID house_id)
+static void DrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte stage, HouseID house_id)
 {
 	const DrawTileSprites *dts = group->g.layout.dts;
 	const DrawTileSeqStruct *dtss;
@@ -444,7 +444,7 @@
 
 		if (IS_CUSTOM_SPRITE(image)) image += stage;
 
-		if ((HasBit(image, SPRITE_MODIFIER_OPAQUE) || !IsTransparencySet(TO_HOUSES)) && HasBit(image, PALETTE_MODIFIER_COLOR)) {
+		if (HasBit(image, PALETTE_MODIFIER_TRANSPARENT) || HasBit(image, PALETTE_MODIFIER_COLOR)) {
 			if (pal == 0) {
 				const HouseSpec *hs = GetHouseSpecs(house_id);
 				if (HasBit(hs->callback_mask, CBM_HOUSE_COLOUR)) {
@@ -467,10 +467,11 @@
 				ti->x + dtss->delta_x, ti->y + dtss->delta_y,
 				dtss->size_x, dtss->size_y,
 				dtss->size_z, ti->z + dtss->delta_z,
-				IsTransparencySet(TO_HOUSES)
+				!HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_HOUSES)
 			);
 		} else {
-			AddChildSpriteScreen(image, pal, (byte)dtss->delta_x, (byte)dtss->delta_y, IsTransparencySet(TO_HOUSES));
+			/* For industries and houses delta_x and delta_y are unsigned */
+			AddChildSpriteScreen(image, pal, (byte)dtss->delta_x, (byte)dtss->delta_y, !HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_HOUSES));
 		}
 	}
 }
--- a/src/newgrf_industrytiles.cpp	Sat Oct 18 17:20:31 2008 +0000
+++ b/src/newgrf_industrytiles.cpp	Sat Oct 18 17:21:56 2008 +0000
@@ -167,7 +167,7 @@
 	res->grffile         = (its != NULL ? its->grf_prop.grffile : NULL);
 }
 
-void IndustryDrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte rnd_color, byte stage, IndustryGfx gfx)
+static void IndustryDrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte rnd_color, byte stage, IndustryGfx gfx)
 {
 	const DrawTileSprites *dts = group->g.layout.dts;
 	const DrawTileSeqStruct *dtss;
@@ -198,7 +198,7 @@
 
 		if (IS_CUSTOM_SPRITE(image)) image += stage;
 
-		if (HasBit(image, PALETTE_MODIFIER_COLOR)) {
+		if (HasBit(image, PALETTE_MODIFIER_TRANSPARENT) || HasBit(image, PALETTE_MODIFIER_COLOR)) {
 			if (pal == 0) {
 				pal = GENERAL_SPRITE_COLOR(rnd_color);
 			}
@@ -215,7 +215,8 @@
 				!HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_INDUSTRIES)
 			);
 		} else {
-			AddChildSpriteScreen(image, pal, (byte)dtss->delta_x, (byte)dtss->delta_y, IsTransparencySet(TO_INDUSTRIES));
+			/* For industries and houses delta_x and delta_y are unsigned */
+			AddChildSpriteScreen(image, pal, (byte)dtss->delta_x, (byte)dtss->delta_y, !HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_INDUSTRIES));
 		}
 	}
 }
--- a/src/rail_cmd.cpp	Sat Oct 18 17:20:31 2008 +0000
+++ b/src/rail_cmd.cpp	Sat Oct 18 17:21:56 2008 +0000
@@ -2014,10 +2014,14 @@
 				image += relocation;
 			}
 
-			if (!(!HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_BUILDINGS)) && HasBit(image, PALETTE_MODIFIER_COLOR)) {
-				pal = _drawtile_track_palette;
+			if (HasBit(image, PALETTE_MODIFIER_TRANSPARENT) || HasBit(image, PALETTE_MODIFIER_COLOR)) {
+				if (dtss->image.pal != 0) {
+					pal = dtss->image.pal;
+				} else {
+					pal = _drawtile_track_palette;
+				}
 			} else {
-				pal = dtss->image.pal;
+				pal = PAL_NONE;
 			}
 
 			if ((byte)dtss->delta_z != 0x80) {
@@ -2029,7 +2033,8 @@
 					!HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_BUILDINGS)
 				);
 			} else {
-				AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y);
+				/* For stations and original spritelayouts delta_x and delta_y are signed */
+				AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y, !HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_BUILDINGS));
 			}
 		}
 	}
--- a/src/station_cmd.cpp	Sat Oct 18 17:20:31 2008 +0000
+++ b/src/station_cmd.cpp	Sat Oct 18 17:21:56 2008 +0000
@@ -2344,7 +2344,8 @@
 				!HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_BUILDINGS)
 			);
 		} else {
-			AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y, IsTransparencySet(TO_BUILDINGS));
+			/* For stations and original spritelayouts delta_x and delta_y are signed */
+			AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y, !HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_BUILDINGS));
 		}
 	}
 }