changeset 4527:b67e06dd63e8 draft

(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold DestinationID being a union of these types is just hassle without benefit and cannot be handled correctly everywhere because of local lack of information
author tron <tron@openttd.org>
date Sun, 03 Sep 2006 08:25:27 +0000
parents a4e404bf620d
children d6358ea16283
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 waypoint.c yapf/yapf_destrail.hpp
diffstat 21 files changed, 173 insertions(+), 187 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.dest.station = AiGetStationIdByDef(aib->use_tile, aib->cur_building_rule);
+		order.dest = 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.dest.station = AiGetStationIdFromRoadBlock(aib->use_tile, aib->cur_building_rule);
+		order.dest = 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.dest.station = AiGetStationIdFromAircraftBlock(aib->use_tile, aib->cur_building_rule);
+		order.dest = 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->dest.station] = 1;
+		if (ord->type == OT_GOTO_STATION) in_use[ord->dest] = 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->dest.station) == st) {
+				if (order->type == OT_GOTO_STATION && GetStation(order->dest) == 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.dest.depot = GetDepotByTile(p->ainew.depot_tile)->index;
+		order.dest = 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.dest.station = GetStationIndex(p->ainew.to_tile);
+	order.dest = 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.dest.station = GetStationIndex(p->ainew.from_tile);
+	order.dest = 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
@@ -554,7 +554,7 @@
 			v->current_order.type = OT_GOTO_DEPOT;
 			v->current_order.flags = OF_NON_STOP;
 			if (!(p1 & DEPOT_SERVICE)) SETBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
-			v->current_order.dest.station = next_airport_index;
+			v->current_order.dest = next_airport_index;
 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 			if (p2 & DEPOT_LOCATE_HANGAR || (p2 & DEPOT_SERVICE && v->u.air.state == FLYING && !next_airport_has_hangar)) {
 				/* The aircraft is now heading for a different hangar than the next in the orders */
@@ -667,7 +667,7 @@
 
 	if (_patches.gotodepot && VehicleHasDepotOrders(v)) return;
 
-	st = GetStation(v->current_order.dest.station);
+	st = GetStation(v->current_order.dest);
 	// 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);
@@ -1212,9 +1212,9 @@
 
 	if (order->type == OT_DUMMY && !CheckForValidOrders(v)) CrashAirplane(v);
 
-	if (order->type         == v->current_order.type   &&
-			order->flags        == v->current_order.flags  &&
-			order->dest.station == v->current_order.dest.station)
+	if (order->type  == v->current_order.type  &&
+			order->flags == v->current_order.flags &&
+			order->dest  == v->current_order.dest)
 		return;
 
 	v->current_order = *order;
@@ -1222,7 +1222,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->dest.station;
+		v->u.air.targetairport = order->dest;
 	}
 
 	InvalidateVehicleOrder(v);
@@ -1364,7 +1364,7 @@
 	v->current_order.flags = 0;
 
 	if (old_order.type == OT_GOTO_STATION &&
-			v->current_order.dest.station == v->last_station_visited) {
+			v->current_order.dest == v->last_station_visited) {
 		v->current_order.flags =
 			(old_order.flags & (OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER)) | OF_NON_STOP;
 	}
@@ -1432,7 +1432,7 @@
 
 	if (v->current_order.type == OT_GOTO_STATION ||
 			v->current_order.type == OT_GOTO_DEPOT)
-		v->u.air.targetairport = v->current_order.dest.station;
+		v->u.air.targetairport = v->current_order.dest;
 
 	st = GetStation(v->u.air.targetairport);
 	Airport = GetAirport(st->airport_type);
@@ -1504,7 +1504,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.dest.station == v->u.air.targetairport) {
+	if (v->current_order.dest == 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) {
@@ -1556,7 +1556,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.dest.station == v->u.air.targetairport) {
+			if (v->current_order.dest == 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,14 +548,14 @@
 		} else {
 			switch (v->current_order.type) {
 			case OT_GOTO_STATION: {
-				SetDParam(0, v->current_order.dest.station);
+				SetDParam(0, v->current_order.dest);
 				SetDParam(1, v->cur_speed * 128 / 10);
 				str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;
 			} break;
 
 			case OT_GOTO_DEPOT: {
 				/* Aircrafts always go to a station, even if you say depot */
-				SetDParam(0, v->current_order.dest.station);
+				SetDParam(0, v->current_order.dest);
 				SetDParam(1, v->cur_speed * 128 / 10);
 				if (HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
 					str = STR_HEADING_FOR_HANGAR + _patches.vehicle_speed;
@@ -965,7 +965,7 @@
 		sel--;
 
 		if (order->type == OT_GOTO_STATION) {
-			SetDParam(0, order->dest.station);
+			SetDParam(0, order->dest);
 			DrawString(x, y, STR_A036, 0);
 
 			y += 6;
--- a/depot.c
+++ b/depot.c
@@ -79,14 +79,11 @@
  */
 void DestroyDepot(Depot *depot)
 {
-	DestinationID dest;
-
 	/* Clear the tile */
 	DoClearSquare(depot->xy);
 
 	/* Clear the depot from all order-lists */
-	dest.depot = depot->index;
-	RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, dest);
+	RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, 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.dest.station = 0;
+	v->current_order.dest = 0;
 
 	DisasterVehicleUpdateImage(v);
 	VehiclePositionChanged(v);
@@ -165,7 +165,7 @@
 
 	++v->tick_counter;
 
-	if (v->current_order.dest.disaster < 2) {
+	if (v->current_order.dest < 2) {
 		if (v->tick_counter&1)
 			return;
 
@@ -173,23 +173,23 @@
 
 		SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
 
-		if (v->current_order.dest.disaster == 1) {
+		if (v->current_order.dest == 1) {
 			if (++v->age == 38) {
-				v->current_order.dest.disaster = 2;
+				v->current_order.dest = 2;
 				v->age = 0;
 			}
 
 			if ((v->tick_counter&7)==0) {
 				CreateEffectVehicleRel(v, 0, -17, 2, EV_SMOKE);
 			}
-		} else if (v->current_order.dest.disaster == 0) {
+		} else if (v->current_order.dest == 0) {
 			tile = v->tile; /**/
 
 			if (IsValidTile(tile) &&
 					IsTileType(tile, MP_STATION) &&
 					IsAirport(tile) &&
 					IS_HUMAN_PLAYER(GetTileOwner(tile))) {
-				v->current_order.dest.disaster = 1;
+				v->current_order.dest = 1;
 				v->age = 0;
 
 				SetDParam(0, GetStationIndex(tile));
@@ -204,7 +204,7 @@
 		return;
 	}
 
-	if (v->current_order.dest.disaster > 2) {
+	if (v->current_order.dest > 2) {
 		if (++v->age <= 13320)
 			return;
 
@@ -247,7 +247,7 @@
 				EV_EXPLOSION_SMALL);
 		}
 	} else if (v->age == 350) {
-		v->current_order.dest.disaster = 3;
+		v->current_order.dest = 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.dest.disaster == 0) {
+	if (v->current_order.dest == 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.dest.disaster = 1;
+		v->current_order.dest = 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.dest.disaster == 1 && v->tick_counter & 4) ? SPR_F_15_FIRING : 0;
+		(v->current_order.dest == 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.dest.disaster == 2) {
+	if (v->current_order.dest == 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.dest.disaster = 3;
+				v->current_order.dest = 3;
 		}
-	} else if (v->current_order.dest.disaster == 1) {
+	} else if (v->current_order.dest == 1) {
 		if (++v->age == 112) {
 			Industry *i;
 
-			v->current_order.dest.disaster = 2;
+			v->current_order.dest = 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.dest.disaster == 0) {
+	} else if (v->current_order.dest == 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.dest.disaster = 1;
+			v->current_order.dest = 1;
 			v->age = 0;
 		}
 	}
@@ -432,7 +432,7 @@
 
 	v->tick_counter++;
 	v->u.disaster.image_override =
-		(v->current_order.dest.disaster == 1 && v->tick_counter & 4) ? SPR_AH_64A_FIRING : 0;
+		(v->current_order.dest == 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.dest.disaster == 2) {
+	if (v->current_order.dest == 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.dest.disaster = 3;
+				v->current_order.dest = 3;
 		}
-	} else if (v->current_order.dest.disaster == 1) {
+	} else if (v->current_order.dest == 1) {
 		if (++v->age == 112) {
 			Industry *i;
 
-			v->current_order.dest.disaster = 2;
+			v->current_order.dest = 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.dest.disaster == 0) {
+	} else if (v->current_order.dest == 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.dest.disaster = 1;
+			v->current_order.dest = 1;
 			v->age = 0;
 		}
 	}
@@ -523,7 +523,7 @@
 
 	v->tick_counter++;
 
-	if (v->current_order.dest.disaster == 1) {
+	if (v->current_order.dest == 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.dest.disaster = 2;
+		v->current_order.dest = 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.dest.disaster < 1) {
+	} else if (v->current_order.dest < 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.dest.disaster = 1;
+		v->current_order.dest = 1;
 
 		tile_org = tile = RandomTile();
 		do {
@@ -624,11 +624,11 @@
 		return;
 	}
 
-	if (v->current_order.dest.disaster == 0) {
+	if (v->current_order.dest == 0) {
 		u = GetVehicle(v->u.disaster.unk2);
 		if (abs(v->x_pos - u->x_pos) > TILE_SIZE)
 			return;
-		v->current_order.dest.disaster = 1;
+		v->current_order.dest = 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.dest.station;
+		fstd->station_index = v->current_order.dest;
 		/* Let's take the closest tile of the station as our target for trains */
-		fstd->dest_coords = CalcClosestStationTile(v->current_order.dest.station, v->tile);
+		fstd->dest_coords = CalcClosestStationTile(v->current_order.dest, v->tile);
 	} else {
 		fstd->dest_coords = v->dest_tile;
 		fstd->station_index = INVALID_STATION;
--- a/openttd.h
+++ b/openttd.h
@@ -57,20 +57,14 @@
 typedef uint16 OrderID;
 typedef uint16 SignID;
 typedef uint16 EngineRenewID;
+typedef uint16 DestinationID;
 
-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 DestinationID has to be of the same size, because some part
- *  of the code depends on the fact that DestinationID is the same for all
- *  items inside DestinationID. Check PackOrder() */
-assert_compile(sizeof(StationID) == sizeof(DepotID));
-assert_compile(sizeof(StationID) == sizeof(WaypointID));
-assert_compile(sizeof(StationID) == sizeof(uint16));
+/* DestinationID must be at least as large as every these below, because it can
+ * be any of them
+ */
+assert_compile(sizeof(DestinationID) == sizeof(DepotID));
+assert_compile(sizeof(DestinationID) == sizeof(WaypointID));
+assert_compile(sizeof(DestinationID) == sizeof(StationID));
 
 typedef uint32 WindowNumber;
 typedef byte WindowClass;
--- a/order.h
+++ b/order.h
@@ -177,7 +177,7 @@
 
 static inline uint32 PackOrder(const Order *order)
 {
-	return order->dest.station << 16 | order->flags << 8 | order->type;
+	return order->dest << 16 | order->flags << 8 | order->type;
 }
 
 static inline Order UnpackOrder(uint32 packed)
@@ -185,7 +185,7 @@
 	Order order;
 	order.type    = (OrderType)GB(packed,  0,  8);
 	order.flags   = GB(packed,  8,  8);
-	order.dest.station = GB(packed, 16, 16);
+	order.dest    = GB(packed, 16, 16);
 	order.next    = NULL;
 	order.index   = 0; // avoid compiler warning
 	return order;
--- 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.dest.station = GB(packed, 8, 8);
+	order.dest    = 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.dest.station != 0)) {
+	if (order.type == OT_NOTHING && (order.flags != 0 || order.dest != 0)) {
 		order.type = OT_DUMMY;
 		order.flags = 0;
 	}
@@ -68,11 +68,11 @@
 static Order UnpackVersion4Order(uint16 packed)
 {
 	Order order;
-	order.type    = GB(packed, 0, 4);
-	order.flags   = GB(packed, 4, 4);
-	order.dest.station = GB(packed, 8, 8);
-	order.next    = NULL;
-	order.index   = 0; // avoid compiler warning
+	order.type  = GB(packed, 0, 4);
+	order.flags = GB(packed, 4, 4);
+	order.dest  = GB(packed, 8, 8);
+	order.next  = NULL;
+	order.index = 0; // avoid compiler warning
 	return order;
 }
 
@@ -142,9 +142,9 @@
  */
 void AssignOrder(Order *order, Order data)
 {
-	order->type    = data.type;
-	order->flags   = data.flags;
-	order->dest.station = data.dest.station;
+	order->type  = data.type;
+	order->flags = data.flags;
+	order->dest  = data.dest;
 }
 
 
@@ -191,8 +191,8 @@
 		case OT_GOTO_STATION: {
 			const Station *st;
 
-			if (!IsValidStationID(new_order.dest.station)) return CMD_ERROR;
-			st = GetStation(new_order.dest.station);
+			if (!IsValidStationID(new_order.dest)) return CMD_ERROR;
+			st = GetStation(new_order.dest);
 
 			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.dest.station)) return CMD_ERROR;
-				st = GetStation(new_order.dest.station);
+				if (!IsValidStationID(new_order.dest)) return CMD_ERROR;
+				st = GetStation(new_order.dest);
 
 				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.dest.depot)) return CMD_ERROR;
-				dp = GetDepot(new_order.dest.depot);
+				if (!IsValidDepotID(new_order.dest)) return CMD_ERROR;
+				dp = GetDepot(new_order.dest);
 
 				if (!CheckOwnership(GetTileOwner(dp->xy))) return CMD_ERROR;
 
@@ -308,8 +308,8 @@
 
 			if (v->type != VEH_Train) return CMD_ERROR;
 
-			if (!IsValidWaypointID(new_order.dest.waypoint)) return CMD_ERROR;
-			wp = GetWaypoint(new_order.dest.waypoint);
+			if (!IsValidWaypointID(new_order.dest)) return CMD_ERROR;
+			wp = GetWaypoint(new_order.dest);
 
 			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)->dest.station)->xy,
-			GetStation(new_order.dest.station)->xy // XXX type != OT_GOTO_STATION?
+			GetStation(GetVehicleOrder(v, sel_ord - 1)->dest)->xy,
+			GetStation(new_order.dest)->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->dest.station);
+						const Station *st = GetStation(order->dest);
 						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->dest.station);
+				const Station* st = GetStation(order->dest);
 				TileIndex required_tile = GetStationTileForVehicle(v, st);
 
 				n_st++;
@@ -931,9 +931,9 @@
 		if (v->num_orders > 1) {
 			const Order* last = GetLastVehicleOrder(v);
 
-			if (v->orders->type    == last->type &&
-					v->orders->flags   == last->flags &&
-					v->orders->dest.station == last->dest.station) {
+			if (v->orders->type  == last->type &&
+					v->orders->flags == last->flags &&
+					v->orders->dest  == last->dest) {
 				problem_type = 2;
 			}
 		}
@@ -973,11 +973,11 @@
 		if (v->orders == NULL) continue;
 
 		/* Forget about this station if this station is removed */
-		if (v->last_station_visited == destination.station && type == OT_GOTO_STATION)
+		if (v->last_station_visited == destination && type == OT_GOTO_STATION)
 			v->last_station_visited = INVALID_STATION;
 
 		/* Check the current order */
-		if (v->current_order.type == type && v->current_order.dest.station == destination.station) {
+		if (v->current_order.type == type && v->current_order.dest == destination) {
 			/* 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->dest.station == destination.station) {
+			if (order->type == type && order->dest == destination) {
 				/* Mark the order as DUMMY */
 				order->type = OT_DUMMY;
 				order->flags = 0;
@@ -1110,10 +1110,10 @@
 }
 
 static const SaveLoad _order_desc[] = {
-	SLE_VAR(Order, type,    SLE_UINT8),
-	SLE_VAR(Order, flags,   SLE_UINT8),
-	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),
+	SLE_VAR(Order, type,  SLE_UINT8),
+	SLE_VAR(Order, flags, SLE_UINT8),
+	SLE_VAR(Order, dest,  SLE_UINT16),
+	SLE_REF(Order, next,  REF_ORDER),
 
 	// reserve extra space in savegame here. (currently 10 bytes)
 	SLE_CONDNULL(10, 5, SL_MAX_VERSION),
--- a/order_gui.c
+++ b/order_gui.c
@@ -145,7 +145,7 @@
 			switch (order->type) {
 				case OT_GOTO_STATION:
 					SetDParam(1, StationOrderStrings[order->flags]);
-					SetDParam(2, order->dest.station);
+					SetDParam(2, order->dest);
 					break;
 
 				case OT_GOTO_DEPOT: {
@@ -153,9 +153,9 @@
 
 					if (v->type == VEH_Aircraft) {
 						s = STR_GO_TO_AIRPORT_HANGAR;
-						SetDParam(2, order->dest.depot);
+						SetDParam(2, order->dest);
 					} else {
-						SetDParam(2, GetDepot(order->dest.depot)->town_index);
+						SetDParam(2, GetDepot(order->dest)->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;
@@ -173,7 +173,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->dest.waypoint);
+					SetDParam(2, order->dest);
 					break;
 
 				default: break;
@@ -185,7 +185,7 @@
 				DrawString(2, y, str, color);
 			} else {
 				SetDParam(1, STR_INVALID_ORDER);
-				SetDParam(2, order->dest.station);
+				SetDParam(2, order->dest);
 				DrawString(2, y, str, color);
 			}
 			y += 10;
@@ -216,7 +216,7 @@
 				if (IsRailDepot(tile)) {
 					order.type = OT_GOTO_DEPOT;
 					order.flags = OF_PART_OF_ORDERS;
-					order.dest.depot = GetDepotByTile(tile)->index;
+					order.dest = GetDepotByTile(tile)->index;
 					return order;
 				}
 			}
@@ -226,7 +226,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.dest.depot = GetDepotByTile(tile)->index;
+				order.dest = GetDepotByTile(tile)->index;
 				return order;
 			}
 			break;
@@ -236,7 +236,7 @@
 			if (IsHangar(tile) && IsTileOwner(tile, _local_player)) {
 				order.type = OT_GOTO_DEPOT;
 				order.flags = OF_PART_OF_ORDERS;
-				order.dest.station = GetStationIndex(tile);
+				order.dest = GetStationIndex(tile);
 				return order;
 			}
 			break;
@@ -249,7 +249,7 @@
 
 				order.type = OT_GOTO_DEPOT;
 				order.flags = OF_PART_OF_ORDERS;
-				order.dest.depot = GetDepotByTile(tile < tile2 ? tile : tile2)->index;
+				order.dest = GetDepotByTile(tile < tile2 ? tile : tile2)->index;
 				return order;
 			}
 
@@ -265,7 +265,7 @@
 			IsRailWaypoint(tile)) {
 		order.type = OT_GOTO_WAYPOINT;
 		order.flags = 0;
-		order.dest.waypoint = GetWaypointByTile(tile)->index;
+		order.dest = GetWaypointByTile(tile)->index;
 		return order;
 	}
 
@@ -283,7 +283,7 @@
 			if (st->facilities & facil) {
 				order.type = OT_GOTO_STATION;
 				order.flags = 0;
-				order.dest.station = st_index;
+				order.dest = st_index;
 				return order;
 			}
 		}
@@ -292,7 +292,7 @@
 	// not found
 	order.type = OT_NOTHING;
 	order.flags = 0;
-	order.dest.station = INVALID_STATION;
+	order.dest = INVALID_STATION;
 	return order;
 }
 
@@ -421,9 +421,9 @@
 				TileIndex xy;
 
 				switch (ord->type) {
-					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;
+					case OT_GOTO_STATION:  xy = GetStation(ord->dest)->xy ; break;
+					case OT_GOTO_DEPOT:    xy = GetDepot(ord->dest)->xy;    break;
+					case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->dest)->xy; break;
 					default:               xy = 0; break;
 				}
 
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -417,7 +417,7 @@
 		v->current_order.type = OT_GOTO_DEPOT;
 		v->current_order.flags = OF_NON_STOP;
 		if (!(p2 & DEPOT_SERVICE)) SETBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
-		v->current_order.dest.depot = dep->index;
+		v->current_order.dest = dep->index;
 		v->dest_tile = dep->xy;
 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 	}
@@ -670,9 +670,9 @@
 		return;
 	}
 
-	if (order->type    == v->current_order.type &&
-			order->flags   == v->current_order.flags &&
-			order->dest.station == v->current_order.dest.station) {
+	if (order->type  == v->current_order.type &&
+			order->flags == v->current_order.flags &&
+			order->dest  == v->current_order.dest) {
 		return;
 	}
 
@@ -682,12 +682,12 @@
 		case OT_GOTO_STATION: {
 			const RoadStop* rs;
 
-			if (order->dest.station == v->last_station_visited) {
+			if (order->dest == v->last_station_visited) {
 				v->last_station_visited = INVALID_STATION;
 			}
 
 			rs = GetPrimaryRoadStop(
-				GetStation(order->dest.station),
+				GetStation(order->dest),
 				v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK
 			);
 
@@ -713,7 +713,7 @@
 		}
 
 		case OT_GOTO_DEPOT:
-			v->dest_tile = GetDepot(order->dest.depot)->xy;
+			v->dest_tile = GetDepot(order->dest)->xy;
 			break;
 
 		default:
@@ -1501,7 +1501,7 @@
 			v->current_order.flags = 0;
 
 			if (old_order.type == OT_GOTO_STATION &&
-					v->current_order.dest.station == v->last_station_visited) {
+					v->current_order.dest == v->last_station_visited) {
 				v->current_order.flags =
 					(old_order.flags & (OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER)) | OF_NON_STOP;
 			}
@@ -1543,9 +1543,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.dest.station != st->index)
+				if (v->current_order.dest != st->index)
 					DEBUG(ms, 0) ("Multistop: -- Current station %d is not target station in current_order.station (%d).",
-							st->index, v->current_order.dest.station);
+							st->index, v->current_order.dest);
 			}
 
 			DEBUG(ms, 0) ("           -- Force a slot clearing.");
@@ -1660,7 +1660,7 @@
 
 	v->current_order.type = OT_GOTO_DEPOT;
 	v->current_order.flags = OF_NON_STOP;
-	v->current_order.dest.depot = depot->index;
+	v->current_order.dest = depot->index;
 	v->dest_tile = depot->xy;
 	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 }
@@ -1688,7 +1688,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.dest.station);
+		Station* st = GetStation(v->current_order.dest);
 		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.dest.station);
+				SetDParam(0, v->current_order.dest);
 				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.dest.depot);
+				Depot *depot = GetDepot(v->current_order.dest);
 				SetDParam(0, depot->town_index);
 				SetDParam(1, v->cur_speed / 2);
 				if (HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
--- 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.dest.depot = depot->index;
+	v->current_order.dest = depot->index;
 	v->dest_tile = depot->xy;
 	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 }
@@ -227,9 +227,9 @@
 		return;
 	}
 
-	if (order->type    == v->current_order.type &&
-			order->flags   == v->current_order.flags &&
-			order->dest.station == v->current_order.dest.station)
+	if (order->type  == v->current_order.type &&
+			order->flags == v->current_order.flags &&
+			order->dest  == v->current_order.dest)
 		return;
 
 	v->current_order = *order;
@@ -237,15 +237,15 @@
 	if (order->type == OT_GOTO_STATION) {
 		const Station *st;
 
-		if (order->dest.station == v->last_station_visited)
+		if (order->dest == v->last_station_visited)
 			v->last_station_visited = INVALID_STATION;
 
-		st = GetStation(order->dest.station);
+		st = GetStation(order->dest);
 		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->dest.depot)->xy;
+		v->dest_tile = GetDepot(order->dest)->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.dest.station;
+							v->last_station_visited = v->current_order.dest;
 
 							/* Process station in the orderlist. */
-							st = GetStation(v->current_order.dest.station);
+							st = GetStation(v->current_order.dest);
 							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;
@@ -1055,7 +1055,7 @@
 		v->current_order.type = OT_GOTO_DEPOT;
 		v->current_order.flags = OF_NON_STOP;
 		if (!(p2 & DEPOT_SERVICE)) SETBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
-		v->current_order.dest.depot = dep->index;
+		v->current_order.dest = dep->index;
 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 	}
 
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -475,13 +475,13 @@
 			} else {
 				switch (v->current_order.type) {
 					case OT_GOTO_STATION: {
-						SetDParam(0, v->current_order.dest.station);
+						SetDParam(0, v->current_order.dest);
 						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.dest.depot);
+						Depot *depot = GetDepot(v->current_order.dest);
 						SetDParam(0, depot->town_index);
 						SetDParam(1, v->cur_speed / 2);
 						if (HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
@@ -904,8 +904,8 @@
 		sel--;
 
 		if (order->type == OT_GOTO_STATION) {
-			if (!IsBuoy(GetStation(order->dest.station))){
-				SetDParam(0, order->dest.station);
+			if (!IsBuoy(GetStation(order->dest))) {
+				SetDParam(0, order->dest);
 				DrawString(x, y, STR_A036, 0);
 
 				y += 6;
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -1848,7 +1848,7 @@
 		if (v->type == VEH_Ship) {
 			const Order *order;
 			FOR_VEHICLE_ORDERS(v, order) {
-				if (order->type == OT_GOTO_STATION && order->dest.station == st->index) {
+				if (order->type == OT_GOTO_STATION && order->dest == st->index) {
 					return true;
 				}
 			}
@@ -2289,7 +2289,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.dest.station == station_id)) {
+					(v->current_order.type == OT_GOTO_STATION && v->current_order.dest == 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) {
@@ -2375,7 +2375,6 @@
   */
 void DestroyStation(Station *st)
 {
-	DestinationID dest;
 	StationID index;
 	Vehicle *v;
 
@@ -2389,8 +2388,7 @@
 	DeleteWindowById(WC_STATION_VIEW, index);
 
 	/* Now delete all orders that go to the station */
-	dest.station = index;
-	RemoveOrderFromAllVehicles(OT_GOTO_STATION, dest);
+	RemoveOrderFromAllVehicles(OT_GOTO_STATION, index);
 
 	//And do the same with aircraft that have the station as a hangar-stop
 	FOR_ALL_VEHICLES(v) {
@@ -2398,7 +2396,7 @@
 		if (v->type == VEH_Aircraft) {
 			Order *order;
 			FOR_VEHICLE_ORDERS(v, order) {
-				if (order->type == OT_GOTO_DEPOT && order->dest.station == index) {
+				if (order->type == OT_GOTO_DEPOT && order->dest == 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->dest.station) {
+	if (_patches.new_nonstop && o->flags & OF_NON_STOP && sid == o->dest) {
 		return false;
 	}
 
 	if (v->last_station_visited == sid) return false;
 
-	if (sid != o->dest.station && (o->flags & OF_NON_STOP || _patches.new_nonstop)) {
+	if (sid != o->dest && (o->flags & OF_NON_STOP || _patches.new_nonstop)) {
 		return false;
 	}
 
@@ -1985,7 +1985,7 @@
 		v->current_order.type = OT_GOTO_DEPOT;
 		v->current_order.flags = OF_NON_STOP;
 		if (!(p2 & DEPOT_SERVICE)) SETBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
-		v->current_order.dest.depot = GetDepotByTile(tfdd.tile)->index;
+		v->current_order.dest = GetDepotByTile(tfdd.tile)->index;
 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		/* If there is no depot in front, reverse automatically */
 		if (tfdd.reverse)
@@ -2189,7 +2189,7 @@
 {
 	fd->dest_coords = v->dest_tile;
 	if (v->current_order.type == OT_GOTO_STATION) {
-		fd->station_index = v->current_order.dest.station;
+		fd->station_index = v->current_order.dest;
 	} else {
 		fd->station_index = INVALID_STATION;
 	}
@@ -2436,7 +2436,7 @@
 	if (_patches.new_nonstop &&
 			v->current_order.flags & OF_NON_STOP &&
 			IsTileType(v->tile, MP_STATION) &&
-			v->current_order.dest.station == GetStationIndex(v->tile)) {
+			v->current_order.dest == GetStationIndex(v->tile)) {
 		v->cur_order_index++;
 	}
 
@@ -2454,9 +2454,9 @@
 	}
 
 	// If it is unchanged, keep it.
-	if (order->type    == v->current_order.type &&
-			order->flags   == v->current_order.flags &&
-			order->dest.station == v->current_order.dest.station)
+	if (order->type  == v->current_order.type &&
+			order->flags == v->current_order.flags &&
+			order->dest  == v->current_order.dest)
 		return false;
 
 	// Otherwise set it, and determine the destination tile.
@@ -2468,17 +2468,17 @@
 
 	switch (order->type) {
 		case OT_GOTO_STATION:
-			if (order->dest.station == v->last_station_visited)
+			if (order->dest == v->last_station_visited)
 				v->last_station_visited = INVALID_STATION;
-			v->dest_tile = GetStation(order->dest.station)->xy;
+			v->dest_tile = GetStation(order->dest)->xy;
 			break;
 
 		case OT_GOTO_DEPOT:
-			v->dest_tile = GetDepot(order->dest.depot)->xy;
+			v->dest_tile = GetDepot(order->dest)->xy;
 			break;
 
 		case OT_GOTO_WAYPOINT:
-			v->dest_tile = GetWaypoint(order->dest.waypoint)->xy;
+			v->dest_tile = GetWaypoint(order->dest)->xy;
 			break;
 
 		default:
@@ -2599,7 +2599,7 @@
 
 	// Did we reach the final destination?
 	if (v->current_order.type == OT_GOTO_STATION &&
-			v->current_order.dest.station == station) {
+			v->current_order.dest == station) {
 		// Yeah, keep the load/unload flags
 		// Non Stop now means if the order should be increased.
 		v->current_order.type = OT_LOADING;
@@ -2610,7 +2610,7 @@
 		v->current_order.type = OT_LOADING;
 		v->current_order.flags = 0;
 	}
-	v->current_order.dest.station = 0;
+	v->current_order.dest = 0;
 
 	SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC);
 	if (LoadUnloadVehicle(v) != 0) {
@@ -3528,14 +3528,14 @@
 	depot = GetDepotByTile(tfdd.tile);
 
 	if (v->current_order.type == OT_GOTO_DEPOT &&
-			v->current_order.dest.depot != depot->index &&
+			v->current_order.dest != depot->index &&
 			!CHANCE16(3, 16)) {
 		return;
 	}
 
 	v->current_order.type = OT_GOTO_DEPOT;
 	v->current_order.flags = OF_NON_STOP;
-	v->current_order.dest.depot = depot->index;
+	v->current_order.dest = depot->index;
 	v->dest_tile = tfdd.tile;
 	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 }
@@ -3580,7 +3580,7 @@
 
 		/* update destination */
 		if (v->current_order.type == OT_GOTO_STATION &&
-				(tile = GetStation(v->current_order.dest.station)->train_tile) != 0) {
+				(tile = GetStation(v->current_order.dest)->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.dest.station);
+				SetDParam(0, v->current_order.dest);
 				SetDParam(1, v->u.rail.last_speed);
 			} break;
 
 			case OT_GOTO_DEPOT: {
-				Depot *dep = GetDepot(v->current_order.dest.depot);
+				Depot *dep = GetDepot(v->current_order.dest);
 				SetDParam(0, dep->town_index);
 				if (HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
 					str = STR_HEADING_FOR_TRAIN_DEPOT + _patches.vehicle_speed;
@@ -989,7 +989,7 @@
 				break;
 
 			case OT_GOTO_WAYPOINT: {
-				SetDParam(0, v->current_order.dest.waypoint);
+				SetDParam(0, v->current_order.dest);
 				str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed;
 				SetDParam(1, v->u.rail.last_speed);
 				break;
--- a/vehicle.c
+++ b/vehicle.c
@@ -1922,7 +1922,7 @@
 					const Order *order;
 
 					FOR_VEHICLE_ORDERS(v, order) {
-						if (order->type == OT_GOTO_STATION && order->dest.station == station) {
+						if (order->type == OT_GOTO_STATION && order->dest == station) {
 							sort_list[n++] = v;
 							break;
 						}
@@ -2294,13 +2294,13 @@
 	/* This next line is for version 4 and prior compatibility.. it temporarily reads
 	    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, dest.station), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
+	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, type), SLE_UINT8,                 0, 4),
+	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest), 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, dest.station), SLE_UINT16,                5, SL_MAX_VERSION),
+	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, dest),  SLE_UINT16, 5, SL_MAX_VERSION),
 
 	    SLE_REF(Vehicle, orders,               REF_ORDER),
 
@@ -2465,8 +2465,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, 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_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
+	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest), 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/waypoint.c
+++ b/waypoint.c
@@ -98,10 +98,7 @@
 /* Internal handler to delete a waypoint */
 void DestroyWaypoint(Waypoint *wp)
 {
-	DestinationID dest;
-
-	dest.waypoint = wp->index;
-	RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, dest);
+	RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, wp->index);
 
 	if (wp->string != STR_NULL) DeleteName(wp->string);
 
--- 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.dest.station);
-			m_dest_station_id = v->current_order.dest.station;
+			m_destTile = CalcStationCenterTile(v->current_order.dest);
+			m_dest_station_id = v->current_order.dest;
 			m_destTrackdirs = INVALID_TRACKDIR_BIT;
 		} else {
 			m_destTile = v->dest_tile;