src/station_cmd.cpp
changeset 5919 2b58160d667d
parent 5918 602e158900a2
child 5927 d740cab19ca0
equal deleted inserted replaced
5918:602e158900a2 5919:2b58160d667d
  2034 	return &_station_display_datas[gfx];
  2034 	return &_station_display_datas[gfx];
  2035 }
  2035 }
  2036 
  2036 
  2037 static void DrawTile_Station(TileInfo *ti)
  2037 static void DrawTile_Station(TileInfo *ti)
  2038 {
  2038 {
  2039 	uint32 image;
       
  2040 	const DrawTileSeqStruct *dtss;
  2039 	const DrawTileSeqStruct *dtss;
  2041 	const DrawTileSprites *t = NULL;
  2040 	const DrawTileSprites *t = NULL;
  2042 	RailType railtype = GetRailType(ti->tile);
  2041 	RailType railtype = GetRailType(ti->tile);
  2043 	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
  2042 	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
  2044 	uint32 relocation = 0;
  2043 	uint32 relocation = 0;
  2045 	const Station *st = NULL;
  2044 	const Station *st = NULL;
  2046 	const StationSpec *statspec = NULL;
  2045 	const StationSpec *statspec = NULL;
  2047 	PlayerID owner = GetTileOwner(ti->tile);
  2046 	PlayerID owner = GetTileOwner(ti->tile);
  2048 	uint32 palette;
  2047 	SpriteID image;
       
  2048 	SpriteID palette;
  2049 
  2049 
  2050 	if (IsValidPlayer(owner)) {
  2050 	if (IsValidPlayer(owner)) {
  2051 		palette = PLAYER_SPRITE_COLOR(owner);
  2051 		palette = PLAYER_SPRITE_COLOR(owner);
  2052 	} else {
  2052 	} else {
  2053 		// Some stations are not owner by a player, namely oil rigs
  2053 		// Some stations are not owner by a player, namely oil rigs
  2083 	}
  2083 	}
  2084 
  2084 
  2085 	if (t == NULL || t->seq == NULL) t = &_station_display_datas[GetStationGfx(ti->tile)];
  2085 	if (t == NULL || t->seq == NULL) t = &_station_display_datas[GetStationGfx(ti->tile)];
  2086 
  2086 
  2087 	image = t->ground_sprite;
  2087 	image = t->ground_sprite;
  2088 	if (HASBIT(image, 31)) {
  2088 	if (HASBIT(image, SPRITE_MODIFIER_USE_OFFSET)) {
  2089 		CLRBIT(image, 31);
       
  2090 		image += GetCustomStationGroundRelocation(statspec, st, ti->tile);
  2089 		image += GetCustomStationGroundRelocation(statspec, st, ti->tile);
  2091 		image += rti->custom_ground_offset;
  2090 		image += rti->custom_ground_offset;
  2092 	} else {
  2091 	} else {
  2093 		image += rti->total_offset;
  2092 		image += rti->total_offset;
  2094 	}
  2093 	}
  2095 	if (image & PALETTE_MODIFIER_COLOR) image |= palette;
       
  2096 
  2094 
  2097 	// station_land array has been increased from 82 elements to 114
  2095 	// station_land array has been increased from 82 elements to 114
  2098 	// but this is something else. If AI builds station with 114 it looks all weird
  2096 	// but this is something else. If AI builds station with 114 it looks all weird
  2099 	DrawGroundSprite(image);
  2097 	DrawGroundSprite(image, HASBIT(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE);
  2100 
  2098 
  2101 	if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti);
  2099 	if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti);
  2102 
  2100 
  2103 	foreach_draw_tile_seq(dtss, t->seq) {
  2101 	foreach_draw_tile_seq(dtss, t->seq) {
       
  2102 		SpriteID pal;
       
  2103 
  2104 		image = dtss->image;
  2104 		image = dtss->image;
  2105 		if (HASBIT(image, 30)) {
  2105 		if (HASBIT(image, SPRITE_MODIFIER_USE_OFFSET)) {
  2106 			CLRBIT(image, 30);
       
  2107 			image += rti->total_offset;
  2106 			image += rti->total_offset;
  2108 		} else {
  2107 		} else {
  2109 			image += relocation;
  2108 			image += relocation;
  2110 		}
  2109 		}
  2111 
  2110 
  2112 		if (_display_opt & DO_TRANS_BUILDINGS) {
  2111 		if (_display_opt & DO_TRANS_BUILDINGS) {
  2113 			MAKE_TRANSPARENT(image);
  2112 			SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
  2114 		} else if (image & PALETTE_MODIFIER_COLOR) {
  2113 			pal = PALETTE_TO_TRANSPARENT;
  2115 			image |= palette;
  2114 		} else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) {
       
  2115 			pal = palette;
       
  2116 		} else {
       
  2117 			pal = dtss->pal;
  2116 		}
  2118 		}
  2117 
  2119 
  2118 		if ((byte)dtss->delta_z != 0x80) {
  2120 		if ((byte)dtss->delta_z != 0x80) {
  2119 			AddSortableSpriteToDraw(
  2121 			AddSortableSpriteToDraw(
  2120 				image,
  2122 				image, pal,
  2121 				ti->x + dtss->delta_x, ti->y + dtss->delta_y,
  2123 				ti->x + dtss->delta_x, ti->y + dtss->delta_y,
  2122 				dtss->size_x, dtss->size_y,
  2124 				dtss->size_x, dtss->size_y,
  2123 				dtss->size_z, ti->z + dtss->delta_z
  2125 				dtss->size_z, ti->z + dtss->delta_z
  2124 			);
  2126 			);
  2125 		} else {
  2127 		} else {
  2126 			AddChildSpriteScreen(image, dtss->delta_x, dtss->delta_y);
  2128 			AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y);
  2127 		}
  2129 		}
  2128 	}
  2130 	}
  2129 }
  2131 }
  2130 
  2132 
  2131 void StationPickerDrawSprite(int x, int y, RailType railtype, int image)
  2133 void StationPickerDrawSprite(int x, int y, RailType railtype, int image)
  2132 {
  2134 {
  2133 	uint32 ormod, img;
  2135 	SpriteID pal, img;
  2134 	const DrawTileSeqStruct *dtss;
  2136 	const DrawTileSeqStruct *dtss;
  2135 	const DrawTileSprites *t;
  2137 	const DrawTileSprites *t;
  2136 	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
  2138 	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
  2137 
  2139 
  2138 	ormod = PLAYER_SPRITE_COLOR(_local_player);
  2140 	pal = PLAYER_SPRITE_COLOR(_local_player);
  2139 
  2141 
  2140 	t = &_station_display_datas[image];
  2142 	t = &_station_display_datas[image];
  2141 
  2143 
  2142 	img = t->ground_sprite;
  2144 	img = t->ground_sprite;
  2143 	if (img & PALETTE_MODIFIER_COLOR) img |= ormod;
  2145 	DrawSprite(img + rti->total_offset, HASBIT(img, PALETTE_MODIFIER_COLOR) ? pal : PAL_NONE, x, y);
  2144 	DrawSprite(img + rti->total_offset, x, y);
       
  2145 
  2146 
  2146 	foreach_draw_tile_seq(dtss, t->seq) {
  2147 	foreach_draw_tile_seq(dtss, t->seq) {
  2147 		Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z);
  2148 		Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z);
  2148 		DrawSprite((dtss->image | ormod) + rti->total_offset, x + pt.x, y + pt.y);
  2149 		DrawSprite(dtss->image + rti->total_offset, pal, x + pt.x, y + pt.y);
  2149 	}
  2150 	}
  2150 }
  2151 }
  2151 
  2152 
  2152 static uint GetSlopeZ_Station(TileIndex tile, uint x, uint y)
  2153 static uint GetSlopeZ_Station(TileIndex tile, uint x, uint y)
  2153 {
  2154 {