@@ -919,12 +919,14 @@ CommandCost CmdBuildRailroadStation(Tile
} else {
h_org = plat_len;
w_org = numtracks;
}
StationID station_to_join = GB(p2, 16, 16);
bool reuse = (station_to_join != NEW_STATION);
if (!reuse) station_to_join = INVALID_STATION;
bool distant_join = (station_to_join != INVALID_STATION);
if (distant_join && (!_settings_game.station.distant_join_stations || !IsValidStationID(station_to_join))) return CMD_ERROR;
if (h_org > _settings_game.station.station_spread || w_org > _settings_game.station.station_spread) return CMD_ERROR;
@@ -972,13 +974,13 @@ CommandCost CmdBuildRailroadStation(Tile
/* Distant join */
if (st == NULL && distant_join) st = GetStation(station_to_join);
/* See if there is a deleted station close to us. */
if (st == NULL) st = GetClosestDeletedStation(tile_org);
if (st == NULL && reuse) st = GetClosestDeletedStation(tile_org);
if (st != NULL) {
/* Reuse an existing station. */
if (st->owner != _current_company)
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
@@ -1400,12 +1402,14 @@ CommandCost CmdBuildRoadStop(TileIndex t
{
bool type = HasBit(p2, 0);
bool is_drive_through = HasBit(p2, 1);
bool build_over_road = is_drive_through && IsNormalRoadTile(tile);
RoadTypes rts = (RoadTypes)GB(p2, 2, 2);
Owner tram_owner = _current_company;
Owner road_owner = _current_company;
@@ -1467,13 +1471,13 @@ CommandCost CmdBuildRoadStop(TileIndex t
/* Find a deleted station close to us */
if (st == NULL) st = GetClosestDeletedStation(tile);
if (st == NULL && reuse) st = GetClosestDeletedStation(tile);
/* give us a road stop in the list, and check if something went wrong */
if (!RoadStop::CanAllocateItem()) return_cmd_error(type ? STR_TOO_MANY_TRUCK_STOPS : STR_TOO_MANY_BUS_STOPS);
if (st != NULL &&
GetNumRoadStopsInStation(st, ROADSTOP_BUS) + GetNumRoadStopsInStation(st, ROADSTOP_TRUCK) >= RoadStop::LIMIT) {
@@ -1852,12 +1856,14 @@ void UpdateAirportsNoise()
* - p2 = (bit 16-31) - station ID to join (INVALID_STATION if build new one)
*/
CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
bool airport_upgrade = true;
/* Check if a valid, buildable airport was chosen for construction */
if (p1 > lengthof(_airport_sections) || !HasBit(GetValidAirports(), p1)) return CMD_ERROR;
@@ -1916,13 +1922,13 @@ CommandCost CmdBuildAirport(TileIndex ti
if (st->owner != _current_company) {
@@ -2172,12 +2178,14 @@ static const byte _dock_h_chk[4] = { 1,
* @param p1 (bit 0) - allow docks directly adjacent to other docks.
* @param p2 bit 16-31: station ID to join (INVALID_STATION if build new one)
CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
DiagDirection direction = GetInclinedSlopeDirection(GetTileSlope(tile, NULL));
if (direction == INVALID_DIAGDIR) return_cmd_error(STR_304B_SITE_UNSUITABLE);
@@ -2221,13 +2229,13 @@ CommandCost CmdBuildDock(TileIndex tile,
@@ -1167,13 +1167,13 @@ struct SelectStationWindow : Window {
if (distant_join) st_index--;
if (distant_join && st_index >= _stations_nearby_list.Length()) return;
/* Insert station to be joined into stored command */
SB(this->select_station_cmd.p2, 16, 16,
(distant_join ? _stations_nearby_list[st_index] : INVALID_STATION));
(distant_join ? _stations_nearby_list[st_index] : NEW_STATION));
/* Execute stored Command */
DoCommandP(&this->select_station_cmd);
/* Close Window; this might cause double frees! */
DeleteWindowById(WC_SELECT_STATION, 0);
@@ -9,12 +9,13 @@ typedef uint16 StationID;
typedef uint16 RoadStopID;
struct Station;
struct RoadStop;
struct StationSpec;
static const StationID NEW_STATION = 0xFFFE;
static const StationID INVALID_STATION = 0xFFFF;
/** Station types */
enum StationType {
STATION_RAIL,
STATION_AIRPORT,
Status change: