summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-12-02 18:18:56 +0000
committerrubidium <rubidium@openttd.org>2009-12-02 18:18:56 +0000
commit0ef0e1379534c6372ea93790c1e4b0855c8077d1 (patch)
treed044e4280831f6afdf44626ee303896ef8570c6b
parent429f3993f8dc380780a23a6f46420797a9a8a11c (diff)
downloadopenttd-0ef0e1379534c6372ea93790c1e4b0855c8077d1.tar.xz
(svn r18385) -Cleanup: remove the now unneeded multistop slot management code
-rw-r--r--src/debug.h1
-rw-r--r--src/order_cmd.cpp3
-rw-r--r--src/pathfinder/yapf/yapf.h15
-rw-r--r--src/pathfinder/yapf/yapf_road.cpp146
-rw-r--r--src/roadstop.cpp12
-rw-r--r--src/roadstop_base.h2
-rw-r--r--src/roadveh.h3
-rw-r--r--src/roadveh_cmd.cpp165
-rw-r--r--src/saveload/afterload.cpp7
-rw-r--r--src/saveload/vehicle_sl.cpp6
-rw-r--r--src/station_func.h2
-rw-r--r--src/tunnelbridge_cmd.cpp1
-rw-r--r--src/vehicle.cpp1
13 files changed, 10 insertions, 354 deletions
diff --git a/src/debug.h b/src/debug.h
index b17597d80..62c493d77 100644
--- 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;
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index a912b328f..7e1ac02c5 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -788,8 +788,6 @@ CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
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 @@ bool ProcessOrders(Vehicle *v)
v->current_order.Free();
v->dest_tile = 0;
- if (v->type == VEH_ROAD) ClearSlot(RoadVehicle::From(v));
return false;
}
diff --git a/src/pathfinder/yapf/yapf.h b/src/pathfinder/yapf/yapf.h
index c7ddb3d6e..1f7b4a6a5 100644
--- a/src/pathfinder/yapf/yapf.h
+++ b/src/pathfinder/yapf/yapf.h
@@ -49,21 +49,6 @@ Trackdir YapfRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDi
*/
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
diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp
index 5ca3b1441..a565def27 100644
--- a/src/pathfinder/yapf/yapf_road.cpp
+++ b/src/pathfinder/yapf/yapf_road.cpp
@@ -185,78 +185,6 @@ public:
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 @@ public:
*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 CYapfRoad2 : CYapfT<CYapfRoad_TypesT<CYapfRoad2 , CRoadNod
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 @@ Trackdir YapfRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDi
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 @@ FindDepotData YapfRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_dist
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;
-}
diff --git a/src/roadstop.cpp b/src/roadstop.cpp
index 969c1d21d..67b54fdbd 100644
--- a/src/roadstop.cpp
+++ b/src/roadstop.cpp
@@ -19,21 +19,11 @@ RoadStopPool _roadstop_pool("RoadStop");
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);
}
/**
diff --git a/src/roadstop_base.h b/src/roadstop_base.h
index 7104713bf..4548de4bf 100644
--- a/src/roadstop_base.h
+++ b/src/roadstop_base.h
@@ -29,11 +29,9 @@ struct RoadStop : RoadStopPool::PoolItem<&_roadstop_pool> {
};
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 */
diff --git a/src/roadveh.h b/src/roadveh.h
index e1c8ef123..9eb610a70 100644
--- a/src/roadveh.h
+++ b/src/roadveh.h
@@ -102,8 +102,6 @@ struct RoadVehicle : public SpecializedVehicle<RoadVehicle, VEH_ROAD> {
byte overtaking_ctr;
uint16 crashed_ctr;
byte reverse_ctr;
- struct RoadStop *slot;
- byte slot_age;
RoadType roadtype;
RoadTypes compatible_roadtypes;
@@ -130,7 +128,6 @@ struct RoadVehicle : public SpecializedVehicle<RoadVehicle, VEH_ROAD> {
Trackdir GetVehicleTrackdir() const;
TileIndex GetOrderStationLocation(StationID station);
bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
- void FindRoadStopSlot();
bool IsBus() const;
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 5ccb779e8..92b10b5ff 100644
--- 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 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
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 @@ static void RoadVehCrash(RoadVehicle *v)
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 @@ TileIndex RoadVehicle::GetOrderStationLocation(StationID station)
{
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 @@ found_best_track:;
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 @@ again:
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 @@ again:
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 @@ again:
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 void CheckIfRoadVehNeedsService(RoadVehicle *v)
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 @@ static void CheckIfRoadVehNeedsService(RoadVehicle *v)
}
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 @@ void RoadVehicle::OnNewDay()
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 @@ void RoadVehicle::OnNewDay()
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;
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 438c1069a..2d7013291 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -1088,13 +1088,6 @@ bool AfterLoadGame()
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++;
}
}
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index e08e533fc..cf646141e 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -558,9 +558,9 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
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),
diff --git a/src/station_func.h b/src/station_func.h
index 22a7cf79a..59ffb2ad1 100644
--- a/src/station_func.h
+++ b/src/station_func.h
@@ -40,8 +40,6 @@ bool HasStationInUse(StationID station, CompanyID company);
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. */
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 1f3bfdcc6..f627a0bd2 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -1412,7 +1412,6 @@ static VehicleEnterTileStatus VehicleEnter_TunnelBridge(Vehicle *v, TileIndex ti
rv->state = _road_exit_tunnel_state[dir];
rv->frame = _road_exit_tunnel_frame[dir];
rv->vehstatus &= ~VS_HIDDEN;
- rv->FindRoadStopSlot();
return VETSB_ENTERED_WORMHOLE;
}
}
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index bee83a84c..ab4af88bb 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -496,7 +496,6 @@ void Vehicle::PreDestructor()
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);