summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-01-11 16:33:03 +0000
committerfrosch <frosch@openttd.org>2009-01-11 16:33:03 +0000
commit83467061b7e08e159f7a27c88c5c6fbce0186cd5 (patch)
tree73f8c8645fba7dae8e9bbb20bae74b9023711b5a /src
parent5719596ce2eba88730b32d99c1bea6a2f5846ec2 (diff)
downloadopenttd-83467061b7e08e159f7a27c88c5c6fbce0186cd5.tar.xz
(svn r14994) -Fix [FS#Aali]: Better handling of OT_LOADING and OT_LEAVESTATION in ChooseTrainTrack.
Diffstat (limited to 'src')
-rw-r--r--src/train_cmd.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 787ace3e4..e0ac2db42 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -2847,11 +2847,12 @@ public:
/**
* Set the current vehicle order to the next order in the order list.
+ * @param skip_first Shall the first (i.e. active) order be skipped?
* @return True if a suitable next order could be found.
*/
- bool SwitchToNextOrder()
+ bool SwitchToNextOrder(bool skip_first)
{
- ++this->index;
+ if (skip_first) ++this->index;
int conditional_depth = 0;
@@ -2951,11 +2952,13 @@ static Track ChooseTrainTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir
* for a path and no look-ahead is necessary. This also avoids a
* problem with depot orders not part of the order list when the
* order list itself is empty. */
- if (!v->current_order.IsType(OT_GOTO_DEPOT) && (
+ if (v->current_order.IsType(OT_LEAVESTATION)) {
+ orders.SwitchToNextOrder(false);
+ } else if (v->current_order.IsType(OT_LOADING) || (!v->current_order.IsType(OT_GOTO_DEPOT) && (
v->current_order.IsType(OT_GOTO_STATION) ?
IsRailwayStationTile(v->tile) && v->current_order.GetDestination() == GetStationIndex(v->tile) :
- v->tile == v->dest_tile)) {
- orders.SwitchToNextOrder();
+ v->tile == v->dest_tile))) {
+ orders.SwitchToNextOrder(true);
}
if (res_dest.tile != INVALID_TILE && !res_dest.okay) {
@@ -3032,7 +3035,7 @@ static Track ChooseTrainTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir
}
/* Get next order with destination. */
- if (orders.SwitchToNextOrder()) {
+ if (orders.SwitchToNextOrder(true)) {
PBSTileInfo cur_dest;
DoTrainPathfind(v, next_tile, exitdir, reachable, NULL, true, &cur_dest);
if (cur_dest.tile != INVALID_TILE) {