diff options
author | JMcKiern <jmckiern@tcd.ie> | 2019-09-04 21:47:21 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-09-04 22:47:21 +0200 |
commit | fbbbc6e1931df7d4281432c5a14d10c17f4464aa (patch) | |
tree | 6115313180de933ff9babff8af6b333e73d44aa9 | |
parent | c4850475c3b91099afc6b7149fc77d0b4746cf72 (diff) | |
download | openttd-fbbbc6e1931df7d4281432c5a14d10c17f4464aa.tar.xz |
Fix #7692: Added industry tile to GetOrderCmdFromTile() (#7709)
Sending order command to an industry tile now checks if a neutral_station is available and sends the order to that station
-rw-r--r-- | src/order_gui.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 7cf7a9ba9..fa56f70cb 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -24,6 +24,7 @@ #include "tilehighlight_func.h" #include "network/network.h" #include "station_base.h" +#include "industry.h" #include "waypoint_base.h" #include "core/geometry_func.hpp" #include "hotkeys.h" @@ -389,11 +390,17 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) return order; } - if (IsTileType(tile, MP_STATION)) { - StationID st_index = GetStationIndex(tile); - const Station *st = Station::Get(st_index); + /* check for station or industry with neutral station */ + if (IsTileType(tile, MP_STATION) || IsTileType(tile, MP_INDUSTRY)) { + const Station *st = nullptr; - if (st->owner == _local_company || st->owner == OWNER_NONE) { + if (IsTileType(tile, MP_STATION)) { + st = Station::GetByTile(tile); + } else { + const Industry *in = Industry::GetByTile(tile); + st = in->neutral_station; + } + if (st != nullptr && (st->owner == _local_company || st->owner == OWNER_NONE)) { byte facil; switch (v->type) { case VEH_SHIP: facil = FACIL_DOCK; break; @@ -403,6 +410,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) default: NOT_REACHED(); } if (st->facilities & facil) { + StationID st_index = GetStationIndex(st->xy); order.MakeGoToStation(st_index); if (_ctrl_pressed) order.SetLoadType(OLF_FULL_LOAD_ANY); if (_settings_client.gui.new_nonstop && v->IsGroundVehicle()) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS); |