summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/road_cmd.cpp2
-rw-r--r--src/vehicle.cpp5
3 files changed, 5 insertions, 4 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 453414fde..24792baab 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -2419,7 +2419,7 @@ static VehicleEnterTileStatus VehicleEnter_Track(Vehicle *u, TileIndex tile, int
v->track = TRACK_BIT_DEPOT,
v->vehstatus |= VS_HIDDEN; // hide it
v->direction = ReverseDir(v->direction);
- if (v->Next() == NULL) VehicleEnterDepot(v);
+ if (v->Next() == NULL) VehicleEnterDepot(v->First());
v->tile = tile;
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 8f561c222..754d6fd97 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -1550,7 +1550,7 @@ static VehicleEnterTileStatus VehicleEnter_Road(Vehicle *v, TileIndex tile, int
rv->state = RVSB_IN_DEPOT;
rv->vehstatus |= VS_HIDDEN;
rv->direction = ReverseDir(rv->direction);
- if (rv->Next() == NULL) VehicleEnterDepot(rv);
+ if (rv->Next() == NULL) VehicleEnterDepot(rv->First());
rv->tile = tile;
InvalidateWindowData(WC_VEHICLE_DEPOT, rv->tile);
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index a8509e18a..3b858e60d 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -954,6 +954,9 @@ uint8 CalcPercentVehicleFilled(const Vehicle *v, StringID *colour)
void VehicleEnterDepot(Vehicle *v)
{
+ /* Always work with the front of the vehicle */
+ assert(v == v->First());
+
switch (v->type) {
case VEH_TRAIN: {
Train *t = Train::From(v);
@@ -962,7 +965,6 @@ void VehicleEnterDepot(Vehicle *v)
SetDepotReservation(t->tile, false);
if (_settings_client.gui.show_track_reservation) MarkTileDirtyByTile(t->tile);
- if (!t->IsFrontEngine()) t = t->First();
UpdateSignalsOnSegment(t->tile, INVALID_DIAGDIR, t->owner);
t->load_unload_time_rem = 0;
ClrBit(t->flags, VRF_TOGGLE_REVERSE);
@@ -972,7 +974,6 @@ void VehicleEnterDepot(Vehicle *v)
case VEH_ROAD:
InvalidateWindowClasses(WC_ROADVEH_LIST);
- if (!RoadVehicle::From(v)->IsRoadVehFront()) v = v->First();
break;
case VEH_SHIP: