Changeset - r7333:94b25d4d956c
[Not reviewed]
master
0 15 0
rubidium - 17 years ago 2007-07-26 14:07:11
rubidium@openttd.org
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
15 files changed with 87 insertions and 221 deletions:
0 comments (0 inline, 0 general)
src/elrail.cpp
Show inline comments
 
@@ -270,15 +270,9 @@ static void DrawCatenaryRailway(const Ti
 
						continue; /* No neighbour, go looking for a better position */
 
					}
 

	
 
					SpriteID img = pylons_normal[temp];
 
					SpriteID pal = PAL_NONE;
 
					if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
 
						SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
 
						pal = PALETTE_TO_TRANSPARENT;
 
					}
 

	
 
					AddSortableSpriteToDraw(img, pal, x, y, 1, 1, 10,
 
							GetSlopeZ(ti->x + x_pcp_offsets[i], ti->y + y_pcp_offsets[i]));
 
					AddSortableSpriteToDraw(pylons_normal[temp], PAL_NONE, x, y, 1, 1, 10,
 
							GetSlopeZ(ti->x + x_pcp_offsets[i], ti->y + y_pcp_offsets[i]),
 
							HASBIT(_transparent_opt, TO_BUILDINGS));
 
					break; /* We already have drawn a pylon, bail out */
 
				}
 
			}
 
@@ -315,15 +309,9 @@ static void DrawCatenaryRailway(const Ti
 
			assert(!IsSteepSlope(tileh[TS_HOME]));
 
			sss = &CatenarySpriteData[Wires[tileh_selector][t][PCPconfig]];
 

	
 
			SpriteID img = sss->image;
 
			SpriteID pal = PAL_NONE;
 
			if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
 
				SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
 
				pal = PALETTE_TO_TRANSPARENT;
 
			}
 

	
 
			AddSortableSpriteToDraw(img, pal, ti->x + sss->x_offset, ti->y + sss->y_offset,
 
				sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x + min(sss->x_offset, TILE_SIZE - 1), ti->y + min(sss->y_offset, TILE_SIZE - 1)) + sss->z_offset);
 
			AddSortableSpriteToDraw(sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
 
				sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x + min(sss->x_offset, TILE_SIZE - 1), ti->y + min(sss->y_offset, TILE_SIZE - 1)) + sss->z_offset,
 
				HASBIT(_transparent_opt, TO_BUILDINGS));
 
		}
 
	}
 
}
 
@@ -354,41 +342,27 @@ static void DrawCatenaryOnBridge(const T
 

	
 
	height = GetBridgeHeight(end);
 

	
 
	SpriteID img = sss->image;
 
	SpriteID pal = PAL_NONE;
 
	if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
 
		SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
 
		pal = PALETTE_TO_TRANSPARENT;
 
	}
 

	
 
	AddSortableSpriteToDraw(img, pal, ti->x + sss->x_offset, ti->y + sss->y_offset,
 
		sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset
 
	AddSortableSpriteToDraw(sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
 
		sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset,
 
		HASBIT(_transparent_opt, TO_BUILDINGS)
 
	);
 

	
 
	/* Finished with wires, draw pylons */
 
	/* every other tile needs a pylon on the northern end */
 
	if (num % 2) {
 
		if (axis == AXIS_X) {
 
			img = pylons_bridge[0 + HASBIT(tlg, 0)];
 
			if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
 
			AddSortableSpriteToDraw(img, pal, ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height);
 
			AddSortableSpriteToDraw(pylons_bridge[0 + HASBIT(tlg, 0)], PAL_NONE, ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height, HASBIT(_transparent_opt, TO_BUILDINGS));
 
		} else {
 
			img = pylons_bridge[2 + HASBIT(tlg, 1)];
 
			if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
 
			AddSortableSpriteToDraw(img, pal, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y, 1, 1, 10, height);
 
			AddSortableSpriteToDraw(pylons_bridge[2 + HASBIT(tlg, 1)], PAL_NONE, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y, 1, 1, 10, height, HASBIT(_transparent_opt, TO_BUILDINGS));
 
		}
 
	}
 

	
 
	/* need a pylon on the southern end of the bridge */
 
	if (DistanceMax(ti->tile, start) == length) {
 
		if (axis == AXIS_X) {
 
			img = pylons_bridge[0 + HASBIT(tlg, 0)];
 
			if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
 
			AddSortableSpriteToDraw(img, pal, ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height);
 
			AddSortableSpriteToDraw(pylons_bridge[0 + HASBIT(tlg, 0)], PAL_NONE, ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height, HASBIT(_transparent_opt, TO_BUILDINGS));
 
		} else {
 
			img = pylons_bridge[2 + HASBIT(tlg, 1)];
 
			if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
 
			AddSortableSpriteToDraw(img, pal, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, height);
 
			AddSortableSpriteToDraw(pylons_bridge[2 + HASBIT(tlg, 1)], PAL_NONE, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, height, HASBIT(_transparent_opt, TO_BUILDINGS));
 
		}
 
	}
 
}
 
@@ -410,17 +384,11 @@ void DrawCatenary(const TileInfo *ti)
 
			if (IsRailDepot(ti->tile)) {
 
				const SortableSpriteStruct *sss = &CatenarySpriteData_Depot[GetRailDepotDirection(ti->tile)];
 

	
 
				SpriteID img = sss->image;
 
				SpriteID pal = PAL_NONE;
 
				if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
 
					SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
 
					pal = PALETTE_TO_TRANSPARENT;
 
				}
 

	
 
				AddSortableSpriteToDraw(
 
					img, pal, ti->x + sss->x_offset, ti->y + sss->y_offset,
 
					sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
 
					sss->x_size, sss->y_size, sss->z_size,
 
					GetTileMaxZ(ti->tile) + sss->z_offset
 
					GetTileMaxZ(ti->tile) + sss->z_offset,
 
					HASBIT(_transparent_opt, TO_BUILDINGS)
 
				);
 
				return;
 
			}
src/industry_cmd.cpp
Show inline comments
 
@@ -299,22 +299,15 @@ static void DrawTile_Industry(TileInfo *
 
	/* Add industry on top of the ground? */
 
	image = dits->building.sprite;
 
	if (image != 0) {
 
		if (HASBIT(_transparent_opt, TO_INDUSTRIES)) {
 
			SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
			pal = PALETTE_TO_TRANSPARENT;
 
		} else if (HASBIT(image, PALETTE_MODIFIER_COLOR) && dits->building.pal == PAL_NONE) {
 
			pal = GENERAL_SPRITE_COLOR(ind->random_color);
 
		} else {
 
			pal = dits->building.pal;
 
		}
 

	
 
		AddSortableSpriteToDraw(image, pal,
 
		AddSortableSpriteToDraw(image,
 
			(HASBIT(image, PALETTE_MODIFIER_COLOR) && dits->building.pal == PAL_NONE) ? GENERAL_SPRITE_COLOR(ind->random_color) : dits->building.pal,
 
			ti->x + dits->subtile_x,
 
			ti->y + dits->subtile_y,
 
			dits->width  + 1,
 
			dits->height + 1,
 
			dits->dz,
 
			z);
 
			z,
 
			HASBIT(_transparent_opt, TO_INDUSTRIES));
 

	
 
		if (HASBIT(_transparent_opt, TO_INDUSTRIES)) return;
 
	}
src/newgrf_house.cpp
Show inline comments
 
@@ -314,10 +314,7 @@ void DrawTileLayout(const TileInfo *ti, 
 
		image = dtss->image + stage;
 
		pal   = dtss->pal;
 

	
 
		if (!HASBIT(image, SPRITE_MODIFIER_OPAQUE) && HASBIT(_transparent_opt, TO_HOUSES)) {
 
			SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
			pal = PALETTE_TO_TRANSPARENT;
 
		} else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) {
 
		if ((HASBIT(image, SPRITE_MODIFIER_OPAQUE) || !HASBIT(_transparent_opt, TO_HOUSES)) && HASBIT(image, PALETTE_MODIFIER_COLOR)) {
 
			if (pal == 0) {
 
				const HouseSpec *hs = GetHouseSpecs(house_id);
 
				if (HASBIT(hs->callback_mask, CBM_BUILDING_COLOUR)) {
 
@@ -339,7 +336,8 @@ void DrawTileLayout(const TileInfo *ti, 
 
				image, pal,
 
				ti->x + dtss->delta_x, ti->y + dtss->delta_y,
 
				dtss->size_x, dtss->size_y,
 
				dtss->size_z, ti->z + dtss->delta_z
 
				dtss->size_z, ti->z + dtss->delta_z,
 
				HASBIT(_transparent_opt, TO_HOUSES)
 
			);
 
		} else {
 
			AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y);
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -166,10 +166,7 @@ void IndustryDrawTileLayout(const TileIn
 
		image = dtss->image + stage;
 
		pal   = dtss->pal;
 

	
 
		if (!HASBIT(image, SPRITE_MODIFIER_OPAQUE) && HASBIT(_transparent_opt, TO_INDUSTRIES)) {
 
			SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
			pal = PALETTE_TO_TRANSPARENT;
 
		} else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) {
 
		if (HASBIT(image, PALETTE_MODIFIER_COLOR)) {
 
			pal = GENERAL_SPRITE_COLOR(rnd_color);
 
		} else {
 
			pal = PAL_NONE;
 
@@ -180,7 +177,8 @@ void IndustryDrawTileLayout(const TileIn
 
				image, pal,
 
				ti->x + dtss->delta_x, ti->y + dtss->delta_y,
 
				dtss->size_x, dtss->size_y,
 
				dtss->size_z, ti->z + dtss->delta_z
 
				dtss->size_z, ti->z + dtss->delta_z,
 
				!HASBIT(image, SPRITE_MODIFIER_OPAQUE) && HASBIT(_transparent_opt, TO_INDUSTRIES)
 
			);
 
		} else {
 
			AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y);
src/rail_cmd.cpp
Show inline comments
 
@@ -1526,10 +1526,7 @@ default_waypoint:
 
				image += relocation;
 
			}
 

	
 
			if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
 
				SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
				pal = PALETTE_TO_TRANSPARENT;
 
			} else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) {
 
			if (!HASBIT(_transparent_opt, TO_BUILDINGS) && HASBIT(image, PALETTE_MODIFIER_COLOR)) {
 
				pal = _drawtile_track_palette;
 
			} else {
 
				pal = dtss->pal;
 
@@ -1540,7 +1537,8 @@ default_waypoint:
 
					image, pal,
 
					ti->x + dtss->delta_x, ti->y + dtss->delta_y,
 
					dtss->size_x, dtss->size_y,
 
					dtss->size_z, ti->z + dtss->delta_z
 
					dtss->size_z, ti->z + dtss->delta_z,
 
					HASBIT(_transparent_opt, TO_BUILDINGS)
 
				);
 
			} else {
 
				AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y);
src/road_cmd.cpp
Show inline comments
 
@@ -918,15 +918,8 @@ void DrawTramCatenary(TileInfo *ti, Road
 
		front = SPR_TRAMWAY_BASE + _road_frontwire_sprites_1[tram];
 
	}
 

	
 
	SpriteID pal = PAL_NONE;
 
	if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
 
		SETBIT(front, PALETTE_MODIFIER_TRANSPARENT);
 
		SETBIT(back,  PALETTE_MODIFIER_TRANSPARENT);
 
		pal = PALETTE_TO_TRANSPARENT;
 
	}
 

	
 
	AddSortableSpriteToDraw(back,  pal, ti->x, ti->y, 16, 16, 0x1F, ti->z);
 
	AddSortableSpriteToDraw(front, pal, ti->x, ti->y, 16, 16, 0x1F, ti->z);
 
	AddSortableSpriteToDraw(back,  PAL_NONE, ti->x, ti->y, 16, 16, 0x1F, ti->z, HASBIT(_transparent_opt, TO_BUILDINGS));
 
	AddSortableSpriteToDraw(front, PAL_NONE, ti->x, ti->y, 16, 16, 0x1F, ti->z, HASBIT(_transparent_opt, TO_BUILDINGS));
 
}
 

	
 
/**
 
@@ -1084,10 +1077,7 @@ static void DrawTile_Road(TileInfo *ti)
 
				SpriteID image = dtss->image;
 
				SpriteID pal;
 

	
 
				if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
 
					SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
					pal = PALETTE_TO_TRANSPARENT;
 
				} else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) {
 
				if (!HASBIT(_transparent_opt, TO_BUILDINGS) && HASBIT(image, PALETTE_MODIFIER_COLOR)) {
 
					pal = palette;
 
				} else {
 
					pal = PAL_NONE;
 
@@ -1097,7 +1087,8 @@ static void DrawTile_Road(TileInfo *ti)
 
					image, pal,
 
					ti->x + dtss->delta_x, ti->y + dtss->delta_y,
 
					dtss->size_x, dtss->size_y,
 
					dtss->size_z, ti->z
 
					dtss->size_z, ti->z,
 
					HASBIT(_transparent_opt, TO_BUILDINGS)
 
				);
 
			}
 
			break;
src/station_cmd.cpp
Show inline comments
 
@@ -2131,10 +2131,7 @@ static void DrawTile_Station(TileInfo *t
 
		}
 

	
 
		SpriteID pal;
 
		if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
 
			SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
			pal = PALETTE_TO_TRANSPARENT;
 
		} else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) {
 
		if (!HASBIT(_transparent_opt, TO_BUILDINGS) && HASBIT(image, PALETTE_MODIFIER_COLOR)) {
 
			pal = palette;
 
		} else {
 
			pal = dtss->pal;
 
@@ -2145,7 +2142,8 @@ static void DrawTile_Station(TileInfo *t
 
				image, pal,
 
				ti->x + dtss->delta_x, ti->y + dtss->delta_y,
 
				dtss->size_x, dtss->size_y,
 
				dtss->size_z, ti->z + dtss->delta_z
 
				dtss->size_z, ti->z + dtss->delta_z,
 
				HASBIT(_transparent_opt, TO_BUILDINGS)
 
			);
 
		} else {
 
			AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y);
src/town_cmd.cpp
Show inline comments
 
@@ -163,20 +163,14 @@ static void DrawTile_Town(TileInfo *ti)
 
	/* Add a house on top of the ground? */
 
	image = dcts->building.sprite;
 
	if (image != 0) {
 
		if (HASBIT(_transparent_opt, TO_HOUSES)) {
 
			SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
			pal = PALETTE_TO_TRANSPARENT;
 
		} else {
 
			pal = dcts->building.pal;
 
		}
 

	
 
		AddSortableSpriteToDraw(image, pal,
 
		AddSortableSpriteToDraw(image, dcts->building.pal,
 
			ti->x + dcts->subtile_x,
 
			ti->y + dcts->subtile_y,
 
			dcts->width + 1,
 
			dcts->height + 1,
 
			dcts->dz,
 
			ti->z
 
			ti->z,
 
			HASBIT(_transparent_opt, TO_HOUSES)
 
		);
 

	
 
		if (HASBIT(_transparent_opt, TO_HOUSES)) return;
src/tree_cmd.cpp
Show inline comments
 
@@ -374,13 +374,8 @@ static void DrawTile_Trees(TileInfo *ti)
 
		i = GetTreeCount(ti->tile) + 1;
 
		do {
 
			SpriteID image = s[0].sprite + (--i == 0 ? GetTreeGrowth(ti->tile) : 3);
 
			SpriteID pal;
 
			if (HASBIT(_transparent_opt, TO_TREES)) {
 
				SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
				pal = PALETTE_TO_TRANSPARENT;
 
			} else {
 
				pal = s[0].pal;
 
			}
 
			SpriteID pal = s[0].pal;
 

	
 
			te[i].image = image;
 
			te[i].pal   = pal;
 
			te[i].x = d->x;
 
@@ -404,7 +399,7 @@ static void DrawTile_Trees(TileInfo *ti)
 

	
 
			if (tep == NULL) break;
 

	
 
			AddSortableSpriteToDraw(tep->image, tep->pal, ti->x + tep->x, ti->y + tep->y, 5, 5, 0x10, z);
 
			AddSortableSpriteToDraw(tep->image, tep->pal, ti->x + tep->x, ti->y + tep->y, 5, 5, 0x10, z, HASBIT(_transparent_opt, TO_TREES));
 
			tep->image = 0;
 
		}
 
	}
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -831,7 +831,6 @@ static void DrawBridgePillars(const PalS
 
		int back_height, front_height;
 
		int i = z;
 
		const byte *p;
 
		SpriteID pal;
 

	
 
		static const byte _tileh_bits[4][8] = {
 
			{ 2, 1, 8, 4,  16,  2, 0, 9 },
 
@@ -840,13 +839,6 @@ static void DrawBridgePillars(const PalS
 
			{ 2, 4, 8, 1,   2, 16, 9, 0 }
 
		};
 

	
 
		if (HASBIT(_transparent_opt, TO_BRIDGES)) {
 
			SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
			pal = PALETTE_TO_TRANSPARENT;
 
		} else {
 
			pal = psid->pal;
 
		}
 

	
 
		p = _tileh_bits[(image & 1) * 2 + (axis == AXIS_X ? 0 : 1)];
 
		front_height = ti->z + (ti->tileh & p[0] ? TILE_HEIGHT : 0);
 
		back_height  = ti->z + (ti->tileh & p[1] ? TILE_HEIGHT : 0);
 
@@ -861,11 +853,11 @@ static void DrawBridgePillars(const PalS
 
			 * sprites is at the top
 
			 */
 
			if (z >= front_height) { // front facing pillar
 
				AddSortableSpriteToDraw(image, pal, x, y, p[4], p[5], 1, z);
 
				AddSortableSpriteToDraw(image, psid->pal, x, y, p[4], p[5], 1, z, HASBIT(_transparent_opt, TO_BRIDGES));
 
			}
 

	
 
			if (drawfarpillar && z >= back_height && z < i - TILE_HEIGHT) { // back facing pillar
 
				AddSortableSpriteToDraw(image, pal, x - p[6], y - p[7], p[4], p[5], 1, z);
 
				AddSortableSpriteToDraw(image, psid->pal, x - p[6], y - p[7], p[4], p[5], 1, z, HASBIT(_transparent_opt, TO_BRIDGES));
 
			}
 
		}
 
	}
 
@@ -912,18 +904,9 @@ static void DrawBridgeTramBits(int x, in
 

	
 
	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, x, y, size_x[offset], size_y[offset], offset >= 2 ? 1 : 0, z);
 

	
 
	SpriteID front = SPR_TRAMWAY_BASE + front_offsets[offset];
 
	SpriteID back  = SPR_TRAMWAY_BASE + back_offsets[offset];
 
	SpriteID pal   = PAL_NONE;
 
	if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
 
		SETBIT(front, PALETTE_MODIFIER_TRANSPARENT);
 
		SETBIT(back,  PALETTE_MODIFIER_TRANSPARENT);
 
		pal = PALETTE_TO_TRANSPARENT;
 
	}
 

	
 
	AddSortableSpriteToDraw(back,  pal, x, y, size_x[offset], size_y[offset], 0, z);
 
	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset],  PAL_NONE, x, y, size_x[offset], size_y[offset], 0, z, HASBIT(_transparent_opt, TO_BUILDINGS));
 
	/* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */
 
	AddSortableSpriteToDraw(front, pal, x, y, size_x[offset], size_y[offset], offset >= 2 ? 0x30 : 0x10, z);
 
	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + front_offsets[offset], PAL_NONE, x, y, size_x[offset], size_y[offset], offset >= 2 ? 0x30 : 0x10, z, HASBIT(_transparent_opt, TO_BUILDINGS));
 
}
 

	
 
/**
 
@@ -942,7 +925,6 @@ static void DrawBridgeTramBits(int x, in
 
static void DrawTile_TunnelBridge(TileInfo *ti)
 
{
 
	SpriteID image;
 
	SpriteID pal;
 

	
 
	if (IsTunnel(ti->tile)) {
 
		if (GetTunnelTransportType(ti->tile) == TRANSPORT_RAIL) {
 
@@ -1005,21 +987,13 @@ static void DrawTile_TunnelBridge(TileIn
 
			DrawGroundSprite(SPR_FLAT_SNOWY_TILE + _tileh_to_sprite[ti->tileh], PAL_NONE);
 
		}
 

	
 
		image = psid->sprite;
 

	
 
		/* draw ramp */
 
		if (HASBIT(_transparent_opt, TO_BRIDGES)) {
 
			SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
			pal = PALETTE_TO_TRANSPARENT;
 
		} else {
 
			pal = psid->pal;
 
		}
 

	
 
		/* HACK set the height of the BB of a sloped ramp to 1 so a vehicle on
 
		 * it doesn't disappear behind it
 
		 */
 
		AddSortableSpriteToDraw(
 
			image, pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z
 
			psid->sprite, psid->pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z, HASBIT(_transparent_opt, TO_BRIDGES)
 
		);
 

	
 
		if (GetBridgeTransportType(ti->tile) == TRANSPORT_ROAD) {
 
@@ -1082,8 +1056,6 @@ static uint CalcBridgePiece(uint north, 
 
void DrawBridgeMiddle(const TileInfo* ti)
 
{
 
	const PalSpriteID* psid;
 
	SpriteID image;
 
	SpriteID pal;
 
	uint base_offset;
 
	TileIndex rampnorth;
 
	TileIndex rampsouth;
 
@@ -1120,28 +1092,13 @@ void DrawBridgeMiddle(const TileInfo* ti
 
	uint bridge_z = GetBridgeHeight(rampsouth);
 
	z = bridge_z - 3;
 

	
 
	image = psid->sprite;
 
	if (HASBIT(_transparent_opt, TO_BRIDGES)) {
 
		SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
		pal = PALETTE_TO_TRANSPARENT;
 
	if (axis == AXIS_X) {
 
		AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 11, 1, z, HASBIT(_transparent_opt, TO_BRIDGES));
 
	} else {
 
		pal = psid->pal;
 
	}
 

	
 
	if (axis == AXIS_X) {
 
		AddSortableSpriteToDraw(image, pal, x, y, 16, 11, 1, z);
 
	} else {
 
		AddSortableSpriteToDraw(image, pal, x, y, 11, 16, 1, z);
 
		AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 11, 16, 1, z, HASBIT(_transparent_opt, TO_BRIDGES));
 
	}
 

	
 
	psid++;
 
	image = psid->sprite;
 
	if (HASBIT(_transparent_opt, TO_BRIDGES)) {
 
		SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
		pal = PALETTE_TO_TRANSPARENT;
 
	} else {
 
		pal = psid->pal;
 
	}
 

	
 
	if (GetBridgeTransportType(rampsouth) == TRANSPORT_ROAD) {
 
		RoadTypes rts = GetRoadTypes(rampsouth);
 
@@ -1156,22 +1113,21 @@ void DrawBridgeMiddle(const TileInfo* ti
 
	/* draw roof, the component of the bridge which is logically between the vehicle and the camera */
 
	if (axis == AXIS_X) {
 
		y += 12;
 
		if (image & SPRITE_MASK) AddSortableSpriteToDraw(image, pal, x, y, 16, 1, 0x28, z);
 
		if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 1, 0x28, z, HASBIT(_transparent_opt, TO_BRIDGES));
 
	} else {
 
		x += 12;
 
		if (image & SPRITE_MASK) AddSortableSpriteToDraw(image, pal, x, y, 1, 16, 0x28, z);
 
		if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 1, 16, 0x28, z, HASBIT(_transparent_opt, TO_BRIDGES));
 
	}
 

	
 
	psid++;
 
	if (ti->z + 5 == z) {
 
		/* draw poles below for small bridges */
 
		if (psid->sprite != 0) {
 
			image = psid->sprite;
 
			SpriteID image = psid->sprite;
 
			SpriteID pal   = psid->pal;
 
			if (HASBIT(_transparent_opt, TO_BRIDGES)) {
 
				SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
				pal = PALETTE_TO_TRANSPARENT;
 
			} else {
 
				pal = psid->pal;
 
			}
 

	
 
			DrawGroundSpriteAt(image, pal, x, y, z);
src/unmovable_cmd.cpp
Show inline comments
 
@@ -112,8 +112,6 @@ CommandCost CmdBuildCompanyHQ(TileIndex 
 

	
 
static void DrawTile_Unmovable(TileInfo *ti)
 
{
 
	SpriteID image;
 
	SpriteID pal;
 

	
 
	switch (GetUnmovableType(ti->tile)) {
 
		case UNMOVABLE_TRANSMITTER:
 
@@ -125,17 +123,10 @@ static void DrawTile_Unmovable(TileInfo 
 

	
 
			dtus = &_draw_tile_unmovable_data[GetUnmovableType(ti->tile)];
 

	
 
			image = dtus->image;
 
			if (HASBIT(_transparent_opt, TO_STRUCTURES)) {
 
				SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
				pal = PALETTE_TO_TRANSPARENT;
 
			} else {
 
				pal = PAL_NONE;
 
			}
 

	
 
			AddSortableSpriteToDraw(
 
				image, pal, ti->x | dtus->subcoord_x, ti->y | dtus->subcoord_y,
 
				dtus->width, dtus->height, dtus->z_size, ti->z
 
				dtus->image, PAL_NONE, ti->x | dtus->subcoord_x, ti->y | dtus->subcoord_y,
 
				dtus->width, dtus->height, dtus->z_size, ti->z,
 
				HASBIT(_transparent_opt, TO_STRUCTURES)
 
			);
 
			break;
 
		}
 
@@ -143,23 +134,14 @@ static void DrawTile_Unmovable(TileInfo 
 
		case UNMOVABLE_STATUE:
 
			DrawGroundSprite(SPR_CONCRETE_GROUND, PAL_NONE);
 

	
 
			image = SPR_STATUE_COMPANY;
 
			if (HASBIT(_transparent_opt, TO_STRUCTURES)) {
 
				SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
				pal = PALETTE_TO_TRANSPARENT;
 
			} else {
 
				pal = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
 
			}
 
			AddSortableSpriteToDraw(image, pal, ti->x, ti->y, 16, 16, 25, ti->z);
 
			AddSortableSpriteToDraw(SPR_STATUE_COMPANY, PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), ti->x, ti->y, 16, 16, 25, ti->z, HASBIT(_transparent_opt, TO_STRUCTURES));
 
			break;
 

	
 
		case UNMOVABLE_OWNED_LAND:
 
			DrawClearLandTile(ti, 0);
 

	
 
			image = SPR_BOUGHT_LAND;
 
			pal = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
 
			AddSortableSpriteToDraw(
 
				image, pal,
 
				SPR_BOUGHT_LAND, PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)),
 
				ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 10, GetSlopeZ(ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2)
 
			);
 
			DrawBridgeMiddle(ti);
 
@@ -179,18 +161,12 @@ static void DrawTile_Unmovable(TileInfo 
 
			DrawGroundSprite(t->ground_sprite, palette);
 

	
 
			foreach_draw_tile_seq(dtss, t->seq) {
 
				image = dtss->image;
 
				if (HASBIT(_transparent_opt, TO_STRUCTURES)) {
 
					SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
					pal = PALETTE_TO_TRANSPARENT;
 
				} else {
 
					pal = palette;
 
				}
 
				AddSortableSpriteToDraw(
 
					image, pal,
 
					dtss->image, palette,
 
					ti->x + dtss->delta_x, ti->y + dtss->delta_y,
 
					dtss->size_x, dtss->size_y,
 
					dtss->size_z, ti->z + dtss->delta_z
 
					dtss->size_z, ti->z + dtss->delta_z,
 
					HASBIT(_transparent_opt, TO_STRUCTURES)
 
				);
 
			}
 
			break;
src/vehicle.cpp
Show inline comments
 
@@ -852,17 +852,14 @@ static void DoDrawVehicle(const Vehicle 
 
	SpriteID image = v->cur_image;
 
	SpriteID pal;
 

	
 
	if (v->vehstatus & VS_SHADOW) {
 
		SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
		pal = PALETTE_TO_TRANSPARENT;
 
	} else if (v->vehstatus & VS_DEFPAL) {
 
	if (v->vehstatus & VS_DEFPAL) {
 
		pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
 
	} else {
 
		pal = PAL_NONE;
 
	}
 

	
 
	AddSortableSpriteToDraw(image, pal, v->x_pos + v->x_offs, v->y_pos + v->y_offs,
 
		v->sprite_width, v->sprite_height, v->z_height, v->z_pos);
 
		v->sprite_width, v->sprite_height, v->z_height, v->z_pos, v->vehstatus & VS_SHADOW);
 
}
 

	
 
void ViewportAddVehicles(DrawPixelInfo *dpi)
src/viewport.cpp
Show inline comments
 
@@ -478,8 +478,18 @@ static void AddCombinedSprite(SpriteID i
 
	AddChildSpriteScreen(image, pal, pt.x - vd->parent_list[-1]->left, pt.y - vd->parent_list[-1]->top);
 
}
 

	
 

	
 
void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, byte dz, byte z)
 
/** Draw a (transparent) sprite at given coordinates
 
 * @param image the image to combine and draw,
 
 * @param pal the provided palette,
 
 * @param x position x of the sprite,
 
 * @param y position y of the sprite,
 
 * @param w width of the sprite,
 
 * @param h height of the sprite,
 
 * @param dz delta z, difference of elevation between sprite and parent sprite,
 
 * @param z elevation of the sprite,
 
 * @param transparent if true, switch the palette between the provided palette and the transparent palette
 
 */
 
void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, byte dz, byte z, bool transparent)
 
{
 
	ViewportDrawer *vd = _cur_vd;
 
	ParentSpriteToDraw *ps;
 
@@ -488,6 +498,12 @@ void AddSortableSpriteToDraw(SpriteID im
 

	
 
	assert((image & SPRITE_MASK) < MAX_SPRITES);
 

	
 
	/* make the sprites transparent with the right palette */
 
	if (transparent) {
 
		SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
		pal = PALETTE_TO_TRANSPARENT;
 
	}
 

	
 
	if (vd->combine_sprites == 2) {
 
		AddCombinedSprite(image, pal, x, y, z);
 
		return;
src/viewport.h
Show inline comments
 
@@ -48,7 +48,7 @@ void OffsetGroundSprite(int x, int y);
 

	
 
void DrawGroundSprite(SpriteID image, SpriteID pal);
 
void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z);
 
void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, byte dz, byte z);
 
void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, byte dz, byte z, bool transparent = false);
 
void *AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2);
 
void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y);
 

	
src/water_cmd.cpp
Show inline comments
 
@@ -441,23 +441,11 @@ static void DrawWaterStuff(const TileInf
 
	DrawGroundSprite(image, PAL_NONE);
 

	
 
	for (; wdts->delta_x != 0x80; wdts++) {
 
		SpriteID image = wdts->image;
 
		SpriteID pal;
 

	
 
		if (image < 24) image += locks_base;
 
		image += base;
 

	
 
		if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
 
			SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
			pal = PALETTE_TO_TRANSPARENT;
 
		} else {
 
			pal = palette;
 
		}
 

	
 
		AddSortableSpriteToDraw(image, pal,
 
		AddSortableSpriteToDraw(wdts->image + base + ((wdts->image < 24) ? locks_base : 0), palette,
 
			ti->x + wdts->delta_x, ti->y + wdts->delta_y,
 
			wdts->width, wdts->height,
 
			wdts->unk, ti->z + wdts->delta_z);
 
			wdts->unk, ti->z + wdts->delta_z,
 
			HASBIT(_transparent_opt, TO_BUILDINGS));
 
	}
 
}
 

	
0 comments (0 inline, 0 general)