1
0
Fork 0

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
pull/7721/head
JMcKiern 2019-09-04 21:47:21 +01:00 committed by Niels Martin Hansen
parent c4850475c3
commit fbbbc6e193
1 changed files with 12 additions and 4 deletions

View File

@ -24,6 +24,7 @@
#include "tilehighlight_func.h" #include "tilehighlight_func.h"
#include "network/network.h" #include "network/network.h"
#include "station_base.h" #include "station_base.h"
#include "industry.h"
#include "waypoint_base.h" #include "waypoint_base.h"
#include "core/geometry_func.hpp" #include "core/geometry_func.hpp"
#include "hotkeys.h" #include "hotkeys.h"
@ -389,11 +390,17 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
return order; return order;
} }
if (IsTileType(tile, MP_STATION)) { /* check for station or industry with neutral station */
StationID st_index = GetStationIndex(tile); if (IsTileType(tile, MP_STATION) || IsTileType(tile, MP_INDUSTRY)) {
const Station *st = Station::Get(st_index); 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; byte facil;
switch (v->type) { switch (v->type) {
case VEH_SHIP: facil = FACIL_DOCK; break; case VEH_SHIP: facil = FACIL_DOCK; break;
@ -403,6 +410,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
default: NOT_REACHED(); default: NOT_REACHED();
} }
if (st->facilities & facil) { if (st->facilities & facil) {
StationID st_index = GetStationIndex(st->xy);
order.MakeGoToStation(st_index); order.MakeGoToStation(st_index);
if (_ctrl_pressed) order.SetLoadType(OLF_FULL_LOAD_ANY); 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); if (_settings_client.gui.new_nonstop && v->IsGroundVehicle()) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);