diff options
author | rubidium <rubidium@openttd.org> | 2008-04-05 15:30:15 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-04-05 15:30:15 +0000 |
commit | ed2acd6f3da6572839e57423f95625093f245aa1 (patch) | |
tree | 57bb3ebb25557e1d6fcad5c15f3dac0e731a4475 /src/order_cmd.cpp | |
parent | f8b2e84537fce4c436e6c2db74f967d7e9347e95 (diff) | |
download | openttd-ed2acd6f3da6572839e57423f95625093f245aa1.tar.xz |
(svn r12580) -Codechange: merge some logical related to non-stop orders.
Diffstat (limited to 'src/order_cmd.cpp')
-rw-r--r-- | src/order_cmd.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 871124959..775e08f0f 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -1343,6 +1343,7 @@ bool ProcessOrders(Vehicle *v) v->current_order.flags & OFB_NON_STOP && IsTileType(v->tile, MP_STATION) && v->current_order.dest == GetStationIndex(v->tile)) { + v->last_station_visited = v->current_order.dest; UpdateVehicleTimetable(v, true); v->cur_order_index++; } @@ -1414,6 +1415,23 @@ bool ProcessOrders(Vehicle *v) return may_reverse; } +/** + * Check whether the given vehicle should stop at the given station + * based on this order and the non-stop settings. + * @param v the vehicle that might be stopping. + * @param station the station to stop at. + * @return true if the vehicle should stop. + */ +bool Order::ShouldStopAtStation(const Vehicle *v, StationID station) const +{ + return + v->last_station_visited != station && // Do stop only when we've not just been there + type == OT_GOTO_STATION && // Do stop only when going to a station + /* Finally do stop when the non-stop flag is not set, or when we should stop at + * this station according to the new_nonstop setting. */ + (!this->flags & OFB_NON_STOP || ((this->dest != station) == _patches.new_nonstop)); +} + void InitializeOrders() { _Order_pool.CleanPool(); |