changeset 4389:588995cd6d97 draft

(svn r6142) -Codechange: added WaypointID (sorry DV, couldn't splits it anymore) -Codechange: introduced DestinationID, which is in fact an union of several types Used in Order struct, so no longer StationID is abused for all targets. Hangars are a big exception, as they use a station-id with GOTO_DEPOT (go figure)
author truelight <truelight@openttd.org>
date Sat, 26 Aug 2006 16:34:03 +0000
parents 4ad157504539
children 495ca5f888cc
files ai/default/default.c ai/trolly/trolly.c aircraft_cmd.c aircraft_gui.c depot.c disaster_cmd.c npf.c openttd.h order.h order_cmd.c order_gui.c roadveh_cmd.c roadveh_gui.c ship_cmd.c ship_gui.c station_cmd.c train_cmd.c train_gui.c vehicle.c vehicle_gui.c waypoint.c waypoint.h yapf/yapf_destrail.hpp
diffstat 23 files changed, 172 insertions(+), 157 deletions(-) [+]
line wrap: on
line diff
--- a/ai/default/default.c
+++ b/ai/default/default.c
@@ -2453,7 +2453,7 @@
 
 		order.type = OT_GOTO_STATION;
 		order.flags = 0;
-		order.station = AiGetStationIdByDef(aib->use_tile, aib->cur_building_rule);
+		order.dest.station = AiGetStationIdByDef(aib->use_tile, aib->cur_building_rule);
 
 		if (!is_pass && i == 1) order.flags |= OF_UNLOAD;
 		if (p->ai.num_want_fullload != 0 && (is_pass || i == 0))
@@ -3185,7 +3185,7 @@
 
 		order.type = OT_GOTO_STATION;
 		order.flags = 0;
-		order.station = AiGetStationIdFromRoadBlock(aib->use_tile, aib->cur_building_rule);
+		order.dest.station = AiGetStationIdFromRoadBlock(aib->use_tile, aib->cur_building_rule);
 
 		if (!is_pass && i == 1) order.flags |= OF_UNLOAD;
 		if (p->ai.num_want_fullload != 0 && (is_pass || i == 0))
@@ -3464,7 +3464,7 @@
 
 		order.type = OT_GOTO_STATION;
 		order.flags = 0;
-		order.station = AiGetStationIdFromAircraftBlock(aib->use_tile, aib->cur_building_rule);
+		order.dest.station = AiGetStationIdFromAircraftBlock(aib->use_tile, aib->cur_building_rule);
 
 		if (!is_pass && i == 1) order.flags |= OF_UNLOAD;
 		if (p->ai.num_want_fullload != 0 && (is_pass || i == 0))
@@ -3567,7 +3567,7 @@
 	in_use = malloc(GetStationArraySize());
 	memset(in_use, 0, GetStationArraySize());
 	FOR_ALL_ORDERS(ord) {
-		if (ord->type == OT_GOTO_STATION) in_use[ord->station] = 1;
+		if (ord->type == OT_GOTO_STATION) in_use[ord->dest.station] = 1;
 	}
 
 	// Go through all stations and delete those that aren't in use
--- a/ai/trolly/trolly.c
+++ b/ai/trolly/trolly.c
@@ -555,7 +555,7 @@
 			const Order *order;
 
 			FOR_VEHICLE_ORDERS(v, order) {
-				if (order->type == OT_GOTO_STATION && GetStation(order->station) == st) {
+				if (order->type == OT_GOTO_STATION && GetStation(order->dest.station) == st) {
 					// This vehicle has this city in its list
 					count++;
 				}
@@ -1192,14 +1192,14 @@
 		idx = 0;
 		order.type = OT_GOTO_DEPOT;
 		order.flags = OF_UNLOAD;
-		order.station = GetDepotByTile(p->ainew.depot_tile)->index;
+		order.dest.depot = GetDepotByTile(p->ainew.depot_tile)->index;
 		AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
 	}
 
 	idx = 0;
 	order.type = OT_GOTO_STATION;
 	order.flags = 0;
-	order.station = GetStationIndex(p->ainew.to_tile);
+	order.dest.station = GetStationIndex(p->ainew.to_tile);
 	if (p->ainew.tbt == AI_TRUCK && p->ainew.to_deliver)
 		order.flags |= OF_FULL_LOAD;
 	AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
@@ -1207,7 +1207,7 @@
 	idx = 0;
 	order.type = OT_GOTO_STATION;
 	order.flags = 0;
-	order.station = GetStationIndex(p->ainew.from_tile);
+	order.dest.station = GetStationIndex(p->ainew.from_tile);
 	if (p->ainew.tbt == AI_TRUCK && p->ainew.from_deliver)
 		order.flags |= OF_FULL_LOAD;
 	AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -537,7 +537,7 @@
 		if (flags & DC_EXEC) {
 			v->current_order.type = OT_GOTO_DEPOT;
 			v->current_order.flags = HASBIT(p2, 16) ? 0 : OF_NON_STOP | OF_FULL_LOAD;
-			v->current_order.station = next_airport_index;
+			v->current_order.dest.station = next_airport_index;
 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 			if (HASBIT(p2, 17) || (p2 == 0 && v->u.air.state == FLYING && !next_airport_has_hangar)) {
 			// the aircraft is now heading for a different hangar than the next in the orders
@@ -650,7 +650,7 @@
 
 	if (_patches.gotodepot && VehicleHasDepotOrders(v)) return;
 
-	st = GetStation(v->current_order.station);
+	st = GetStation(v->current_order.dest.station);
 	// only goto depot if the target airport has terminals (eg. it is airport)
 	if (IsValidStation(st) && st->airport_tile != 0 && GetAirport(st->airport_type)->terminals != NULL) {
 //		printf("targetairport = %d, st->index = %d\n", v->u.air.targetairport, st->index);
@@ -1195,9 +1195,9 @@
 
 	if (order->type == OT_DUMMY && !CheckForValidOrders(v)) CrashAirplane(v);
 
-	if (order->type    == v->current_order.type   &&
-			order->flags   == v->current_order.flags  &&
-			order->station == v->current_order.station)
+	if (order->type         == v->current_order.type   &&
+			order->flags        == v->current_order.flags  &&
+			order->dest.station == v->current_order.dest.station)
 		return;
 
 	v->current_order = *order;
@@ -1205,7 +1205,7 @@
 	// orders are changed in flight, ensure going to the right station
 	if (order->type == OT_GOTO_STATION && v->u.air.state == FLYING) {
 		AircraftNextAirportPos_and_Order(v);
-		v->u.air.targetairport = order->station;
+		v->u.air.targetairport = order->dest.station;
 	}
 
 	InvalidateVehicleOrder(v);
@@ -1347,7 +1347,7 @@
 	v->current_order.flags = 0;
 
 	if (old_order.type == OT_GOTO_STATION &&
-			v->current_order.station == v->last_station_visited) {
+			v->current_order.dest.station == v->last_station_visited) {
 		v->current_order.flags =
 			(old_order.flags & (OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER)) | OF_NON_STOP;
 	}
@@ -1415,7 +1415,7 @@
 
 	if (v->current_order.type == OT_GOTO_STATION ||
 			v->current_order.type == OT_GOTO_DEPOT)
-		v->u.air.targetairport = v->current_order.station;
+		v->u.air.targetairport = v->current_order.dest.station;
 
 	st = GetStation(v->u.air.targetairport);
 	Airport = GetAirport(st->airport_type);
@@ -1487,7 +1487,7 @@
 	if (AirportHasBlock(v, &Airport->layout[v->u.air.pos], Airport)) return;
 
 	// We are already at the target airport, we need to find a terminal
-	if (v->current_order.station == v->u.air.targetairport) {
+	if (v->current_order.dest.station == v->u.air.targetairport) {
 		// FindFreeTerminal:
 		// 1. Find a free terminal, 2. Occupy it, 3. Set the vehicle's state to that terminal
 		if (v->subtype != 0) {
@@ -1539,7 +1539,7 @@
 			v->u.air.state = (v->subtype != 0) ? TAKEOFF : HELITAKEOFF;
 			break;
 		case OT_GOTO_DEPOT:   // visit hangar for serivicing, sale, etc.
-			if (v->current_order.station == v->u.air.targetairport) {
+			if (v->current_order.dest.station == v->u.air.targetairport) {
 				v->u.air.state = HANGAR;
 			} else {
 				v->u.air.state = (v->subtype != 0) ? TAKEOFF : HELITAKEOFF;
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -548,13 +548,14 @@
 		} else {
 			switch (v->current_order.type) {
 			case OT_GOTO_STATION: {
-				SetDParam(0, v->current_order.station);
+				SetDParam(0, v->current_order.dest.station);
 				SetDParam(1, v->cur_speed * 128 / 10);
 				str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;
 			} break;
 
 			case OT_GOTO_DEPOT: {
-				SetDParam(0, v->current_order.station);
+				/* Aircrafts always go to a station, even if you say depot */
+				SetDParam(0, v->current_order.dest.station);
 				SetDParam(1, v->cur_speed * 128 / 10);
 				str = STR_HEADING_FOR_HANGAR + _patches.vehicle_speed;
 			} break;
@@ -960,7 +961,7 @@
 		sel--;
 
 		if (order->type == OT_GOTO_STATION) {
-			SetDParam(0, order->station);
+			SetDParam(0, order->dest.station);
 			DrawString(x, y, STR_A036, 0);
 
 			y += 6;
--- a/depot.c
+++ b/depot.c
@@ -83,7 +83,7 @@
 	DoClearSquare(depot->xy);
 
 	/* Clear the depot from all order-lists */
-	RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, depot->index);
+	RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, (DestinationID)depot->index);
 
 	/* Delete the depot-window */
 	DeleteWindowById(WC_VEHICLE_DEPOT, depot->xy);
--- a/disaster_cmd.c
+++ b/disaster_cmd.c
@@ -101,7 +101,7 @@
 	v->u.disaster.image_override = 0;
 	v->current_order.type = OT_NOTHING;
 	v->current_order.flags = 0;
-	v->current_order.station = 0;
+	v->current_order.dest.station = 0;
 
 	DisasterVehicleUpdateImage(v);
 	VehiclePositionChanged(v);
@@ -165,7 +165,7 @@
 
 	++v->tick_counter;
 
-	if (v->current_order.station < 2) {
+	if (v->current_order.dest.disaster < 2) {
 		if (v->tick_counter&1)
 			return;
 
@@ -173,23 +173,23 @@
 
 		SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
 
-		if (v->current_order.station == 1) {
+		if (v->current_order.dest.disaster == 1) {
 			if (++v->age == 38) {
-				v->current_order.station = 2;
+				v->current_order.dest.disaster = 2;
 				v->age = 0;
 			}
 
 			if ((v->tick_counter&7)==0) {
 				CreateEffectVehicleRel(v, 0, -17, 2, EV_SMOKE);
 			}
-		} else if (v->current_order.station == 0) {
+		} else if (v->current_order.dest.disaster == 0) {
 			tile = v->tile; /**/
 
 			if (IsValidTile(tile) &&
 					IsTileType(tile, MP_STATION) &&
 					IsAirport(tile) &&
 					IS_HUMAN_PLAYER(GetTileOwner(tile))) {
-				v->current_order.station = 1;
+				v->current_order.dest.disaster = 1;
 				v->age = 0;
 
 				SetDParam(0, GetStationIndex(tile));
@@ -204,7 +204,7 @@
 		return;
 	}
 
-	if (v->current_order.station > 2) {
+	if (v->current_order.dest.disaster > 2) {
 		if (++v->age <= 13320)
 			return;
 
@@ -247,7 +247,7 @@
 				EV_EXPLOSION_SMALL);
 		}
 	} else if (v->age == 350) {
-		v->current_order.station = 3;
+		v->current_order.dest.disaster = 3;
 		v->age = 0;
 	}
 
@@ -272,7 +272,7 @@
 
 	v->u.disaster.image_override = (++v->tick_counter & 8) ? SPR_UFO_SMALL_SCOUT_DARKER : SPR_UFO_SMALL_SCOUT;
 
-	if (v->current_order.station == 0) {
+	if (v->current_order.dest.disaster == 0) {
 // fly around randomly
 		int x = TileX(v->dest_tile) * TILE_SIZE;
 		int y = TileY(v->dest_tile) * TILE_SIZE;
@@ -286,7 +286,7 @@
 			v->dest_tile = RandomTile();
 			return;
 		}
-		v->current_order.station = 1;
+		v->current_order.dest.disaster = 1;
 
 		FOR_ALL_VEHICLES(u) {
 			if (u->type == VEH_Road && IS_HUMAN_PLAYER(u->owner)) {
@@ -360,7 +360,7 @@
 
 	v->tick_counter++;
 	v->u.disaster.image_override =
-		(v->current_order.station == 1 && v->tick_counter & 4) ? SPR_F_15_FIRING : 0;
+		(v->current_order.dest.disaster == 1 && v->tick_counter & 4) ? SPR_F_15_FIRING : 0;
 
 	GetNewVehiclePos(v, &gp);
 	SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
@@ -370,7 +370,7 @@
 		return;
 	}
 
-	if (v->current_order.station == 2) {
+	if (v->current_order.dest.disaster == 2) {
 		if (!(v->tick_counter&3)) {
 			Industry *i = GetIndustry(v->dest_tile);
 			int x = TileX(i->xy) * TILE_SIZE;
@@ -384,13 +384,13 @@
 				EV_EXPLOSION_SMALL);
 
 			if (++v->age >= 55)
-				v->current_order.station = 3;
+				v->current_order.dest.disaster = 3;
 		}
-	} else if (v->current_order.station == 1) {
+	} else if (v->current_order.dest.disaster == 1) {
 		if (++v->age == 112) {
 			Industry *i;
 
-			v->current_order.station = 2;
+			v->current_order.dest.disaster = 2;
 			v->age = 0;
 
 			i = GetIndustry(v->dest_tile);
@@ -400,7 +400,7 @@
 			AddNewsItem(STR_B002_OIL_REFINERY_EXPLOSION, NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy, 0);
 			SndPlayTileFx(SND_12_EXPLOSION, i->xy);
 		}
-	} else if (v->current_order.station == 0) {
+	} else if (v->current_order.dest.disaster == 0) {
 		int x,y;
 		TileIndex tile;
 		uint ind;
@@ -419,7 +419,7 @@
 		v->dest_tile = ind;
 
 		if (GetIndustry(ind)->type == IT_OIL_REFINERY) {
-			v->current_order.station = 1;
+			v->current_order.dest.disaster = 1;
 			v->age = 0;
 		}
 	}
@@ -432,7 +432,7 @@
 
 	v->tick_counter++;
 	v->u.disaster.image_override =
-		(v->current_order.station == 1 && v->tick_counter & 4) ? SPR_AH_64A_FIRING : 0;
+		(v->current_order.dest.disaster == 1 && v->tick_counter & 4) ? SPR_AH_64A_FIRING : 0;
 
 	GetNewVehiclePos(v, &gp);
 	SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
@@ -442,7 +442,7 @@
 		return;
 	}
 
-	if (v->current_order.station == 2) {
+	if (v->current_order.dest.disaster == 2) {
 		if (!(v->tick_counter&3)) {
 			Industry *i = GetIndustry(v->dest_tile);
 			int x = TileX(i->xy) * TILE_SIZE;
@@ -456,13 +456,13 @@
 				EV_EXPLOSION_SMALL);
 
 			if (++v->age >= 55)
-				v->current_order.station = 3;
+				v->current_order.dest.disaster = 3;
 		}
-	} else if (v->current_order.station == 1) {
+	} else if (v->current_order.dest.disaster == 1) {
 		if (++v->age == 112) {
 			Industry *i;
 
-			v->current_order.station = 2;
+			v->current_order.dest.disaster = 2;
 			v->age = 0;
 
 			i = GetIndustry(v->dest_tile);
@@ -472,7 +472,7 @@
 			AddNewsItem(STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS, NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy, 0);
 			SndPlayTileFx(SND_12_EXPLOSION, i->xy);
 		}
-	} else if (v->current_order.station == 0) {
+	} else if (v->current_order.dest.disaster == 0) {
 		int x,y;
 		TileIndex tile;
 		uint ind;
@@ -491,7 +491,7 @@
 		v->dest_tile = ind;
 
 		if (GetIndustry(ind)->type == IT_FACTORY) {
-			v->current_order.station = 1;
+			v->current_order.dest.disaster = 1;
 			v->age = 0;
 		}
 	}
@@ -523,7 +523,7 @@
 
 	v->tick_counter++;
 
-	if (v->current_order.station == 1) {
+	if (v->current_order.dest.disaster == 1) {
 		int x = TileX(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2;
 		int y = TileY(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2;
 		if (abs(v->x_pos - x) + abs(v->y_pos - y) >= 8) {
@@ -540,7 +540,7 @@
 			return;
 		}
 
-		v->current_order.station = 2;
+		v->current_order.dest.disaster = 2;
 
 		FOR_ALL_VEHICLES(u) {
 			if (u->type == VEH_Train || u->type == VEH_Road) {
@@ -574,7 +574,7 @@
 		u->next = w;
 		InitializeDisasterVehicle(w, -6 * TILE_SIZE, v->y_pos, 0, DIR_SW, 12);
 		w->vehstatus |= VS_SHADOW;
-	} else if (v->current_order.station < 1) {
+	} else if (v->current_order.dest.disaster < 1) {
 
 		int x = TileX(v->dest_tile) * TILE_SIZE;
 		int y = TileY(v->dest_tile) * TILE_SIZE;
@@ -589,7 +589,7 @@
 			v->dest_tile = RandomTile();
 			return;
 		}
-		v->current_order.station = 1;
+		v->current_order.dest.disaster = 1;
 
 		tile_org = tile = RandomTile();
 		do {
@@ -624,11 +624,11 @@
 		return;
 	}
 
-	if (v->current_order.station == 0) {
+	if (v->current_order.dest.disaster == 0) {
 		u = GetVehicle(v->u.disaster.unk2);
 		if (abs(v->x_pos - u->x_pos) > TILE_SIZE)
 			return;
-		v->current_order.station = 1;
+		v->current_order.dest.disaster = 1;
 
 		CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE);
 		SndPlayVehicleFx(SND_12_EXPLOSION, u);
--- a/npf.c
+++ b/npf.c
@@ -886,9 +886,9 @@
 	 * So only for train orders to stations we fill fstd->station_index, for all
 	 * others only dest_coords */
 	if (v->current_order.type == OT_GOTO_STATION && v->type == VEH_Train) {
-		fstd->station_index = v->current_order.station;
+		fstd->station_index = v->current_order.dest.station;
 		/* Let's take the closest tile of the station as our target for trains */
-		fstd->dest_coords = CalcClosestStationTile(v->current_order.station, v->tile);
+		fstd->dest_coords = CalcClosestStationTile(v->current_order.dest.station, v->tile);
 	} else {
 		fstd->dest_coords = v->dest_tile;
 		fstd->station_index = INVALID_STATION;
--- a/openttd.h
+++ b/openttd.h
@@ -40,18 +40,33 @@
 typedef uint16 TownID;
 typedef uint16 IndustryID;
 typedef uint16 DepotID;
+typedef uint16 WaypointID;
 typedef byte PlayerID;
 typedef byte OrderID;
 typedef byte CargoID;
 typedef byte LandscapeID;
 typedef uint16 StringID;
-typedef uint32 SpriteID;    ///< The number of a sprite, without mapping bits and colortables
-typedef uint32 PalSpriteID; ///< The number of a sprite plus all the mapping bits and colortables
+typedef uint32 SpriteID;      ///< The number of a sprite, without mapping bits and colortables
+typedef uint32 PalSpriteID;   ///< The number of a sprite plus all the mapping bits and colortables
 typedef uint32 CursorID;
-typedef uint16 EngineID; ///< All enginenumbers should be of this type
+typedef uint16 EngineID;
 typedef uint16 EngineRenewID;
 typedef uint16 SignID;
-typedef uint16 UnitID;   ///< All unitnumber stuff is of this type (or anyway, should be)
+typedef uint16 UnitID;
+
+typedef union DestinationID {
+	StationID station;
+	DepotID depot;
+	WaypointID waypoint;
+	uint16 disaster;            ///< Please don't ask about it, but disasters uses orders to store stuff...
+} DestinationID;
+
+/* All items of DestionationID has to be of the same size, because some part
+ *  of the code depends on the fact that DestionationID is the same for all
+ *  items inside DestionationID. Check PackOrder() */
+assert_compile(sizeof(StationID) == sizeof(DepotID));
+assert_compile(sizeof(StationID) == sizeof(WaypointID));
+assert_compile(sizeof(StationID) == sizeof(uint16));
 
 typedef uint32 WindowNumber;
 typedef byte WindowClass;
--- a/order.h
+++ b/order.h
@@ -70,7 +70,6 @@
 	CO_UNSHARE = 2
 };
 
-
 /* If you change this, keep in mind that it is saved on 3 places:
  * - Load_ORDR, all the global orders
  * - Vehicle -> current_order
@@ -79,7 +78,7 @@
 typedef struct Order {
 	OrderType type;
 	uint8  flags;
-	StationID station;
+	DestinationID dest;   ///< The destionation of the order.
 
 	struct Order *next;   ///< Pointer to next order. If NULL, end of list
 
@@ -172,7 +171,7 @@
 
 static inline uint32 PackOrder(const Order *order)
 {
-	return order->station << 16 | order->flags << 8 | order->type;
+	return order->dest.station << 16 | order->flags << 8 | order->type;
 }
 
 static inline Order UnpackOrder(uint32 packed)
@@ -180,7 +179,7 @@
 	Order order;
 	order.type    = (OrderType)GB(packed,  0,  8);
 	order.flags   = GB(packed,  8,  8);
-	order.station = GB(packed, 16, 16);
+	order.dest.station = GB(packed, 16, 16);
 	order.next    = NULL;
 	order.index   = 0; // avoid compiler warning
 	return order;
@@ -189,7 +188,7 @@
 /* Functions */
 void BackupVehicleOrders(const Vehicle *v, BackuppedOrders *order);
 void RestoreVehicleOrders(const Vehicle* v, const BackuppedOrders* order);
-void RemoveOrderFromAllVehicles(OrderType type, StationID destination);
+void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination);
 void InvalidateVehicleOrder(const Vehicle *v);
 bool VehicleHasDepotOrders(const Vehicle *v);
 void CheckOrders(const Vehicle*);
--- a/order_cmd.c
+++ b/order_cmd.c
@@ -47,12 +47,12 @@
 	Order order;
 	order.type    = GB(packed, 0, 4);
 	order.flags   = GB(packed, 4, 4);
-	order.station = GB(packed, 8, 8);
+	order.dest.station = GB(packed, 8, 8);
 	order.next    = NULL;
 
 	// Sanity check
 	// TTD stores invalid orders as OT_NOTHING with non-zero flags/station
-	if (order.type == OT_NOTHING && (order.flags != 0 || order.station != 0)) {
+	if (order.type == OT_NOTHING && (order.flags != 0 || order.dest.station != 0)) {
 		order.type = OT_DUMMY;
 		order.flags = 0;
 	}
@@ -70,7 +70,7 @@
 	Order order;
 	order.type    = GB(packed, 0, 4);
 	order.flags   = GB(packed, 4, 4);
-	order.station = GB(packed, 8, 8);
+	order.dest.station = GB(packed, 8, 8);
 	order.next    = NULL;
 	order.index   = 0; // avoid compiler warning
 	return order;
@@ -144,7 +144,7 @@
 {
 	order->type    = data.type;
 	order->flags   = data.flags;
-	order->station = data.station;
+	order->dest.station = data.dest.station;
 }
 
 
@@ -191,8 +191,8 @@
 		case OT_GOTO_STATION: {
 			const Station *st;
 
-			if (!IsValidStationID(new_order.station)) return CMD_ERROR;
-			st = GetStation(new_order.station);
+			if (!IsValidStationID(new_order.dest.station)) return CMD_ERROR;
+			st = GetStation(new_order.dest.station);
 
 			if (st->airport_type != AT_OILRIG && !IsBuoy(st) && !CheckOwnership(st->owner)) {
 				return CMD_ERROR;
@@ -252,8 +252,8 @@
 			if (v->type == VEH_Aircraft) {
 				const Station* st;
 
-				if (!IsValidStationID(new_order.station)) return CMD_ERROR;
-				st = GetStation(new_order.station);
+				if (!IsValidStationID(new_order.dest.station)) return CMD_ERROR;
+				st = GetStation(new_order.dest.station);
 
 				if ((st->airport_type != AT_OILRIG && !CheckOwnership(st->owner)) ||
 						!(st->facilities & FACIL_AIRPORT) ||
@@ -263,8 +263,8 @@
 			} else {
 				const Depot* dp;
 
-				if (!IsValidDepotID(new_order.station)) return CMD_ERROR;
-				dp = GetDepot(new_order.station);
+				if (!IsValidDepotID(new_order.dest.depot)) return CMD_ERROR;
+				dp = GetDepot(new_order.dest.depot);
 
 				if (!CheckOwnership(GetTileOwner(dp->xy))) return CMD_ERROR;
 
@@ -308,8 +308,8 @@
 
 			if (v->type != VEH_Train) return CMD_ERROR;
 
-			if (!IsValidWaypointID(new_order.station)) return CMD_ERROR;
-			wp = GetWaypoint(new_order.station);
+			if (!IsValidWaypointID(new_order.dest.waypoint)) return CMD_ERROR;
+			wp = GetWaypoint(new_order.dest.waypoint);
 
 			if (!CheckOwnership(GetTileOwner(wp->xy))) return CMD_ERROR;
 
@@ -346,8 +346,8 @@
 		&& !_patches.new_pathfinding_all) {
 
 		int dist = DistanceManhattan(
-			GetStation(GetVehicleOrder(v, sel_ord - 1)->station)->xy,
-			GetStation(new_order.station)->xy // XXX type != OT_GOTO_STATION?
+			GetStation(GetVehicleOrder(v, sel_ord - 1)->dest.station)->xy,
+			GetStation(new_order.dest.station)->xy // XXX type != OT_GOTO_STATION?
 		);
 		if (dist >= 130)
 			return_cmd_error(STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO);
@@ -704,7 +704,7 @@
 
 				FOR_VEHICLE_ORDERS(src, order) {
 					if (order->type == OT_GOTO_STATION) {
-						const Station *st = GetStation(order->station);
+						const Station *st = GetStation(order->dest.station);
 						if (dst->cargo_type == CT_PASSENGERS) {
 							if (st->bus_stops != NULL) required_dst = st->bus_stops->xy;
 						} else {
@@ -919,7 +919,7 @@
 			}
 			/* Does station have a load-bay for this vehicle? */
 			if (order->type == OT_GOTO_STATION) {
-				const Station* st = GetStation(order->station);
+				const Station* st = GetStation(order->dest.station);
 				TileIndex required_tile = GetStationTileForVehicle(v, st);
 
 				n_st++;
@@ -933,7 +933,7 @@
 
 			if (v->orders->type    == last->type &&
 					v->orders->flags   == last->flags &&
-					v->orders->station == last->station) {
+					v->orders->dest.station == last->dest.station) {
 				problem_type = 2;
 			}
 		}
@@ -962,7 +962,7 @@
  * @param type The type of the order (OT_GOTO_[STATION|DEPOT|WAYPOINT]).
  * @param destination The destination. Can be a StationID, DepotID or WaypointID.
  */
-void RemoveOrderFromAllVehicles(OrderType type, StationID destination)
+void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
 {
 	Vehicle *v;
 	Order *order;
@@ -973,11 +973,11 @@
 		if (v->orders == NULL) continue;
 
 		/* Forget about this station if this station is removed */
-		if (v->last_station_visited == destination && type == OT_GOTO_STATION)
+		if (v->last_station_visited == destination.station && type == OT_GOTO_STATION)
 			v->last_station_visited = INVALID_STATION;
 
 		/* Check the current order */
-		if (v->current_order.type == type && v->current_order.station == destination) {
+		if (v->current_order.type == type && v->current_order.dest.station == destination.station) {
 			/* Mark the order as DUMMY */
 			v->current_order.type = OT_DUMMY;
 			v->current_order.flags = 0;
@@ -987,7 +987,7 @@
 		/* Clear the order from the order-list */
 		need_invalidate = false;
 		FOR_VEHICLE_ORDERS(v, order) {
-			if (order->type == type && order->station == destination) {
+			if (order->type == type && order->dest.station == destination.station) {
 				/* Mark the order as DUMMY */
 				order->type = OT_DUMMY;
 				order->flags = 0;
@@ -1112,7 +1112,7 @@
 static const SaveLoad _order_desc[] = {
 	SLE_VAR(Order, type,    SLE_UINT8),
 	SLE_VAR(Order, flags,   SLE_UINT8),
-	SLE_VAR(Order, station, SLE_UINT16),
+	SLE_VAR(Order, dest.station, SLE_UINT16), // Saving one of the union is enough, they all share the same memory
 	SLE_REF(Order, next,    REF_ORDER),
 
 	// reserve extra space in savegame here. (currently 10 bytes)
--- a/order_gui.c
+++ b/order_gui.c
@@ -134,7 +134,7 @@
 			switch (order->type) {
 				case OT_GOTO_STATION:
 					SetDParam(1, StationOrderStrings[order->flags]);
-					SetDParam(2, order->station);
+					SetDParam(2, order->dest.station);
 					break;
 
 				case OT_GOTO_DEPOT: {
@@ -142,9 +142,9 @@
 
 					if (v->type == VEH_Aircraft) {
 						s = STR_GO_TO_AIRPORT_HANGAR;
-						SetDParam(2, order->station);
+						SetDParam(2, order->dest.depot);
 					} else {
-						SetDParam(2, GetDepot(order->station)->town_index);
+						SetDParam(2, GetDepot(order->dest.depot)->town_index);
 
 						switch (v->type) {
 							case VEH_Train: s = (order->flags & OF_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
@@ -162,7 +162,7 @@
 
 				case OT_GOTO_WAYPOINT:
 					SetDParam(1, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
-					SetDParam(2, order->station);
+					SetDParam(2, order->dest.waypoint);
 					break;
 
 				default: break;
@@ -174,7 +174,7 @@
 				DrawString(2, y, str, color);
 			} else {
 				SetDParam(1, STR_INVALID_ORDER);
-				SetDParam(2, order->station);
+				SetDParam(2, order->dest.station);
 				DrawString(2, y, str, color);
 			}
 			y += 10;
@@ -205,7 +205,7 @@
 				if (IsRailDepot(tile)) {
 					order.type = OT_GOTO_DEPOT;
 					order.flags = OF_PART_OF_ORDERS;
-					order.station = GetDepotByTile(tile)->index;
+					order.dest.depot = GetDepotByTile(tile)->index;
 					return order;
 				}
 			}
@@ -215,7 +215,7 @@
 			if (GetRoadTileType(tile) == ROAD_TILE_DEPOT && v->type == VEH_Road && IsTileOwner(tile, _local_player)) {
 				order.type = OT_GOTO_DEPOT;
 				order.flags = OF_PART_OF_ORDERS;
-				order.station = GetDepotByTile(tile)->index;
+				order.dest.depot = GetDepotByTile(tile)->index;
 				return order;
 			}
 			break;
@@ -225,7 +225,7 @@
 			if (IsHangar(tile) && IsTileOwner(tile, _local_player)) {
 				order.type = OT_GOTO_DEPOT;
 				order.flags = OF_PART_OF_ORDERS;
-				order.station = GetStationIndex(tile);
+				order.dest.station = GetStationIndex(tile);
 				return order;
 			}
 			break;
@@ -238,7 +238,7 @@
 
 				order.type = OT_GOTO_DEPOT;
 				order.flags = OF_PART_OF_ORDERS;
-				order.station = GetDepotByTile(tile < tile2 ? tile : tile2)->index;
+				order.dest.depot = GetDepotByTile(tile < tile2 ? tile : tile2)->index;
 				return order;
 			}
 
@@ -254,7 +254,7 @@
 			IsRailWaypoint(tile)) {
 		order.type = OT_GOTO_WAYPOINT;
 		order.flags = 0;
-		order.station = GetWaypointByTile(tile)->index;
+		order.dest.waypoint = GetWaypointByTile(tile)->index;
 		return order;
 	}
 
@@ -272,7 +272,7 @@
 			if (st->facilities & facil) {
 				order.type = OT_GOTO_STATION;
 				order.flags = 0;
-				order.station = st_index;
+				order.dest.station = st_index;
 				return order;
 			}
 		}
@@ -281,7 +281,7 @@
 	// not found
 	order.type = OT_NOTHING;
 	order.flags = 0;
-	order.station = INVALID_STATION;
+	order.dest.station = INVALID_STATION;
 	return order;
 }
 
@@ -410,9 +410,9 @@
 				TileIndex xy;
 
 				switch (ord->type) {
-					case OT_GOTO_STATION:  xy = GetStation(ord->station)->xy ; break;
-					case OT_GOTO_DEPOT:    xy = GetDepot(ord->station)->xy;    break;
-					case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->station)->xy; break;
+					case OT_GOTO_STATION:  xy = GetStation(ord->dest.station)->xy ; break;
+					case OT_GOTO_DEPOT:    xy = GetDepot(ord->dest.depot)->xy;    break;
+					case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->dest.waypoint)->xy; break;
 					default:               xy = 0; break;
 				}
 
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -394,7 +394,7 @@
 		ClearSlot(v);
 		v->current_order.type = OT_GOTO_DEPOT;
 		v->current_order.flags = OF_NON_STOP | OF_HALT_IN_DEPOT;
-		v->current_order.station = dep->index;
+		v->current_order.dest.depot = dep->index;
 		v->dest_tile = dep->xy;
 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 	}
@@ -649,7 +649,7 @@
 
 	if (order->type    == v->current_order.type &&
 			order->flags   == v->current_order.flags &&
-			order->station == v->current_order.station) {
+			order->dest.station == v->current_order.dest.station) {
 		return;
 	}
 
@@ -659,12 +659,12 @@
 		case OT_GOTO_STATION: {
 			const RoadStop* rs;
 
-			if (order->station == v->last_station_visited) {
+			if (order->dest.station == v->last_station_visited) {
 				v->last_station_visited = INVALID_STATION;
 			}
 
 			rs = GetPrimaryRoadStop(
-				GetStation(order->station),
+				GetStation(order->dest.station),
 				v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK
 			);
 
@@ -690,7 +690,7 @@
 		}
 
 		case OT_GOTO_DEPOT:
-			v->dest_tile = GetDepot(order->station)->xy;
+			v->dest_tile = GetDepot(order->dest.depot)->xy;
 			break;
 
 		default:
@@ -1478,7 +1478,7 @@
 			v->current_order.flags = 0;
 
 			if (old_order.type == OT_GOTO_STATION &&
-					v->current_order.station == v->last_station_visited) {
+					v->current_order.dest.station == v->last_station_visited) {
 				v->current_order.flags =
 					(old_order.flags & (OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER)) | OF_NON_STOP;
 			}
@@ -1520,9 +1520,9 @@
 			if (v->current_order.type != OT_GOTO_STATION) {
 				DEBUG(ms, 0) ("Multistop: -- Current order type (%d) is not OT_GOTO_STATION.", v->current_order.type);
 			} else {
-				if (v->current_order.station != st->index)
+				if (v->current_order.dest.station != st->index)
 					DEBUG(ms, 0) ("Multistop: -- Current station %d is not target station in current_order.station (%d).",
-							st->index, v->current_order.station);
+							st->index, v->current_order.dest.station);
 			}
 
 			DEBUG(ms, 0) ("           -- Force a slot clearing.");
@@ -1637,7 +1637,7 @@
 
 	v->current_order.type = OT_GOTO_DEPOT;
 	v->current_order.flags = OF_NON_STOP;
-	v->current_order.station = depot->index;
+	v->current_order.dest.depot = depot->index;
 	v->dest_tile = depot->xy;
 	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 }
@@ -1665,7 +1665,7 @@
 
 	/* update destination */
 	if (v->current_order.type == OT_GOTO_STATION && v->u.road.slot == NULL && !(v->vehstatus & VS_CRASHED)) {
-		Station* st = GetStation(v->current_order.station);
+		Station* st = GetStation(v->current_order.dest.station);
 		RoadStop* rs = GetPrimaryRoadStop(st, v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK);
 		RoadStop* best = NULL;
 
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -334,13 +334,13 @@
 		} else {
 			switch (v->current_order.type) {
 			case OT_GOTO_STATION: {
-				SetDParam(0, v->current_order.station);
+				SetDParam(0, v->current_order.dest.station);
 				SetDParam(1, v->cur_speed / 2);
 				str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;
 			} break;
 
 			case OT_GOTO_DEPOT: {
-				Depot *depot = GetDepot(v->current_order.station);
+				Depot *depot = GetDepot(v->current_order.dest.depot);
 				SetDParam(0, depot->town_index);
 				SetDParam(1, v->cur_speed / 2);
 				str = STR_HEADING_FOR_ROAD_DEPOT + _patches.vehicle_speed;
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -125,7 +125,7 @@
 
 	v->current_order.type = OT_GOTO_DEPOT;
 	v->current_order.flags = OF_NON_STOP;
-	v->current_order.station = depot->index;
+	v->current_order.dest.depot = depot->index;
 	v->dest_tile = depot->xy;
 	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 }
@@ -229,7 +229,7 @@
 
 	if (order->type    == v->current_order.type &&
 			order->flags   == v->current_order.flags &&
-			order->station == v->current_order.station)
+			order->dest.station == v->current_order.dest.station)
 		return;
 
 	v->current_order = *order;
@@ -237,15 +237,15 @@
 	if (order->type == OT_GOTO_STATION) {
 		const Station *st;
 
-		if (order->station == v->last_station_visited)
+		if (order->dest.station == v->last_station_visited)
 			v->last_station_visited = INVALID_STATION;
 
-		st = GetStation(order->station);
+		st = GetStation(order->dest.station);
 		if (st->dock_tile != 0) {
 			v->dest_tile = TILE_ADD(st->dock_tile, ToTileIndexDiff(GetDockOffset(st->dock_tile)));
 		}
 	} else if (order->type == OT_GOTO_DEPOT) {
-		v->dest_tile = GetDepot(order->station)->xy;
+		v->dest_tile = GetDepot(order->dest.depot)->xy;
 	} else {
 		v->dest_tile = 0;
 	}
@@ -722,10 +722,10 @@
 						} else if (v->current_order.type == OT_GOTO_STATION) {
 							Station *st;
 
-							v->last_station_visited = v->current_order.station;
+							v->last_station_visited = v->current_order.dest.station;
 
 							/* Process station in the orderlist. */
-							st = GetStation(v->current_order.station);
+							st = GetStation(v->current_order.dest.station);
 							if (st->facilities & FACIL_DOCK) { /* ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations */
 								v->current_order.type = OT_LOADING;
 								v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER;
@@ -1033,7 +1033,7 @@
 		v->dest_tile = dep->xy;
 		v->current_order.type = OT_GOTO_DEPOT;
 		v->current_order.flags = OF_NON_STOP | OF_HALT_IN_DEPOT;
-		v->current_order.station = dep->index;
+		v->current_order.dest.depot = dep->index;
 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 	}
 
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -481,13 +481,13 @@
 			} else {
 				switch (v->current_order.type) {
 					case OT_GOTO_STATION: {
-						SetDParam(0, v->current_order.station);
+						SetDParam(0, v->current_order.dest.station);
 						SetDParam(1, v->cur_speed / 2);
 						str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;
 					} break;
 
 					case OT_GOTO_DEPOT: {
-						Depot *depot = GetDepot(v->current_order.station);
+						Depot *depot = GetDepot(v->current_order.dest.depot);
 						SetDParam(0, depot->town_index);
 						SetDParam(1, v->cur_speed / 2);
 						str = STR_HEADING_FOR_SHIP_DEPOT + _patches.vehicle_speed;
@@ -906,8 +906,8 @@
 		sel--;
 
 		if (order->type == OT_GOTO_STATION) {
-			if (!IsBuoy(GetStation(order->station))){
-				SetDParam(0, order->station);
+			if (!IsBuoy(GetStation(order->dest.station))){
+				SetDParam(0, order->dest.station);
 				DrawString(x, y, STR_A036, 0);
 
 				y += 6;
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -1863,7 +1863,7 @@
 		if (v->type == VEH_Ship) {
 			const Order *order;
 			FOR_VEHICLE_ORDERS(v, order) {
-				if (order->type == OT_GOTO_STATION && order->station == st->index) {
+				if (order->type == OT_GOTO_STATION && order->dest.station == st->index) {
 					return true;
 				}
 			}
@@ -2333,7 +2333,7 @@
 			StationID station_id = GetStationIndex(tile);
 
 			if ((!(v->current_order.flags & OF_NON_STOP) && !_patches.new_nonstop) ||
-					(v->current_order.type == OT_GOTO_STATION && v->current_order.station == station_id)) {
+					(v->current_order.type == OT_GOTO_STATION && v->current_order.dest.station == station_id)) {
 				if (!(_patches.new_nonstop && v->current_order.flags & OF_NON_STOP) &&
 						v->current_order.type != OT_LEAVESTATION &&
 						v->last_station_visited != station_id) {
@@ -2412,7 +2412,7 @@
 	DeleteWindowById(WC_STATION_VIEW, index);
 
 	/* Now delete all orders that go to the station */
-	RemoveOrderFromAllVehicles(OT_GOTO_STATION, index);
+	RemoveOrderFromAllVehicles(OT_GOTO_STATION, (DestinationID)index);
 
 	//And do the same with aircraft that have the station as a hangar-stop
 	FOR_ALL_VEHICLES(v) {
@@ -2420,7 +2420,7 @@
 		if (v->type == VEH_Aircraft) {
 			Order *order;
 			FOR_VEHICLE_ORDERS(v, order) {
-				if (order->type == OT_GOTO_DEPOT && order->station == index) {
+				if (order->type == OT_GOTO_DEPOT && order->dest.station == index) {
 					order->type = OT_DUMMY;
 					order->flags = 0;
 					invalidate = true;
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -254,13 +254,13 @@
 	assert(v->type == VEH_Train);
 	//When does a train drive through a station
 	//first we deal with the "new nonstop handling"
-	if (_patches.new_nonstop && o->flags & OF_NON_STOP && sid == o->station) {
+	if (_patches.new_nonstop && o->flags & OF_NON_STOP && sid == o->dest.station) {
 		return false;
 	}
 
 	if (v->last_station_visited == sid) return false;
 
-	if (sid != o->station && (o->flags & OF_NON_STOP || _patches.new_nonstop)) {
+	if (sid != o->dest.station && (o->flags & OF_NON_STOP || _patches.new_nonstop)) {
 		return false;
 	}
 
@@ -1960,7 +1960,7 @@
 		v->dest_tile = tfdd.tile;
 		v->current_order.type = OT_GOTO_DEPOT;
 		v->current_order.flags = OF_NON_STOP | OF_FULL_LOAD;
-		v->current_order.station = GetDepotByTile(tfdd.tile)->index;
+		v->current_order.dest.depot = GetDepotByTile(tfdd.tile)->index;
 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		/* If there is no depot in front, reverse automatically */
 		if (tfdd.reverse)
@@ -2164,7 +2164,7 @@
 {
 	fd->dest_coords = v->dest_tile;
 	if (v->current_order.type == OT_GOTO_STATION) {
-		fd->station_index = v->current_order.station;
+		fd->station_index = v->current_order.dest.station;
 	} else {
 		fd->station_index = INVALID_STATION;
 	}
@@ -2411,7 +2411,7 @@
 	if (_patches.new_nonstop &&
 			v->current_order.flags & OF_NON_STOP &&
 			IsTileType(v->tile, MP_STATION) &&
-			v->current_order.station == GetStationIndex(v->tile)) {
+			v->current_order.dest.station == GetStationIndex(v->tile)) {
 		v->cur_order_index++;
 	}
 
@@ -2431,7 +2431,7 @@
 	// If it is unchanged, keep it.
 	if (order->type    == v->current_order.type &&
 			order->flags   == v->current_order.flags &&
-			order->station == v->current_order.station)
+			order->dest.station == v->current_order.dest.station)
 		return false;
 
 	// Otherwise set it, and determine the destination tile.
@@ -2443,17 +2443,17 @@
 
 	switch (order->type) {
 		case OT_GOTO_STATION:
-			if (order->station == v->last_station_visited)
+			if (order->dest.station == v->last_station_visited)
 				v->last_station_visited = INVALID_STATION;
-			v->dest_tile = GetStation(order->station)->xy;
+			v->dest_tile = GetStation(order->dest.station)->xy;
 			break;
 
 		case OT_GOTO_DEPOT:
-			v->dest_tile = GetDepot(order->station)->xy;
+			v->dest_tile = GetDepot(order->dest.depot)->xy;
 			break;
 
 		case OT_GOTO_WAYPOINT:
-			v->dest_tile = GetWaypoint(order->station)->xy;
+			v->dest_tile = GetWaypoint(order->dest.waypoint)->xy;
 			break;
 
 		default:
@@ -2574,7 +2574,7 @@
 
 	// Did we reach the final destination?
 	if (v->current_order.type == OT_GOTO_STATION &&
-			v->current_order.station == station) {
+			v->current_order.dest.station == station) {
 		// Yeah, keep the load/unload flags
 		// Non Stop now means if the order should be increased.
 		v->current_order.type = OT_LOADING;
@@ -2585,7 +2585,7 @@
 		v->current_order.type = OT_LOADING;
 		v->current_order.flags = 0;
 	}
-	v->current_order.station = 0;
+	v->current_order.dest.station = 0;
 
 	SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC);
 	if (LoadUnloadVehicle(v) != 0) {
@@ -3503,14 +3503,14 @@
 	depot = GetDepotByTile(tfdd.tile);
 
 	if (v->current_order.type == OT_GOTO_DEPOT &&
-			v->current_order.station != depot->index &&
+			v->current_order.dest.depot != depot->index &&
 			!CHANCE16(3, 16)) {
 		return;
 	}
 
 	v->current_order.type = OT_GOTO_DEPOT;
 	v->current_order.flags = OF_NON_STOP;
-	v->current_order.station = depot->index;
+	v->current_order.dest.depot = depot->index;
 	v->dest_tile = tfdd.tile;
 	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 }
@@ -3555,7 +3555,7 @@
 
 		/* update destination */
 		if (v->current_order.type == OT_GOTO_STATION &&
-				(tile = GetStation(v->current_order.station)->train_tile) != 0) {
+				(tile = GetStation(v->current_order.dest.station)->train_tile) != 0) {
 			v->dest_tile = tile;
 		}
 
--- a/train_gui.c
+++ b/train_gui.c
@@ -968,12 +968,12 @@
 			switch (v->current_order.type) {
 			case OT_GOTO_STATION: {
 				str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;
-				SetDParam(0, v->current_order.station);
+				SetDParam(0, v->current_order.dest.station);
 				SetDParam(1, v->u.rail.last_speed);
 			} break;
 
 			case OT_GOTO_DEPOT: {
-				Depot *dep = GetDepot(v->current_order.station);
+				Depot *dep = GetDepot(v->current_order.dest.depot);
 				SetDParam(0, dep->town_index);
 				str = STR_HEADING_FOR_TRAIN_DEPOT + _patches.vehicle_speed;
 				SetDParam(1, v->u.rail.last_speed);
@@ -985,7 +985,7 @@
 				break;
 
 			case OT_GOTO_WAYPOINT: {
-				SetDParam(0, v->current_order.station);
+				SetDParam(0, v->current_order.dest.waypoint);
 				str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed;
 				SetDParam(1, v->u.rail.last_speed);
 				break;
--- a/vehicle.c
+++ b/vehicle.c
@@ -2193,12 +2193,12 @@
 	    type and flags (which were both 4 bits) into type. Later on this is
 	    converted correctly */
 	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, type),    SLE_UINT8,                 0, 4),
-	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
+	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest.station), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
 
 	/* Orders for version 5 and on */
 	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, type),    SLE_UINT8,                 5, SL_MAX_VERSION),
 	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, flags),   SLE_UINT8,                 5, SL_MAX_VERSION),
-	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station), SLE_UINT16,                5, SL_MAX_VERSION),
+	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest.station), SLE_UINT16,                5, SL_MAX_VERSION),
 
 	    SLE_REF(Vehicle, orders,               REF_ORDER),
 
@@ -2363,8 +2363,8 @@
 	    SLE_VAR(Vehicle, z_height,      SLE_UINT8),
 	    SLE_VAR(Vehicle, owner,         SLE_UINT8),
 	    SLE_VAR(Vehicle, vehstatus,     SLE_UINT8),
-	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station),     SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
-	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station),     SLE_UINT16,                5, SL_MAX_VERSION),
+	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest.station),     SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
+	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest.station),     SLE_UINT16,                5, SL_MAX_VERSION),
 
 	    SLE_VAR(Vehicle, cur_image,     SLE_UINT16),
 	SLE_CONDVAR(Vehicle, age,           SLE_FILE_U16 | SLE_VAR_I32,  0, 30),
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -142,7 +142,7 @@
 				const Order *order;
 
 				FOR_VEHICLE_ORDERS(v, order) {
-					if (order->type == OT_GOTO_STATION && order->station == station) {
+					if (order->type == OT_GOTO_STATION && order->dest.station == station) {
 						sort_list[n++] = v;
 						break;
 					}
--- a/waypoint.c
+++ b/waypoint.c
@@ -249,7 +249,7 @@
 {
 	wp->xy = 0;
 
-	RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, wp->index);
+	RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, (DestinationID)wp->index);
 
 	if (wp->string != STR_NULL) DeleteName(wp->string);
 
--- a/waypoint.h
+++ b/waypoint.h
@@ -8,7 +8,7 @@
 
 struct Waypoint {
 	TileIndex xy;      ///< Tile of waypoint
-	StationID index;   ///< Index of waypoint
+	WaypointID index;  ///< Index of waypoint
 
 	TownID town_index; ///< Town associated with the waypoint
 	byte town_cn;      ///< The Nth waypoint for this town (consecutive number)
@@ -29,7 +29,7 @@
 /**
  * Get the pointer to the waypoint with index 'index'
  */
-static inline Waypoint *GetWaypoint(uint index)
+static inline Waypoint *GetWaypoint(WaypointID index)
 {
 	return (Waypoint*)GetItemFromPool(&_waypoint_pool, index);
 }
@@ -50,7 +50,7 @@
 	return wp->xy != 0;
 }
 
-static inline bool IsValidWaypointID(uint index)
+static inline bool IsValidWaypointID(WaypointID index)
 {
 	return index < GetWaypointPoolSize() && IsValidWaypoint(GetWaypoint(index));
 }
--- a/yapf/yapf_destrail.hpp
+++ b/yapf/yapf_destrail.hpp
@@ -85,8 +85,8 @@
 	void SetDestination(Vehicle* v)
 	{
 		if (v->current_order.type == OT_GOTO_STATION) {
-			m_destTile = CalcStationCenterTile(v->current_order.station);
-			m_dest_station_id = v->current_order.station;
+			m_destTile = CalcStationCenterTile(v->current_order.dest.station);
+			m_dest_station_id = v->current_order.dest.station;
 			m_destTrackdirs = INVALID_TRACKDIR_BIT;
 		} else {
 			m_destTile = v->dest_tile;