rail_cmd.c
changeset 413 36afcda97345
parent 412 f0573bfb67a9
child 415 423de36034b8
--- a/rail_cmd.c	Sun Nov 14 20:25:07 2004 +0000
+++ b/rail_cmd.c	Sun Nov 14 20:50:38 2004 +0000
@@ -744,6 +744,7 @@
 
 		cp->deleted = 0;
 		cp->xy = tile;
+		cp->build_date = _date;
 
 		if (cp->town_or_string == 0) MakeDefaultWaypointName(cp); else RedrawWaypointSign(cp);
 		UpdateWaypointSign(cp);
@@ -1427,6 +1428,22 @@
 	AddSortableSpriteToDraw(image, ti->x + x, ti->y + y, xsize, ysize, zsize, ti->z + z);
 }
 
+/* This hacks together some dummy one-shot Station structure for a waypoint. */
+static Station *ComposeWaypointStation(uint tile)
+{
+	Waypoint *waypt = &_waypoints[GetWaypointByTile(tile)];
+	static Station stat;
+
+	stat.train_tile = stat.xy = waypt->xy;
+	/* FIXME - We should always keep town. */
+	stat.town = waypt->town_or_string & 0xC000 ? &_towns[waypt->town_or_string & 0xFF] : NULL;
+	stat.string_id = waypt->town_or_string & 0xC000 ? /* FIXME? */ 0 : waypt->town_or_string;
+	stat.build_date = waypt->build_date;
+	stat.class_id = 6; stat.stat_id = waypt->stat_id;
+
+	return &stat;
+}
+
 static void DrawTile_Track(TileInfo *ti)
 {
 	uint32 tracktype_offs, image;
@@ -1551,8 +1568,7 @@
 				DrawTileSeqStruct const *seq;
 				// emulate station tile - open with building
 				DrawTileSprites *cust = &stat->renderdata[2 + (m5 & 0x1)];
-				/* FIXME: NULL Station! --pasky */
-				uint32 relocation = GetCustomStationRelocation(stat, NULL, 0);
+				uint32 relocation = GetCustomStationRelocation(stat, ComposeWaypointStation(ti->tile), 0);
 
 				image = cust->ground_sprite;
 				if (image & 0x8000) image = (image & 0x7FFF) + tracktype_offs;