MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CanExpandRailStation

Function CanExpandRailStation

src/station_cmd.cpp:1192–1209  ·  view source on GitHub ↗

* Check whether we can expand the rail part of the given station. * @param st the station to expand * @param new_ta the current (and if all is fine new) tile area of the rail part of the station * @return Succeeded or failed command. */

Source from the content-addressed store, hash-verified

1190 * @return Succeeded or failed command.
1191 */
1192CommandCost CanExpandRailStation(const BaseStation *st, TileArea &new_ta)
1193{
1194 TileArea cur_ta = st->train_station;
1195
1196 /* determine new size of train station region.. */
1197 int x = std::min(TileX(cur_ta.tile), TileX(new_ta.tile));
1198 int y = std::min(TileY(cur_ta.tile), TileY(new_ta.tile));
1199 new_ta.w = std::max(TileX(cur_ta.tile) + cur_ta.w, TileX(new_ta.tile) + new_ta.w) - x;
1200 new_ta.h = std::max(TileY(cur_ta.tile) + cur_ta.h, TileY(new_ta.tile) + new_ta.h) - y;
1201 new_ta.tile = TileXY(x, y);
1202
1203 /* make sure the final size is not too big. */
1204 if (new_ta.w > _settings_game.station.station_spread || new_ta.h > _settings_game.station.station_spread) {
1205 return CommandCost(STR_ERROR_STATION_TOO_SPREAD_OUT);
1206 }
1207
1208 return CommandCost();
1209}
1210
1211RailStationTileLayout::RailStationTileLayout(const StationSpec *spec, uint8_t platforms, uint8_t length) : platforms(platforms), length(length)
1212{

Callers 2

CmdBuildRailWaypointFunction · 0.85
CmdBuildRailStationFunction · 0.85

Calls 4

TileXFunction · 0.85
TileYFunction · 0.85
TileXYFunction · 0.85
CommandCostClass · 0.85

Tested by

no test coverage detected