station_cmd.c
changeset 3775 0fb5118536c3
parent 3771 9bce8ac706b2
child 3784 213a1a3f8697
--- a/station_cmd.c	Sun May 07 08:18:12 2006 +0000
+++ b/station_cmd.c	Sun May 07 10:58:53 2006 +0000
@@ -1986,8 +1986,6 @@
 	return &_station_display_datas[gfx];
 }
 
-extern uint16 _custom_sprites_base;
-
 static void DrawTile_Station(TileInfo *ti)
 {
 	uint32 image_or_modificator;
@@ -1996,8 +1994,9 @@
 	const DrawTileSprites *t = NULL;
 	RailType railtype = GetRailType(ti->tile);
 	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
-	SpriteID offset;
 	uint32 relocation = 0;
+	const Station *st = NULL;
+	const StationSpec *statspec = NULL;
 
 	{
 		PlayerID owner = GetTileOwner(ti->tile);
@@ -2011,8 +2010,8 @@
 
 	if (IsCustomStationSpecIndex(ti->tile)) {
 		// look for customization
-		const Station *st = GetStationByTile(ti->tile);
-		const StationSpec *statspec = st->speclist[GetCustomStationSpecIndex(ti->tile)].spec;
+		st = GetStationByTile(ti->tile);
+		statspec = st->speclist[GetCustomStationSpecIndex(ti->tile)].spec;
 
 		//debug("Cust-o-mized %p", statspec);
 
@@ -2036,12 +2035,15 @@
 	if (t == NULL || t->seq == NULL) t = &_station_display_datas[GetStationGfx(ti->tile)];
 
 	image = t->ground_sprite;
+	if (HASBIT(image, 31)) {
+		CLRBIT(image, 31);
+		image += GetCustomStationGroundRelocation(statspec, st, ti->tile);
+		image += rti->custom_ground_offset;
+	} else {
+		image += rti->total_offset;
+	}
 	if (image & PALETTE_MODIFIER_COLOR) image |= image_or_modificator;
 
-	// For custom sprites, there's no railtype-based pitching.
-	offset = (image & SPRITE_MASK) < _custom_sprites_base ? rti->total_offset : rti->custom_ground_offset;
-	image += offset;
-
 	// station_land array has been increased from 82 elements to 114
 	// but this is something else. If AI builds station with 114 it looks all weird
 	DrawGroundSprite(image);
@@ -2049,8 +2051,14 @@
 	if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
 
 	foreach_draw_tile_seq(dtss, t->seq) {
-		image = dtss->image + relocation;
-		image += offset;
+		image = dtss->image;
+		if (HASBIT(image, 30)) {
+			CLRBIT(image, 30);
+			image += rti->total_offset;
+		} else {
+			image += relocation;
+		}
+
 		if (_display_opt & DO_TRANS_BUILDINGS) {
 			MAKE_TRANSPARENT(image);
 		} else {