@@ -316,6 +316,8 @@ AIIndustry.IsCargoAccepted <- function(i
return AIIndustry._IsCargoAccepted(industry_id, cargo_id) != AIIndustry.CAS_NOT_ACCEPTED;
}
AIAbstractList <- AIList;
AIList.ChangeItem <- AIList.SetValue;
AIRail.ERR_NONUNIFORM_STATIONS_DISABLED <- 0xFFFF;
@@ -67,6 +67,8 @@ AIIndustry.IsCargoAccepted <- function(i
@@ -30,12 +30,13 @@
* \li AITown::IsCity
*
* API removals:
* \li HasNext for all lists.
* \li AIAbstractList, use AIList instead.
* \li AIList::ChangeItem, use AIList::SetValue instead.
* \li AIRail::ERR_NONUNIFORM_STATIONS_DISABLED, that error is never returned anymore.
* Other changes:
* \li AIEngine::GetMaxTractiveEffort can be used for road vehicles.
* \li AIEngine::GetPower can be used for road vehicles.
* \li AIEngine::GetWeight can be used for road vehicles.
* \li AIIndustry::IsCargoAccepted now returns CargoAcceptState instead of a boolean.
@@ -32,15 +32,12 @@ public:
/** One-way roads cannot have crossings */
ERR_CROSSING_ON_ONEWAY_ROAD, // [STR_ERROR_CROSSING_ON_ONEWAY_ROAD]
/** Track not suitable for signals */
ERR_UNSUITABLE_TRACK, // [STR_ERROR_NO_SUITABLE_RAILROAD_TRACK]
/** Non-uniform stations is diabled */
ERR_NONUNIFORM_STATIONS_DISABLED, // [STR_ERROR_NONUNIFORM_STATIONS_DISALLOWED]
/** This railtype cannot have crossings */
ERR_RAILTYPE_DISALLOWS_CROSSING, // [STR_ERROR_CROSSING_DISALLOWED]
};
/**
* Types of rail known to the game.
@@ -35,52 +35,49 @@ namespace SQConvert {
void SQAIRail_Register(Squirrel *engine)
{
DefSQClass <AIRail> SQAIRail("AIRail");
SQAIRail.PreRegister(engine);
SQAIRail.AddConstructor<void (AIRail::*)(), 1>(engine, "x");
SQAIRail.DefSQConst(engine, AIRail::ERR_RAIL_BASE, "ERR_RAIL_BASE");
SQAIRail.DefSQConst(engine, AIRail::ERR_CROSSING_ON_ONEWAY_ROAD, "ERR_CROSSING_ON_ONEWAY_ROAD");
SQAIRail.DefSQConst(engine, AIRail::ERR_UNSUITABLE_TRACK, "ERR_UNSUITABLE_TRACK");
SQAIRail.DefSQConst(engine, AIRail::ERR_NONUNIFORM_STATIONS_DISABLED, "ERR_NONUNIFORM_STATIONS_DISABLED");
SQAIRail.DefSQConst(engine, AIRail::ERR_RAILTYPE_DISALLOWS_CROSSING, "ERR_RAILTYPE_DISALLOWS_CROSSING");
SQAIRail.DefSQConst(engine, AIRail::RAILTYPE_INVALID, "RAILTYPE_INVALID");
SQAIRail.DefSQConst(engine, AIRail::RAILTRACK_NE_SW, "RAILTRACK_NE_SW");
SQAIRail.DefSQConst(engine, AIRail::RAILTRACK_NW_SE, "RAILTRACK_NW_SE");
SQAIRail.DefSQConst(engine, AIRail::RAILTRACK_NW_NE, "RAILTRACK_NW_NE");
SQAIRail.DefSQConst(engine, AIRail::RAILTRACK_SW_SE, "RAILTRACK_SW_SE");
SQAIRail.DefSQConst(engine, AIRail::RAILTRACK_NW_SW, "RAILTRACK_NW_SW");
SQAIRail.DefSQConst(engine, AIRail::RAILTRACK_NE_SE, "RAILTRACK_NE_SE");
SQAIRail.DefSQConst(engine, AIRail::RAILTRACK_INVALID, "RAILTRACK_INVALID");
SQAIRail.DefSQConst(engine, AIRail::SIGNALTYPE_NORMAL, "SIGNALTYPE_NORMAL");
SQAIRail.DefSQConst(engine, AIRail::SIGNALTYPE_ENTRY, "SIGNALTYPE_ENTRY");
SQAIRail.DefSQConst(engine, AIRail::SIGNALTYPE_EXIT, "SIGNALTYPE_EXIT");
SQAIRail.DefSQConst(engine, AIRail::SIGNALTYPE_COMBO, "SIGNALTYPE_COMBO");
SQAIRail.DefSQConst(engine, AIRail::SIGNALTYPE_PBS, "SIGNALTYPE_PBS");
SQAIRail.DefSQConst(engine, AIRail::SIGNALTYPE_PBS_ONEWAY, "SIGNALTYPE_PBS_ONEWAY");
SQAIRail.DefSQConst(engine, AIRail::SIGNALTYPE_TWOWAY, "SIGNALTYPE_TWOWAY");
SQAIRail.DefSQConst(engine, AIRail::SIGNALTYPE_NORMAL_TWOWAY, "SIGNALTYPE_NORMAL_TWOWAY");
SQAIRail.DefSQConst(engine, AIRail::SIGNALTYPE_ENTRY_TWOWAY, "SIGNALTYPE_ENTRY_TWOWAY");
SQAIRail.DefSQConst(engine, AIRail::SIGNALTYPE_EXIT_TWOWAY, "SIGNALTYPE_EXIT_TWOWAY");
SQAIRail.DefSQConst(engine, AIRail::SIGNALTYPE_COMBO_TWOWAY, "SIGNALTYPE_COMBO_TWOWAY");
SQAIRail.DefSQConst(engine, AIRail::SIGNALTYPE_NONE, "SIGNALTYPE_NONE");
SQAIRail.DefSQConst(engine, AIRail::BT_TRACK, "BT_TRACK");
SQAIRail.DefSQConst(engine, AIRail::BT_SIGNAL, "BT_SIGNAL");
SQAIRail.DefSQConst(engine, AIRail::BT_DEPOT, "BT_DEPOT");
SQAIRail.DefSQConst(engine, AIRail::BT_STATION, "BT_STATION");
SQAIRail.DefSQConst(engine, AIRail::BT_WAYPOINT, "BT_WAYPOINT");
AIError::RegisterErrorMap(STR_ERROR_CROSSING_ON_ONEWAY_ROAD, AIRail::ERR_CROSSING_ON_ONEWAY_ROAD);
AIError::RegisterErrorMap(STR_ERROR_NO_SUITABLE_RAILROAD_TRACK, AIRail::ERR_UNSUITABLE_TRACK);
AIError::RegisterErrorMap(STR_ERROR_NONUNIFORM_STATIONS_DISALLOWED, AIRail::ERR_NONUNIFORM_STATIONS_DISABLED);
AIError::RegisterErrorMap(STR_ERROR_CROSSING_DISALLOWED, AIRail::ERR_RAILTYPE_DISALLOWS_CROSSING);
AIError::RegisterErrorMapString(AIRail::ERR_CROSSING_ON_ONEWAY_ROAD, "ERR_CROSSING_ON_ONEWAY_ROAD");
AIError::RegisterErrorMapString(AIRail::ERR_UNSUITABLE_TRACK, "ERR_UNSUITABLE_TRACK");
AIError::RegisterErrorMapString(AIRail::ERR_NONUNIFORM_STATIONS_DISABLED, "ERR_NONUNIFORM_STATIONS_DISABLED");
AIError::RegisterErrorMapString(AIRail::ERR_RAILTYPE_DISALLOWS_CROSSING, "ERR_RAILTYPE_DISALLOWS_CROSSING");
SQAIRail.DefSQStaticMethod(engine, &AIRail::GetName, "GetName", 2, ".i");
SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailTile, "IsRailTile", 2, ".i");
SQAIRail.DefSQStaticMethod(engine, &AIRail::IsLevelCrossingTile, "IsLevelCrossingTile", 2, ".i");
SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailDepotTile, "IsRailDepotTile", 2, ".i");
SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailStationTile, "IsRailStationTile", 2, ".i");
@@ -1133,13 +1133,12 @@ STR_CONFIG_SETTING_STOP_LOCATION_MIDDLE
STR_CONFIG_SETTING_STOP_LOCATION_FAR_END :far end
STR_CONFIG_SETTING_ROAD_VEHICLE_QUEUEING :{LTBLUE}Road vehicle queueing (with quantum effects): {ORANGE}{STRING1}
STR_CONFIG_SETTING_AUTOSCROLL :{LTBLUE}Pan window when mouse is at the edge: {ORANGE}{STRING1}
STR_CONFIG_SETTING_BRIBE :{LTBLUE}Allow bribing of the local authority: {ORANGE}{STRING1}
STR_CONFIG_SETTING_ALLOW_EXCLUSIVE :{LTBLUE}Allow buying exclusive transport rights: {ORANGE}{STRING1}
STR_CONFIG_SETTING_ALLOW_GIVE_MONEY :{LTBLUE}Allow sending money to other companies: {ORANGE}{STRING1}
STR_CONFIG_SETTING_NONUNIFORM_STATIONS :{LTBLUE}Nonuniform stations: {ORANGE}{STRING1}
STR_CONFIG_SETTING_FREIGHT_TRAINS :{LTBLUE}Weight multiplier for freight to simulate heavy trains: {ORANGE}{STRING}
STR_CONFIG_SETTING_PLANE_SPEED :{LTBLUE}Plane speed factor: {ORANGE}1 / {STRING1}
STR_CONFIG_SETTING_PLANE_CRASHES :{LTBLUE}Number of plane crashes: {ORANGE}{STRING1}
STR_CONFIG_SETTING_PLANE_CRASHES_NONE :none
STR_CONFIG_SETTING_PLANE_CRASHES_REDUCED :reduced
STR_CONFIG_SETTING_PLANE_CRASHES_NORMAL :normal
@@ -3545,13 +3544,12 @@ STR_ERROR_CAN_T_BUILD_PASSENGER_TRAM_STA
STR_ERROR_CAN_T_BUILD_CARGO_TRAM_STATION :{WHITE}Can't build freight tram station...
STR_ERROR_CAN_T_BUILD_DOCK_HERE :{WHITE}Can't build dock here...
STR_ERROR_CAN_T_BUILD_AIRPORT_HERE :{WHITE}Can't build airport here...
STR_ERROR_ADJOINS_MORE_THAN_ONE_EXISTING :{WHITE}Adjoins more than one existing station/loading area
STR_ERROR_STATION_TOO_SPREAD_OUT :{WHITE}... station too spread out
STR_ERROR_NONUNIFORM_STATIONS_DISALLOWED :{WHITE}... nonuniform stations disabled
STR_ERROR_TOO_MANY_STATIONS_LOADING :{WHITE}Too many stations/loading areas
STR_ERROR_TOO_MANY_STATION_SPECS :{WHITE}Too many railway station parts
STR_ERROR_TOO_MANY_BUS_STOPS :{WHITE}Too many bus stops
STR_ERROR_TOO_MANY_TRUCK_STOPS :{WHITE}Too many lorry stations
STR_ERROR_TOO_CLOSE_TO_ANOTHER_RAILROAD :{WHITE}Too close to another railway station
STR_ERROR_TOO_CLOSE_TO_ANOTHER_STATION :{WHITE}Too close to another station/loading area
@@ -6962,13 +6962,13 @@ static void InitializeGRFSpecial()
| ((_settings_game.order.improved_load ? 1 : 0) << 0x08) // fifoloading
| (0 << 0x09) // townroadbranchprob
| (0 << 0x0A) // tempsnowline
| (1 << 0x0B) // newcargo
| (1 << 0x0C) // enhancemultiplayer
| (1 << 0x0D) // onewayroads
| ((_settings_game.station.nonuniform_stations ? 1 : 0) << 0x0E) // irregularstations
| (1 << 0x0E) // irregularstations
| (1 << 0x0F) // statistics
| (1 << 0x10) // newsounds
| (1 << 0x11) // autoreplace
| (1 << 0x12) // autoslope
| (0 << 0x13) // followvehicle
| (1 << 0x14) // trams
@@ -1353,13 +1353,12 @@ static SettingEntry _settings_stations_c
/** Cargo handling sub-page */
static SettingsPage _settings_stations_cargo_page = {_settings_stations_cargo, lengthof(_settings_stations_cargo)};
static SettingEntry _settings_stations[] = {
SettingEntry(&_settings_stations_cargo_page, STR_CONFIG_SETTING_STATIONS_CARGOHANDLING),
SettingEntry("station.join_stations"),
SettingEntry("station.nonuniform_stations"),
SettingEntry("station.adjacent_stations"),
SettingEntry("station.distant_join_stations"),
SettingEntry("station.station_spread"),
SettingEntry("economy.station_noise_level"),
SettingEntry("station.modified_catchment"),
SettingEntry("construction.road_stop_on_town_road"),
@@ -385,13 +385,12 @@ struct EconomySettings {
/** Settings related to stations. */
struct StationSettings {
bool modified_catchment; ///< different-size catchment areas
bool join_stations; ///< allow joining of train stations
bool nonuniform_stations; ///< allow nonuniform train stations
bool adjacent_stations; ///< allow stations to be built directly adjacent to other stations
bool distant_join_stations; ///< allow to join non-adjacent stations
bool never_expire_airports; ///< never expire airports
byte station_spread; ///< amount a station may spread
@@ -930,52 +930,19 @@ static CommandCost CheckFlatLandRoadStop
* @return Succeeded or failed command.
*/
CommandCost CanExpandRailStation(const BaseStation *st, TileArea &new_ta, Axis axis)
TileArea cur_ta = st->train_station;
if (_settings_game.station.nonuniform_stations) {
/* determine new size of train station region.. */
int x = min(TileX(cur_ta.tile), TileX(new_ta.tile));
int y = min(TileY(cur_ta.tile), TileY(new_ta.tile));
new_ta.w = max(TileX(cur_ta.tile) + cur_ta.w, TileX(new_ta.tile) + new_ta.w) - x;
new_ta.h = max(TileY(cur_ta.tile) + cur_ta.h, TileY(new_ta.tile) + new_ta.h) - y;
new_ta.tile = TileXY(x, y);
} else {
/* do not allow modifying non-uniform stations,
* the uniform-stations code wouldn't handle it well */
TILE_AREA_LOOP(t, cur_ta) {
if (!st->TileBelongsToRailStation(t)) { // there may be adjoined station
return_cmd_error(STR_ERROR_NONUNIFORM_STATIONS_DISALLOWED);
/* check so the orientation is the same */
if (GetRailStationAxis(cur_ta.tile) != axis) {
/* check if the new station adjoins the old station in either direction */
if (cur_ta.w == new_ta.w && cur_ta.tile == new_ta.tile + TileDiffXY(0, new_ta.h)) {
/* above */
new_ta.h += cur_ta.h;
} else if (cur_ta.w == new_ta.w && cur_ta.tile == new_ta.tile - TileDiffXY(0, cur_ta.h)) {
/* below */
new_ta.tile = cur_ta.tile;
new_ta.h += new_ta.h;
} else if (cur_ta.h == new_ta.h && cur_ta.tile == new_ta.tile + TileDiffXY(new_ta.w, 0)) {
/* to the left */
new_ta.w += cur_ta.w;
} else if (cur_ta.h == new_ta.h && cur_ta.tile == new_ta.tile - TileDiffXY(cur_ta.w, 0)) {
/* to the right */
/* make sure the final size is not too big. */
if (new_ta.w > _settings_game.station.station_spread || new_ta.h > _settings_game.station.station_spread) {
return_cmd_error(STR_ERROR_STATION_TOO_SPREAD_OUT);
return CommandCost();
@@ -1162,13 +1129,13 @@ CommandCost CmdBuildRailStation(TileInde
TileArea new_location(tile_org, w_org, h_org);
/* Make sure the area below consists of clear tiles. (OR tiles belonging to a certain rail station) */
StationID est = INVALID_STATION;
SmallVector<Train *, 4> affected_vehicles;
/* Clear the land below the station. */
CommandCost cost = CheckFlatLandRailStation(TileArea(tile_org, w_org, h_org), flags, 5 << axis, _settings_game.station.nonuniform_stations ? &est : NULL, rt, affected_vehicles);
CommandCost cost = CheckFlatLandRailStation(TileArea(tile_org, w_org, h_org), flags, 5 << axis, &est, rt, affected_vehicles);
if (cost.Failed()) return cost;
/* Add construction expenses. */
cost.AddCost((numtracks * _price[PR_BUILD_STATION_RAIL] + _price[PR_BUILD_STATION_RAIL_LENGTH]) * plat_len);
cost.AddCost(numtracks * plat_len * RailBuildCost(rt));
Station *st = NULL;
@@ -1405,17 +1372,12 @@ CommandCost RemoveFromRailBaseStation(Ti
if (_current_company != OWNER_WATER) {
CommandCost ret = CheckOwnership(st->owner);
if (ret.Failed()) continue;
/* Do not allow removing from stations if non-uniform stations are not enabled
* The check must be here to give correct error message
if (!_settings_game.station.nonuniform_stations) return_cmd_error(STR_ERROR_NONUNIFORM_STATIONS_DISALLOWED);
/* If we reached here, the tile is valid so increase the quantity of tiles we will remove */
quantity++;
if (keep_rail || IsStationTileBlocked(tile)) {
/* Don't refund the 'steel' of the track when we keep the
* rail, or when the tile didn't have any rail at all. */
@@ -1569,13 +1531,13 @@ CommandCost RemoveRailStation(T *st, DoC
assert(ta.w != 0 && ta.h != 0);
CommandCost cost(EXPENSES_CONSTRUCTION);
/* clear all areas of the station */
TILE_AREA_LOOP(tile, ta) {
/* for nonuniform stations, only remove tiles that are actually train station tiles */
/* only remove tiles that are actually train station tiles */
if (!st->TileBelongsToRailStation(tile)) continue;
CommandCost ret = EnsureNoVehicleOnGround(tile);
if (ret.Failed()) return ret;
cost.AddCost(_price[PR_CLEAR_STATION_RAIL]);
@@ -1621,14 +1583,14 @@ CommandCost RemoveRailStation(T *st, DoC
* @param tile TileIndex been queried
* @param flags operation to perform
* @return cost or failure of operation
static CommandCost RemoveRailStation(TileIndex tile, DoCommandFlag flags)
/* if there is flooding and non-uniform stations are enabled, remove platforms tile by tile */
if (_current_company == OWNER_WATER && _settings_game.station.nonuniform_stations) {
/* if there is flooding, remove platforms tile by tile */
if (_current_company == OWNER_WATER) {
return DoCommand(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAIL_STATION);
Station *st = Station::GetByTile(tile);
CommandCost cost = RemoveRailStation(st, flags);
@@ -1642,14 +1604,14 @@ static CommandCost RemoveRailStation(Til
static CommandCost RemoveRailWaypoint(TileIndex tile, DoCommandFlag flags)
/* if there is flooding and non-uniform stations are enabled, remove waypoints tile by tile */
/* if there is flooding, remove waypoints tile by tile */
return DoCommand(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAIL_WAYPOINT);
return RemoveRailStation(Waypoint::GetByTile(tile), flags);
@@ -426,13 +426,13 @@ const SettingDesc _settings[] = {
SDT_BOOL(GameSettings, station.join_stations, 0, 0, true, STR_CONFIG_SETTING_JOINSTATIONS, NULL),
SDTC_CONDBOOL( gui.sg_full_load_any, 22, 92, 0, 0, true, STR_NULL, NULL),
SDT_BOOL(GameSettings, order.improved_load, 0,NN, true, STR_CONFIG_SETTING_IMPROVEDLOAD, NULL),
SDT_BOOL(GameSettings, order.selectgoods, 0, 0, true, STR_CONFIG_SETTING_SELECTGOODS, NULL),
SDTC_CONDBOOL( gui.sg_new_nonstop, 22, 92, 0, 0, false, STR_NULL, NULL),
SDT_BOOL(GameSettings, station.nonuniform_stations, 0,NN, true, STR_CONFIG_SETTING_NONUNIFORM_STATIONS, NULL),
SDT_CONDNULL( 1, 0, 158), // station.nonuniform_stations
SDT_VAR(GameSettings, station.station_spread, SLE_UINT8, 0, 0, 12, 4, 64, 0, STR_CONFIG_SETTING_STATION_SPREAD, InvalidateStationBuildWindow),
SDT_BOOL(GameSettings, order.serviceathelipad, 0, 0, true, STR_CONFIG_SETTING_SERVICEATHELIPAD, NULL),
SDT_BOOL(GameSettings, station.modified_catchment, 0, 0, true, STR_CONFIG_SETTING_CATCHMENT, StationCatchmentChanged),
SDT_CONDBOOL(GameSettings, order.gradual_loading, 40, SL_MAX_VERSION, 0,NN, true, STR_CONFIG_SETTING_GRADUAL_LOADING, NULL),
SDT_CONDBOOL(GameSettings, construction.road_stop_on_town_road, 47, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_SETTING_STOP_ON_TOWN_ROAD, NULL),
SDT_CONDBOOL(GameSettings, construction.road_stop_on_competitor_road, 114, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_SETTING_STOP_ON_COMPETITOR_ROAD,NULL),
@@ -899,25 +899,12 @@ static void FloodVehicles(TileIndex tile
/* No vehicle could be flooded on this airport anymore */
return;
/* if non-uniform stations are disabled, flood some train in this train station (if there is any) */
if (!_settings_game.station.nonuniform_stations && IsTileType(tile, MP_STATION) && GetStationType(tile) == STATION_RAIL) {
const Station *st = Station::GetByTile(tile);
TILE_AREA_LOOP(t, st->train_station) {
if (st->TileBelongsToRailStation(t)) {
FindVehicleOnPos(tile, &z, &FloodVehicleProc);
if (!IsBridgeTile(tile)) {
TileIndex end = GetOtherBridgeEnd(tile);
@@ -187,13 +187,13 @@ CommandCost CmdBuildRailWaypoint(TileInd
/* Check whether the tiles we're building on are valid rail or not. */
TileIndexDiff offset = TileOffsByDiagDir(AxisToDiagDir(OtherAxis(axis)));
for (int i = 0; i < count; i++) {
TileIndex tile = start_tile + i * offset;
CommandCost ret = IsValidTileForWaypoint(tile, axis, _settings_game.station.nonuniform_stations ? &est : NULL);
CommandCost ret = IsValidTileForWaypoint(tile, axis, &est);
Waypoint *wp = NULL;
TileArea new_location(TileArea(start_tile, width, height));
CommandCost ret = FindJoiningWaypoint(est, station_to_join, adjacent, new_location, &wp);
Status change: