summaryrefslogtreecommitdiff
path: root/src/train_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r--src/train_cmd.cpp92
1 files changed, 3 insertions, 89 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index e641c484d..a58bf0172 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -11,7 +11,6 @@
#include "gui.h"
#include "station_map.h"
#include "tunnel_map.h"
-#include "timetable.h"
#include "articulated_vehicles.h"
#include "command_func.h"
#include "pathfind.h"
@@ -2616,94 +2615,9 @@ bad:;
return reverse_best != 0;
}
-static bool ProcessTrainOrder(Vehicle *v)
+TileIndex Train::GetOrderStationLocation(StationID station)
{
- switch (v->current_order.type) {
- case OT_GOTO_DEPOT:
- if (!(v->current_order.flags & OFB_PART_OF_ORDERS)) return false;
- if ((v->current_order.flags & OFB_SERVICE_IF_NEEDED) &&
- !VehicleNeedsService(v)) {
- UpdateVehicleTimetable(v, true);
- v->cur_order_index++;
- }
- break;
-
- case OT_LOADING:
- case OT_LEAVESTATION:
- return false;
-
- default: break;
- }
-
- /**
- * Reversing because of order change is allowed only just after leaving a
- * station (and the difficulty setting to allowed, of course)
- * this can be detected because only after OT_LEAVESTATION, current_order
- * will be reset to nothing. (That also happens if no order, but in that case
- * it won't hit the point in code where may_reverse is checked)
- */
- bool may_reverse = v->current_order.type == OT_NOTHING;
-
- /* check if we've reached the waypoint? */
- if (v->current_order.type == OT_GOTO_WAYPOINT && v->tile == v->dest_tile) {
- UpdateVehicleTimetable(v, true);
- v->cur_order_index++;
- }
-
- /* check if we've reached a non-stop station while TTDPatch nonstop is enabled.. */
- if (_patches.new_nonstop &&
- v->current_order.flags & OFB_NON_STOP &&
- IsTileType(v->tile, MP_STATION) &&
- v->current_order.dest == GetStationIndex(v->tile)) {
- UpdateVehicleTimetable(v, true);
- v->cur_order_index++;
- }
-
- /* Get the current order */
- if (v->cur_order_index >= v->num_orders) v->cur_order_index = 0;
-
- const Order *order = GetVehicleOrder(v, v->cur_order_index);
-
- /* If no order, do nothing. */
- if (order == NULL) {
- v->current_order.Free();
- v->dest_tile = 0;
- return false;
- }
-
- /* If it is unchanged, keep it. */
- 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. */
- v->current_order = *order;
-
- v->dest_tile = 0;
-
- InvalidateVehicleOrder(v);
-
- switch (order->type) {
- case OT_GOTO_STATION:
- if (order->dest == v->last_station_visited)
- v->last_station_visited = INVALID_STATION;
- v->dest_tile = GetStation(order->dest)->xy;
- break;
-
- case OT_GOTO_DEPOT:
- v->dest_tile = GetDepot(order->dest)->xy;
- break;
-
- case OT_GOTO_WAYPOINT:
- v->dest_tile = GetWaypoint(order->dest)->xy;
- break;
-
- default:
- return false;
- }
-
- return may_reverse && CheckReverseTrain(v);
+ return GetStation(station)->xy;
}
void Train::MarkDirty()
@@ -3565,7 +3479,7 @@ static void TrainLocoHandler(Vehicle *v, bool mode)
/* exit if train is stopped */
if (v->vehstatus & VS_STOPPED && v->cur_speed == 0) return;
- if (ProcessTrainOrder(v)) {
+ if (ProcessOrders(v) && CheckReverseTrain(v)) {
v->load_unload_time_rem = 0;
v->cur_speed = 0;
v->subspeed = 0;