changeset 13856:8c8d1ebf7ae1 draft

(svn r18385) -Cleanup: remove the now unneeded multistop slot management code
author rubidium <rubidium@openttd.org>
date Wed, 02 Dec 2009 18:18:56 +0000
parents cf7f21e56f62
children 19e881c1e87d
files src/debug.h src/order_cmd.cpp src/pathfinder/yapf/yapf.h src/pathfinder/yapf/yapf_road.cpp src/roadstop.cpp src/roadstop_base.h src/roadveh.h src/roadveh_cmd.cpp src/saveload/afterload.cpp src/saveload/vehicle_sl.cpp src/station_func.h src/tunnelbridge_cmd.cpp src/vehicle.cpp
diffstat 13 files changed, 10 insertions(+), 354 deletions(-) [+]
line wrap: on
line diff
--- a/src/debug.h
+++ b/src/debug.h
@@ -36,7 +36,6 @@
 	extern int _debug_grf_level;
 	extern int _debug_map_level;
 	extern int _debug_misc_level;
-	extern int _debug_ms_level;
 	extern int _debug_net_level;
 	extern int _debug_sprite_level;
 	extern int _debug_oldloader_level;
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -788,8 +788,6 @@
 	if (flags & DC_EXEC) {
 		v->cur_order_index = sel_ord;
 
-		if (v->type == VEH_ROAD) ClearSlot(RoadVehicle::From(v));
-
 		if (v->current_order.IsType(OT_LOADING)) v->LeaveStation();
 
 		InvalidateVehicleOrder(v, -2);
@@ -1794,7 +1792,6 @@
 
 		v->current_order.Free();
 		v->dest_tile = 0;
-		if (v->type == VEH_ROAD) ClearSlot(RoadVehicle::From(v));
 		return false;
 	}
 
--- a/src/pathfinder/yapf/yapf.h
+++ b/src/pathfinder/yapf/yapf.h
@@ -49,21 +49,6 @@
  */
 Track YapfTrainChooseTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, struct PBSTileInfo *target);
 
-/** Used by RV multistop feature to find the nearest road stop that has a free slot.
- * @param v      RV (its current tile will be the origin)
- * @param tile   destination tile
- * @return       distance from origin tile to the destination (number of road tiles) or UINT_MAX if path not found
- */
-uint YapfRoadVehDistanceToTile(const RoadVehicle *v, TileIndex tile);
-
-/** Used to determinine the closest reachable compatible road stop for a given vehicle.
- * @param v            vehicle that needs to go to the road stop
- * @param station      the station the road stop must belong to
- * @param stop_tile    receives the stop tile if a stop was found
- * @return             true if stop was found.
- */
-bool YapfFindNearestRoadVehicleCompatibleStop(const RoadVehicle *v, StationID station, TileIndex *stop_tile);
-
 /**
  * Used when user sends road vehicle to the nearest depot or if road vehicle needs servicing using YAPF.
  * @param v            vehicle that needs to go to some depot
--- a/src/pathfinder/yapf/yapf_road.cpp
+++ b/src/pathfinder/yapf/yapf_road.cpp
@@ -185,78 +185,6 @@
 
 
 template <class Types>
-class CYapfDestinationAnyRoadVehicleCompatibleStopOfGivenStationT
-{
-public:
-	typedef typename Types::Tpf Tpf;                     ///< the pathfinder class (derived from THIS class)
-	typedef typename Types::TrackFollower TrackFollower;
-	typedef typename Types::NodeList::Titem Node;        ///< this will be our node type
-	typedef typename Node::Key Key;                      ///< key to hash tables
-
-	TileIndex      m_destTile;
-	StationID      m_dest_station;
-	bool           m_bus;
-	bool           m_non_artic;
-
-	/** to access inherited path finder */
-	Tpf& Yapf()
-	{
-		return *static_cast<Tpf*>(this);
-	}
-
-	void SetDestination(const RoadVehicle *v, StationID sid, TileIndex destTile)
-	{
-		m_dest_station = sid;
-		m_destTile     = destTile;
-		m_bus          = v->IsBus();
-		m_non_artic    = !v->HasArticulatedPart();
-	}
-
-	/** Called by YAPF to detect if node ends in the desired destination */
-	FORCEINLINE bool PfDetectDestination(Node& n)
-	{
-		return PfDetectDestinationTile(n.m_segment_last_tile, INVALID_TRACKDIR);
-	}
-
-	FORCEINLINE bool PfDetectDestinationTile(TileIndex tile, Trackdir trackdir)
-	{
-		return
-			IsTileType(tile, MP_STATION) &&
-			GetStationIndex(tile) == m_dest_station &&
-			(m_bus ? IsBusStop(tile) : IsTruckStop(tile)) &&
-			(m_non_artic || IsDriveThroughStopTile(tile));
-	}
-
-	/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
-	 *  adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
-	FORCEINLINE bool PfCalcEstimate(Node& n)
-	{
-		static const int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
-		static const int dg_dir_to_y_offs[] = {0, 1, 0, -1};
-		if (PfDetectDestination(n)) {
-			n.m_estimate = n.m_cost;
-			return true;
-		}
-
-		TileIndex tile = n.m_segment_last_tile;
-		DiagDirection exitdir = TrackdirToExitdir(n.m_segment_last_td);
-		int x1 = 2 * TileX(tile) + dg_dir_to_x_offs[(int)exitdir];
-		int y1 = 2 * TileY(tile) + dg_dir_to_y_offs[(int)exitdir];
-		int x2 = 2 * TileX(m_destTile);
-		int y2 = 2 * TileY(m_destTile);
-		int dx = abs(x1 - x2);
-		int dy = abs(y1 - y2);
-		int dmin = min(dx, dy);
-		int dxy = abs(dx - dy);
-		int d = dmin * YAPF_TILE_CORNER_LENGTH + (dxy - 1) * (YAPF_TILE_LENGTH / 2);
-		n.m_estimate = n.m_cost + d;
-		assert(n.m_estimate >= n.m_parent->m_estimate);
-		return true;
-	}
-};
-
-
-template <class Types>
 class CYapfDestinationTileRoadT
 {
 public:
@@ -497,30 +425,6 @@
 		*depot_tile = n->m_segment_last_tile;
 		return true;
 	}
-
-	static bool stFindNearestRoadVehicleCompatibleStop(const RoadVehicle *v, TileIndex tile, TileIndex destTile, Trackdir td, StationID sid, TileIndex *stop_tile)
-	{
-		Tpf pf;
-		return pf.FindNearestRoadVehicleCompatibleStop(v, tile, destTile, td, sid, stop_tile);
-	}
-
-	FORCEINLINE bool FindNearestRoadVehicleCompatibleStop(const RoadVehicle *v, TileIndex tile, TileIndex destTile, Trackdir td, StationID sid, TileIndex *stop_tile)
-	{
-		/* set origin and destination nodes */
-		Yapf().SetOrigin(tile, TrackdirToTrackdirBits(td));
-		Yapf().SetDestination(v, sid, destTile);
-
-		/* find the best path */
-		bool bFound = Yapf().FindPath(v);
-		if (!bFound) return false;
-
-		/* some path found
-		 * get found depot tile */
-		const Node *n = Yapf().GetBestNode();
-
-		*stop_tile = n->m_segment_last_tile;
-		return true;
-	}
 };
 
 template <class Tpf_, class Tnode_list, template <class Types> class Tdestination>
@@ -546,9 +450,6 @@
 struct CYapfRoadAnyDepot1 : CYapfT<CYapfRoad_TypesT<CYapfRoadAnyDepot1, CRoadNodeListTrackDir, CYapfDestinationAnyDepotRoadT> > {};
 struct CYapfRoadAnyDepot2 : CYapfT<CYapfRoad_TypesT<CYapfRoadAnyDepot2, CRoadNodeListExitDir , CYapfDestinationAnyDepotRoadT> > {};
 
-struct CYapfRoadAnyRoadVehicleCompatibleStopOfGivenStation1 : CYapfT<CYapfRoad_TypesT<CYapfRoadAnyRoadVehicleCompatibleStopOfGivenStation1, CRoadNodeListTrackDir, CYapfDestinationAnyRoadVehicleCompatibleStopOfGivenStationT> > {};
-struct CYapfRoadAnyRoadVehicleCompatibleStopOfGivenStation2 : CYapfT<CYapfRoad_TypesT<CYapfRoadAnyRoadVehicleCompatibleStopOfGivenStation2, CRoadNodeListExitDir , CYapfDestinationAnyRoadVehicleCompatibleStopOfGivenStationT> > {};
-
 
 Trackdir YapfRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs)
 {
@@ -565,27 +466,6 @@
 	return (td_ret != INVALID_TRACKDIR) ? td_ret : (Trackdir)FindFirstBit2x64(trackdirs);
 }
 
-uint YapfRoadVehDistanceToTile(const RoadVehicle *v, TileIndex tile)
-{
-	/* default is YAPF type 2 */
-	typedef uint (*PfnDistanceToTile)(const RoadVehicle*, TileIndex);
-	PfnDistanceToTile pfnDistanceToTile = &CYapfRoad2::stDistanceToTile; // default: ExitDir, allow 90-deg
-
-	/* check if non-default YAPF type should be used */
-	if (_settings_game.pf.yapf.disable_node_optimization) {
-		pfnDistanceToTile = &CYapfRoad1::stDistanceToTile; // Trackdir, allow 90-deg
-	}
-
-	/* measure distance in YAPF units */
-	uint dist = pfnDistanceToTile(v, tile);
-	/* convert distance to tiles */
-	if (dist != UINT_MAX) {
-		dist = (dist + YAPF_TILE_LENGTH - 1) / YAPF_TILE_LENGTH;
-	}
-
-	return dist;
-}
-
 FindDepotData YapfRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_distance)
 {
 	TileIndex tile = v->tile;
@@ -608,29 +488,3 @@
 	fdd.best_length = ret ? max_distance / 2 : UINT_MAX; // some fake distance or NOT_FOUND
 	return ret;
 }
-
-bool YapfFindNearestRoadVehicleCompatibleStop(const RoadVehicle *v, StationID station, TileIndex *stop_tile)
-{
-	*stop_tile = INVALID_TILE;
-
-	const RoadStop *rs = Station::Get(station)->GetPrimaryRoadStop(v);
-	if (rs == NULL) return false;
-
-	TileIndex tile = v->tile;
-	Trackdir trackdir = v->GetVehicleTrackdir();
-	if ((TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, v->compatible_roadtypes)) & TrackdirToTrackdirBits(trackdir)) == 0) {
-		return false;
-	}
-
-	/* default is YAPF type 2 */
-	typedef bool (*PfnFindNearestRoadVehicleCompatibleStop)(const RoadVehicle*, TileIndex, TileIndex, Trackdir, StationID, TileIndex*);
-	PfnFindNearestRoadVehicleCompatibleStop pfnFindNearestRoadVehicleCompatibleStop = &CYapfRoadAnyRoadVehicleCompatibleStopOfGivenStation2::stFindNearestRoadVehicleCompatibleStop;
-
-	/* check if non-default YAPF type should be used */
-	if (_settings_game.pf.yapf.disable_node_optimization) {
-		pfnFindNearestRoadVehicleCompatibleStop = &CYapfRoadAnyRoadVehicleCompatibleStopOfGivenStation1::stFindNearestRoadVehicleCompatibleStop; // Trackdir, allow 90-deg
-	}
-
-	bool ret = pfnFindNearestRoadVehicleCompatibleStop(v, tile, rs->xy, trackdir, station, stop_tile);
-	return ret;
-}
--- a/src/roadstop.cpp
+++ b/src/roadstop.cpp
@@ -19,21 +19,11 @@
 INSTANTIATE_POOL_METHODS(RoadStop)
 
 /**
- * De-Initializes RoadStops. This includes clearing all slots that vehicles might
- * have and unlinks it from the linked list of road stops at the given station
+ * De-Initializes RoadStops.
  */
 RoadStop::~RoadStop()
 {
 	if (CleaningPool()) return;
-
-	/* Clear the slot assignment of all vehicles heading for this road stop */
-	if (this->num_vehicles != 0) {
-		RoadVehicle *rv;
-		FOR_ALL_ROADVEHICLES(rv) {
-			if (rv->slot == this) ClearSlot(rv);
-		}
-	}
-	assert(this->num_vehicles == 0);
 }
 
 /**
--- a/src/roadstop_base.h
+++ b/src/roadstop_base.h
@@ -29,11 +29,9 @@
 	};
 
 	static const uint LIMIT           = 16;  ///< The maximum amount of roadstops that are allowed at a single station
-	static const uint MAX_VEHICLES    = 64;  ///< The maximum number of vehicles that can allocate a slot to this roadstop
 
 	TileIndex        xy;                    ///< Position on the map
 	byte             status;                ///< Current status of the Stop, @see RoadStopSatusFlag. Access using *Bay and *Busy functions.
-	byte             num_vehicles;          ///< Number of vehicles currently slotted to this stop
 	struct RoadStop  *next;                 ///< Next stop of the given type at this station
 
 	/** Initializes a RoadStop */
--- a/src/roadveh.h
+++ b/src/roadveh.h
@@ -102,8 +102,6 @@
 	byte overtaking_ctr;
 	uint16 crashed_ctr;
 	byte reverse_ctr;
-	struct RoadStop *slot;
-	byte slot_age;
 
 	RoadType roadtype;
 	RoadTypes compatible_roadtypes;
@@ -130,7 +128,6 @@
 	Trackdir GetVehicleTrackdir() const;
 	TileIndex GetOrderStationLocation(StationID station);
 	bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
-	void FindRoadStopSlot();
 
 	bool IsBus() const;
 
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -14,7 +14,6 @@
 #include "roadveh.h"
 #include "command_func.h"
 #include "news_func.h"
-#include "pathfinder/npf/npf.h"
 #include "pathfinder/npf/npf_func.h"
 #include "station_base.h"
 #include "company_func.h"
@@ -313,20 +312,6 @@
 	return cost;
 }
 
-void ClearSlot(RoadVehicle *v)
-{
-	RoadStop *rs = v->slot;
-	if (v->slot == NULL) return;
-
-	v->slot = NULL;
-	v->slot_age = 0;
-
-	assert(rs->num_vehicles != 0);
-	rs->num_vehicles--;
-
-	DEBUG(ms, 3, "Clearing slot at 0x%X", rs->xy);
-}
-
 bool RoadVehicle::IsStoppedInDepot() const
 {
 	TileIndex tile = this->tile;
@@ -572,8 +557,6 @@
 		MarkSingleVehicleDirty(u);
 	}
 
-	ClearSlot(v);
-
 	SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
 	AI::NewEvent(v->owner, new AIEventVehicleCrashed(v->index, v->tile, AIEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING));
@@ -645,14 +628,14 @@
 {
 	if (station == this->last_station_visited) this->last_station_visited = INVALID_STATION;
 
-	TileIndex dest;
-	if (YapfFindNearestRoadVehicleCompatibleStop(this, station, &dest)) {
-		return dest;
-	} else {
+	const Station *st = Station::Get(station);
+	if (!CanVehicleUseStation(this, st)) {
 		/* There is no stop left at the station, so don't even TRY to go there */
 		this->IncrementOrderIndex();
 		return 0;
 	}
+
+	return st->xy;
 }
 
 static void StartRoadVehSound(const RoadVehicle *v)
@@ -1041,28 +1024,6 @@
 	return best_track;
 }
 
-static uint RoadFindPathToStop(const RoadVehicle *v, TileIndex tile)
-{
-	if (_settings_game.pf.pathfinder_for_roadvehs == VPF_YAPF) {
-		/* use YAPF */
-		return YapfRoadVehDistanceToTile(v, tile);
-	}
-
-	/* use NPF */
-	Trackdir trackdir = v->GetVehicleTrackdir();
-	assert(trackdir != INVALID_TRACKDIR);
-
-	NPFFindStationOrTileData fstd;
-	fstd.dest_coords = tile;
-	fstd.station_index = INVALID_STATION; // indicates that the destination is a tile, not a station
-
-	uint dist = NPFRouteToStationOrTile(v->tile, trackdir, false, &fstd, TRANSPORT_ROAD, v->compatible_roadtypes, v->owner, INVALID_RAILTYPES).best_path_dist;
-	/* change units from NPF_TILE_LENGTH to # of tiles */
-	if (dist != UINT_MAX) dist = (dist + NPF_TILE_LENGTH - 1) / NPF_TILE_LENGTH;
-
-	return dist;
-}
-
 struct RoadDriveEntry {
 	byte x, y;
 };
@@ -1520,13 +1481,9 @@
 				if (IsDriveThroughStopTile(next_tile) && (GetRoadStopType(next_tile) == type) && GetStationIndex(v->tile) == GetStationIndex(next_tile)) {
 					RoadStop *rs_n = RoadStop::GetByTile(next_tile, type);
 
-					if (rs_n->IsFreeBay(HasBit(v->state, RVS_USING_SECOND_BAY)) && rs_n->num_vehicles < RoadStop::MAX_VEHICLES) {
+					if (rs_n->IsFreeBay(HasBit(v->state, RVS_USING_SECOND_BAY))) {
 						/* Bay in next stop along is free - use it */
-						ClearSlot(v);
-						rs_n->num_vehicles++;
-						v->slot = rs_n;
 						v->dest_tile = rs_n->xy;
-						v->slot_age = 14;
 
 						v->frame++;
 						RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y, false));
@@ -1552,37 +1509,10 @@
 				return false;
 			}
 			v->current_order.Free();
-			ClearSlot(v);
 		}
 
 		if (IsStandardRoadStopTile(v->tile)) rs->SetEntranceBusy(true);
 
-		if (rs == v->slot) {
-			/* We are leaving the correct station */
-			ClearSlot(v);
-		} else if (v->slot != NULL) {
-			/* We are leaving the wrong station
-			 * XXX The question is .. what to do? Actually we shouldn't be here
-			 * but I guess we need to clear the slot */
-			DEBUG(ms, 0, "Vehicle %d (index %d) arrived at wrong stop", v->unitnumber, v->index);
-			if (v->tile != v->dest_tile) {
-				DEBUG(ms, 2, " current tile 0x%X is not destination tile 0x%X. Route problem", v->tile, v->dest_tile);
-			}
-			if (v->dest_tile != v->slot->xy) {
-				DEBUG(ms, 2, " stop tile 0x%X is not destination tile 0x%X. Multistop desync", v->slot->xy, v->dest_tile);
-			}
-			if (!v->current_order.IsType(OT_GOTO_STATION)) {
-				DEBUG(ms, 2, " current order type (%d) is not OT_GOTO_STATION", v->current_order.GetType());
-			} else {
-				if (v->current_order.GetDestination() != st->index)
-					DEBUG(ms, 2, " current station %d is not target station in current_order.station (%d)",
-							st->index, v->current_order.GetDestination());
-			}
-
-			DEBUG(ms, 2, " force a slot clearing");
-			ClearSlot(v);
-		}
-
 		StartRoadVehSound(v);
 		SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 	}
@@ -1597,7 +1527,6 @@
 
 	if (v->current_order.IsType(OT_LEAVESTATION) && IsDriveThroughStopTile(v->tile)) {
 		v->current_order.Free();
-		ClearSlot(v);
 	}
 
 	/* Move to next frame unless vehicle arrived at a stop position
@@ -1696,7 +1625,7 @@
 	static const uint MAX_ACCEPTABLE_DEPOT_DIST = 16;
 
 	/* If we already got a slot at a stop, use that FIRST, and go to a depot later */
-	if (v->slot != NULL || Company::Get(v->owner)->settings.vehicle.servint_roadveh == 0 || !v->NeedsAutomaticServicing()) return;
+	if (Company::Get(v->owner)->settings.vehicle.servint_roadveh == 0 || !v->NeedsAutomaticServicing()) return;
 	if (v->IsInDepot()) {
 		VehicleServiceInDepot(v);
 		return;
@@ -1724,7 +1653,6 @@
 	}
 
 	if (v->current_order.IsType(OT_LOADING)) v->LeaveStation();
-	ClearSlot(v);
 
 	v->current_order.MakeGoToDepot(depot, ODTFB_SERVICE);
 	v->dest_tile = rfdd.tile;
@@ -1743,16 +1671,6 @@
 
 	CheckOrders(this);
 
-	/* Current slot has expired */
-	if (this->current_order.IsType(OT_GOTO_STATION) && this->slot != NULL && this->slot_age-- == 0) {
-		DEBUG(ms, 3, "Slot expired for vehicle %d (index %d) at stop 0x%X",
-			this->unitnumber, this->index, this->slot->xy);
-		ClearSlot(this);
-	}
-
-	/* update destination */
-	this->FindRoadStopSlot();
-
 	if (this->running_ticks == 0) return;
 
 	CommandCost cost(EXPENSES_ROADVEH_RUN, this->GetRunningCost() * this->running_ticks / (DAYS_IN_YEAR * DAY_TICKS));
@@ -1766,77 +1684,6 @@
 	SetWindowClassesDirty(WC_ROADVEH_LIST);
 }
 
-void RoadVehicle::FindRoadStopSlot()
-{
-	if (this->slot != NULL ||
-			(this->vehstatus & (VS_STOPPED | VS_CRASHED)) != 0 ||
-			!this->current_order.IsType(OT_GOTO_STATION) ||
-			(this->current_order.GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0) {
-		return;
-	}
-
-	Station *st = Station::Get(this->current_order.GetDestination());
-	RoadStop *rs = st->GetPrimaryRoadStop(this);
-	RoadStop *best = NULL;
-
-	if (rs == NULL) {
-		DEBUG(ms, 4, "No road stop for vehicle %d (index %d) at station %d (0x%X)",
-				this->unitnumber, this->index, st->index, st->xy);
-		return;
-	}
-
-	/* We try to obtain a slot if:
-	 * 1) we're reasonably close to the primary road stop
-	 * or
-	 * 2) we're somewhere close to the station rectangle (to make sure we do assign
-	 *    slots even if the station and its road stops are incredibly spread out)
-	 */
-	if (DistanceManhattan(this->tile, rs->xy) < 16 || st->rect.PtInExtendedRect(TileX(this->tile), TileY(this->tile), 2)) {
-		uint dist, badness;
-		uint minbadness = UINT_MAX;
-
-		DEBUG(ms, 2, "Attempting to obtain a slot for vehicle %d (index %d) at station %d (0x%X)",
-			this->unitnumber, this->index, st->index, st->xy
-		);
-		/* Now we find the nearest road stop that has a free slot */
-		for (; rs != NULL; rs = rs->GetNextRoadStop(this)) {
-			if (rs->num_vehicles >= RoadStop::MAX_VEHICLES) {
-				DEBUG(ms, 4, " stop 0x%X's queue is full, not treating further", rs->xy);
-				continue;
-			}
-			dist = RoadFindPathToStop(this, rs->xy);
-			if (dist == UINT_MAX) {
-				DEBUG(ms, 4, " stop 0x%X is unreachable, not treating further", rs->xy);
-				continue;
-			}
-			badness = (rs->num_vehicles + 1) * (rs->num_vehicles + 1) + dist;
-
-			DEBUG(ms, 4, " stop 0x%X has %d vehicle%s waiting", rs->xy, rs->num_vehicles, rs->num_vehicles == 1 ? "":"s");
-			DEBUG(ms, 4, " distance is %u", dist);
-			DEBUG(ms, 4, " badness %u", badness);
-
-			if (badness < minbadness) {
-				best = rs;
-				minbadness = badness;
-			}
-		}
-
-		if (best != NULL) {
-			best->num_vehicles++;
-			DEBUG(ms, 3, "Assigned to stop 0x%X", best->xy);
-
-			this->slot = best;
-			this->dest_tile = best->xy;
-			this->slot_age = 14;
-		} else {
-			DEBUG(ms, 3, "Could not find a suitable stop");
-		}
-	} else {
-		DEBUG(ms, 5, "Distance from station too far. Postponing slotting for vehicle %d (index %d) at station %d, (0x%X)",
-				this->unitnumber, this->index, st->index, st->xy);
-	}
-}
-
 Trackdir RoadVehicle::GetVehicleTrackdir() const
 {
 	if (this->vehstatus & VS_CRASHED) return INVALID_TRACKDIR;
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -1088,13 +1088,6 @@
 		RoadVehicle *rv;
 		FOR_ALL_ROADVEHICLES(rv) {
 			rv->vehstatus &= ~0x40;
-			rv->slot = NULL;
-			rv->slot_age = 0;
-		}
-	} else {
-		RoadVehicle *rv;
-		FOR_ALL_ROADVEHICLES(rv) {
-			if (rv->slot != NULL) rv->slot->num_vehicles++;
 		}
 	}
 
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -558,9 +558,9 @@
 		     SLE_VAR(RoadVehicle, crashed_ctr,          SLE_UINT16),
 		     SLE_VAR(RoadVehicle, reverse_ctr,          SLE_UINT8),
 
-		 SLE_CONDREF(RoadVehicle, slot,                 REF_ROADSTOPS,                6, SL_MAX_VERSION),
-		SLE_CONDNULL(1,                                                               6, SL_MAX_VERSION),
-		 SLE_CONDVAR(RoadVehicle, slot_age,             SLE_UINT8,                    6, SL_MAX_VERSION),
+		SLE_CONDNULL(2,                                                               6,  68),
+		SLE_CONDNULL(4,                                                              69, 130),
+		SLE_CONDNULL(2,                                                               6, 130),
 		/* reserve extra space in savegame here. (currently 16 bytes) */
 		SLE_CONDNULL(16,                                                              2, SL_MAX_VERSION),
 
--- a/src/station_func.h
+++ b/src/station_func.h
@@ -40,8 +40,6 @@
 RoadStop *GetRoadStopByTile(TileIndex tile, RoadStopType type);
 uint GetNumRoadStops(const Station *st, RoadStopType type);
 
-void ClearSlot(struct RoadVehicle *v);
-
 void DeleteOilRig(TileIndex t);
 
 /* Check if a rail station tile is traversable. */
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -1412,7 +1412,6 @@
 				rv->state = _road_exit_tunnel_state[dir];
 				rv->frame = _road_exit_tunnel_frame[dir];
 				rv->vehstatus &= ~VS_HIDDEN;
-				rv->FindRoadStopSlot();
 				return VETSB_ENTERED_WORMHOLE;
 			}
 		}
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -496,7 +496,6 @@
 		if (this->IsPrimaryVehicle()) DecreaseGroupNumVehicle(this->group_id);
 	}
 
-	if (this->type == VEH_ROAD) ClearSlot(RoadVehicle::From(this));
 	if (this->type == VEH_AIRCRAFT && this->IsPrimaryVehicle()) {
 		Aircraft *a = Aircraft::From(this);
 		Station *st = GetTargetAirportIfValid(a);