OpenTTD
|
Handling of station tiles. More...
#include "stdafx.h"
#include "aircraft.h"
#include "bridge_map.h"
#include "cmd_helper.h"
#include "viewport_func.h"
#include "command_func.h"
#include "town.h"
#include "news_func.h"
#include "train.h"
#include "ship.h"
#include "roadveh.h"
#include "industry.h"
#include "newgrf_cargo.h"
#include "newgrf_debug.h"
#include "newgrf_station.h"
#include "newgrf_canal.h"
#include "pathfinder/yapf/yapf_cache.h"
#include "road_internal.h"
#include "autoslope.h"
#include "water.h"
#include "strings_func.h"
#include "clear_func.h"
#include "date_func.h"
#include "vehicle_func.h"
#include "string_func.h"
#include "animated_tile_func.h"
#include "elrail_func.h"
#include "station_base.h"
#include "roadstop_base.h"
#include "newgrf_railtype.h"
#include "waypoint_base.h"
#include "waypoint_func.h"
#include "pbs.h"
#include "debug.h"
#include "core/random_func.hpp"
#include "company_base.h"
#include "table/airporttile_ids.h"
#include "newgrf_airporttiles.h"
#include "order_backup.h"
#include "newgrf_house.h"
#include "company_gui.h"
#include "linkgraph/linkgraph_base.h"
#include "linkgraph/refresh.h"
#include "widgets/station_widget.h"
#include "table/strings.h"
#include "safeguards.h"
#include "table/station_land.h"
Go to the source code of this file.
Data Structures | |
struct | StationNameInformation |
Information to handle station action 0 property 24 correctly. More... |
Macros | |
#define | M(x) ((x) - STR_SV_STNAME) |
Typedefs | |
typedef bool(* | CMSAMatcher )(TileIndex tile) |
Function to check whether the given tile matches some criterion. |
Enumerations | |
enum | StationNaming { STATIONNAMING_RAIL, STATIONNAMING_ROAD, STATIONNAMING_AIRPORT, STATIONNAMING_OILRIG, STATIONNAMING_DOCK, STATIONNAMING_HELIPORT } |
Functions | |
bool | IsHangar (TileIndex t) |
Check whether the given tile is a hangar. | |
template<class T > | |
CommandCost | GetStationAround (TileArea ta, StationID closest_station, T **st) |
Look for a station around the given tile area. | |
static int | CountMapSquareAround (TileIndex tile, CMSAMatcher cmp) |
Counts the numbers of tiles matching a specific type in the area around. | |
static bool | CMSAMine (TileIndex tile) |
Check whether the tile is a mine. | |
static bool | CMSAWater (TileIndex tile) |
Check whether the tile is water. | |
static bool | CMSATree (TileIndex tile) |
Check whether the tile is a tree. | |
static bool | FindNearIndustryName (TileIndex tile, void *user_data) |
Find a station action 0 property 24 station name, or reduce the free_names if needed. | |
static StringID | GenerateStationName (Station *st, TileIndex tile, StationNaming name_class) |
static Station * | GetClosestDeletedStation (TileIndex tile) |
Find the closest deleted station of the current company. | |
void | UpdateAllStationVirtCoords () |
Update the virtual coords needed to draw the station sign for all stations. | |
static uint | GetAcceptanceMask (const Station *st) |
Get a mask of the cargo types that the station accepts. | |
static void | ShowRejectOrAcceptNews (const Station *st, uint num_items, CargoID *cargo, StringID msg) |
Items contains the two cargo names that are to be accepted or rejected. | |
CargoArray | GetProductionAroundTiles (TileIndex tile, int w, int h, int rad) |
Get the cargo types being produced around the tile (in a rectangle). | |
CargoArray | GetAcceptanceAroundTiles (TileIndex tile, int w, int h, int rad, uint32 *always_accepted) |
Get the acceptance of cargoes around the tile in 1/8. | |
void | UpdateStationAcceptance (Station *st, bool show_msg) |
Update the acceptance for a station. | |
static void | UpdateStationSignCoord (BaseStation *st) |
static CommandCost | BuildStationPart (Station **st, DoCommandFlag flags, bool reuse, TileArea area, StationNaming name_class) |
Common part of building various station parts and possibly attaching them to an existing one. | |
static void | DeleteStationIfEmpty (BaseStation *st) |
This is called right after a station was deleted. | |
CommandCost | ClearTile_Station (TileIndex tile, DoCommandFlag flags) |
Clear a single tile of a station. | |
CommandCost | CheckBuildableTile (TileIndex tile, uint invalid_dirs, int &allowed_z, bool allow_steep, bool check_bridge=true) |
Checks if the given tile is buildable, flat and has a certain height. | |
CommandCost | CheckFlatLand (TileArea tile_area, DoCommandFlag flags) |
Tries to clear the given area. | |
static CommandCost | CheckFlatLandRailStation (TileArea tile_area, DoCommandFlag flags, Axis axis, StationID *station, RailType rt, SmallVector< Train *, 4 > &affected_vehicles, StationClassID spec_class, byte spec_index, byte plat_len, byte numtracks) |
Checks if a rail station can be built at the given area. | |
static CommandCost | CheckFlatLandRoadStop (TileArea tile_area, DoCommandFlag flags, uint invalid_dirs, bool is_drive_through, bool is_truck_stop, Axis axis, StationID *station, RoadTypes rts) |
Checks if a road stop can be built at the given tile. | |
CommandCost | CanExpandRailStation (const BaseStation *st, TileArea &new_ta, Axis axis) |
Check whether we can expand the rail part of the given station. | |
static byte * | CreateSingle (byte *layout, int n) |
static byte * | CreateMulti (byte *layout, int n, byte b) |
void | GetStationLayout (byte *layout, int numtracks, int plat_len, const StationSpec *statspec) |
Create the station layout for the given number of tracks and platform length. | |
template<class T , StringID error_message> | |
CommandCost | FindJoiningBaseStation (StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, T **st) |
Find a nearby station that joins this station. | |
static CommandCost | FindJoiningStation (StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, Station **st) |
Find a nearby station that joins this station. | |
CommandCost | FindJoiningWaypoint (StationID existing_waypoint, StationID waypoint_to_join, bool adjacent, TileArea ta, Waypoint **wp) |
Find a nearby waypoint that joins this waypoint. | |
CommandCost | CmdBuildRailStation (TileIndex tile_org, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Build rail station. | |
static void | MakeRailStationAreaSmaller (BaseStation *st) |
template<class T > | |
CommandCost | RemoveFromRailBaseStation (TileArea ta, SmallVector< T *, 4 > &affected_stations, DoCommandFlag flags, Money removal_cost, bool keep_rail) |
Remove a number of tiles from any rail station within the area. | |
CommandCost | CmdRemoveFromRailStation (TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Remove a single tile from a rail station. | |
CommandCost | CmdRemoveFromRailWaypoint (TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Remove a single tile from a waypoint. | |
template<class T > | |
CommandCost | RemoveRailStation (T *st, DoCommandFlag flags, Money removal_cost) |
Remove a rail station/waypoint. | |
static CommandCost | RemoveRailStation (TileIndex tile, DoCommandFlag flags) |
Remove a rail station. | |
static CommandCost | RemoveRailWaypoint (TileIndex tile, DoCommandFlag flags) |
Remove a rail waypoint. | |
static RoadStop ** | FindRoadStopSpot (bool truck_station, Station *st) |
static CommandCost | RemoveRoadStop (TileIndex tile, DoCommandFlag flags) |
Remove a bus station/truck stop. | |
static CommandCost | FindJoiningRoadStop (StationID existing_stop, StationID station_to_join, bool adjacent, TileArea ta, Station **st) |
Find a nearby station that joins this road stop. | |
CommandCost | CmdBuildRoadStop (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Build a bus or truck stop. | |
static Vehicle * | ClearRoadStopStatusEnum (Vehicle *v, void *) |
CommandCost | CmdRemoveRoadStop (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Remove bus or truck stops. | |
static uint | GetMinimalAirportDistanceToTile (TileIterator &it, TileIndex town_tile) |
Computes the minimal distance from town's xy to any airport's tile. | |
uint8 | GetAirportNoiseLevelForTown (const AirportSpec *as, TileIterator &it, TileIndex town_tile) |
Get a possible noise reduction factor based on distance from town center. | |
Town * | AirportGetNearestTown (const AirportSpec *as, const TileIterator &it) |
Finds the town nearest to given airport. | |
void | UpdateAirportsNoise () |
Recalculate the noise generated by the airports of each town. | |
CommandCost | CmdBuildAirport (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Place an Airport. | |
static CommandCost | RemoveAirport (TileIndex tile, DoCommandFlag flags) |
Remove an airport. | |
CommandCost | CmdOpenCloseAirport (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Open/close an airport to incoming aircraft. | |
bool | HasStationInUse (StationID station, bool include_company, CompanyID company) |
Tests whether the company's vehicles have this station in orders. | |
CommandCost | CmdBuildDock (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Build a dock/haven. | |
static CommandCost | RemoveDock (TileIndex tile, DoCommandFlag flags) |
Remove a dock. | |
const DrawTileSprites * | GetStationTileLayout (StationType st, byte gfx) |
bool | SplitGroundSpriteForOverlay (const TileInfo *ti, SpriteID *ground, RailTrackOffset *overlay_offset) |
Check whether a sprite is a track sprite, which can be replaced by a non-track ground sprite and a rail overlay. | |
static void | DrawTile_Station (TileInfo *ti) |
void | StationPickerDrawSprite (int x, int y, StationType st, RailType railtype, RoadType roadtype, int image) |
static int | GetSlopePixelZ_Station (TileIndex tile, uint x, uint y) |
static Foundation | GetFoundation_Station (TileIndex tile, Slope tileh) |
static void | GetTileDesc_Station (TileIndex tile, TileDesc *td) |
static TrackStatus | GetTileTrackStatus_Station (TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side) |
static void | TileLoop_Station (TileIndex tile) |
static void | AnimateTile_Station (TileIndex tile) |
static bool | ClickTile_Station (TileIndex tile) |
static VehicleEnterTileStatus | VehicleEnter_Station (Vehicle *v, TileIndex tile, int x, int y) |
void | TriggerWatchedCargoCallbacks (Station *st) |
Run the watched cargo callback for all houses in the catchment area. | |
static bool | StationHandleBigTick (BaseStation *st) |
This function is called for each station once every 250 ticks. | |
static void | byte_inc_sat (byte *p) |
static void | TruncateCargo (const CargoSpec *cs, GoodsEntry *ge, uint amount=UINT_MAX) |
Truncate the cargo by a specific amount. | |
static void | UpdateStationRating (Station *st) |
void | RerouteCargo (Station *st, CargoID c, StationID avoid, StationID avoid2) |
Reroute cargo of type c at station st or in any vehicles unloading there. | |
void | DeleteStaleLinks (Station *from) |
Check all next hops of cargo packets in this station for existance of a a valid link they may use to travel on. | |
void | IncreaseStats (Station *st, CargoID cargo, StationID next_station_id, uint capacity, uint usage, EdgeUpdateMode mode) |
Increase capacity for a link stat given by station cargo and next hop. | |
void | IncreaseStats (Station *st, const Vehicle *front, StationID next_station_id) |
Increase capacity for all link stats associated with vehicles in the given consist. | |
static void | StationHandleSmallTick (BaseStation *st) |
void | OnTick_Station () |
void | StationMonthlyLoop () |
Monthly loop for stations. | |
void | ModifyStationRatingAround (TileIndex tile, Owner owner, int amount, uint radius) |
static uint | UpdateStationWaiting (Station *st, CargoID type, uint amount, SourceType source_type, SourceID source_id) |
static bool | IsUniqueStationName (const char *name) |
CommandCost | CmdRenameStation (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Rename a station. | |
void | FindStationsAroundTiles (const TileArea &location, StationList *stations) |
Find all stations around a rectangular producer (industry, house, headquarter, ...) | |
uint | MoveGoodsToStation (CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations) |
void | BuildOilRig (TileIndex tile) |
void | DeleteOilRig (TileIndex tile) |
static void | ChangeTileOwner_Station (TileIndex tile, Owner old_owner, Owner new_owner) |
static bool | CanRemoveRoadWithStop (TileIndex tile, DoCommandFlag flags) |
Check if a drive-through road stop tile can be cleared. | |
static CommandCost | TerraformTile_Station (TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new) |
Variables | |
static const TileIndexDiffC | _dock_tileoffs_chkaround [] |
static const byte | _dock_w_chk [4] = { 2, 1, 2, 1 } |
static const byte | _dock_h_chk [4] = { 1, 2, 1, 2 } |
const TileTypeProcs | _tile_type_station_procs |
Handling of station tiles.
Definition in file station_cmd.cpp.
typedef bool(* CMSAMatcher)(TileIndex tile) |
Function to check whether the given tile matches some criterion.
tile | the tile to check |
Definition at line 127 of file station_cmd.cpp.
Town* AirportGetNearestTown | ( | const AirportSpec * | as, |
const TileIterator & | it | ||
) |
Finds the town nearest to given airport.
Based on minimal manhattan distance to any airport's tile. If two towns have the same distance, town with lower index is returned.
as | airport's description |
it | An iterator over all airport tiles |
Definition at line 2133 of file station_cmd.cpp.
References TileIterator::Clone(), DistanceManhattan(), GetMinimalAirportDistanceToTile(), AirportSpec::size_x, AirportSpec::size_y, and Town::xy.
Referenced by CmdBuildAirport(), RemoveAirport(), and UpdateAirportsNoise().
|
static |
Common part of building various station parts and possibly attaching them to an existing one.
[in,out] | st | Station to attach to |
flags | Command flags | |
reuse | Whether to try to reuse a deleted station (gray sign) if possible | |
area | Area occupied by the new part | |
name_class | Station naming class to use to generate the new station's name |
Definition at line 672 of file station_cmd.cpp.
References _current_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_station_pool >::CanAllocateItem(), ClosestTownFromTile(), DC_EXEC, CommandCost::Failed(), GetClosestDeletedStation(), OrthogonalTileArea::h, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), return_cmd_error, SetBit(), OrthogonalTileArea::tile, and OrthogonalTileArea::w.
Referenced by CmdBuildAirport(), CmdBuildDock(), CmdBuildRailStation(), and CmdBuildRoadStop().
CommandCost CanExpandRailStation | ( | const BaseStation * | st, |
TileArea & | new_ta, | ||
Axis | axis | ||
) |
Check whether we can expand the rail part of the given station.
st | the station to expand |
new_ta | the current (and if all is fine new) tile area of the rail part of the station |
axis | the axis of the newly build rail |
Definition at line 1000 of file station_cmd.cpp.
References _settings_game, OrthogonalTileArea::h, max(), min(), return_cmd_error, GameSettings::station, StationSettings::station_spread, OrthogonalTileArea::tile, TileX(), TileXY(), TileY(), BaseStation::train_station, and OrthogonalTileArea::w.
Referenced by CmdBuildRailStation(), and CmdBuildRailWaypoint().
|
static |
Check if a drive-through road stop tile can be cleared.
Road stops built on town-owned roads check the conditions that would allow clearing of the original road.
tile | road stop tile to check |
flags | command flags |
Definition at line 4013 of file station_cmd.cpp.
References _current_company, CheckAllowRemoveRoad(), CheckOwnership(), GetAnyRoadBits(), GetRoadOwner(), GetRoadTypes(), HasBit(), OWNER_NONE, OWNER_TOWN, OWNER_WATER, ROADTYPE_ROAD, and ROADTYPE_TRAM.
Referenced by ClearTile_Station().
CommandCost CheckBuildableTile | ( | TileIndex | tile, |
uint | invalid_dirs, | ||
int & | allowed_z, | ||
bool | allow_steep, | ||
bool | check_bridge = true |
||
) |
Checks if the given tile is buildable, flat and has a certain height.
tile | TileIndex to check. |
invalid_dirs | Prohibited directions for slopes (set of DiagDirection). |
allowed_z | Height allowed for the tile. If allowed_z is negative, it will be set to the height of this tile. |
allow_steep | Whether steep slopes are allowed. |
check_bridge | Check for the existence of a bridge. |
Definition at line 729 of file station_cmd.cpp.
References _settings_game, CommandCost::AddCost(), ConstructionSettings::build_on_slopes, CanBuildDepotByTileh(), GameSettings::construction, DIAGDIR_BEGIN, DIAGDIR_END, EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), GetSlopeMaxZ(), GetTileSlope(), HasBit(), IsBridgeAbove(), IsSteepSlope(), return_cmd_error, and SLOPE_FLAT.
Referenced by CheckFlatLand(), CheckFlatLandRailStation(), CheckFlatLandRoadStop(), and CmdBuildObject().
CommandCost CheckFlatLand | ( | TileArea | tile_area, |
DoCommandFlag | flags | ||
) |
Tries to clear the given area.
tile_area | Area to check. |
flags | Operation to perform. |
Definition at line 779 of file station_cmd.cpp.
References CommandCost::AddCost(), CheckBuildableTile(), CMD_LANDSCAPE_CLEAR, DoCommand(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), and TILE_AREA_LOOP.
Referenced by CmdBuildAirport().
|
static |
Checks if a rail station can be built at the given area.
tile_area | Area to check. |
flags | Operation to perform. |
axis | Rail station axis. |
station | StationID to be queried and returned if available. |
rt | The rail type to check for (overbuilding rail stations over rail). |
affected_vehicles | List of trains with PBS reservations on the tiles |
spec_class | Station class. |
spec_index | Index into the station class. |
plat_len | Platform length. |
numtracks | Number of platforms. |
Definition at line 811 of file station_cmd.cpp.
References CommandCost::AddCost(), SmallVector< T, S >::Append(), StationSpec::callback_mask, CBM_STATION_SLOPE_CHECK, CheckBuildableTile(), ClearTile_Station(), CMD_LANDSCAPE_CLEAR, CMD_REMOVE_SINGLE_RAIL, DC_AUTO, DIAGDIR_NE, DoCommand(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), NewGRFClass< Tspec, Tid, Tmax >::Get(), GetRailReservationTrackBits(), GetRailType(), GetStationIndex(), GetTrackBits(), GetTrainForReservation(), HasBit(), HasPowerOnRail(), HasSignals(), INVALID_RAILTYPE, IsPlainRailTile(), IsRailStation(), IsTileType(), MP_STATION, PerformStationTileSlopeCheck(), RemoveFirstTrack(), return_cmd_error, OrthogonalTileArea::tile, TILE_AREA_LOOP, TRACK_BIT_NONE, TRACK_X, and TRACK_Y.
Referenced by CmdBuildRailStation().
|
static |
Checks if a road stop can be built at the given tile.
tile_area | Area to check. |
flags | Operation to perform. |
invalid_dirs | Prohibited directions (set of DiagDirections). |
is_drive_through | True if trying to build a drive-through station. |
is_truck_stop | True when building a truck stop, false otherwise. |
axis | Axis of a drive-through road stop. |
station | StationID to be queried and returned if available. |
rts | Road types to build. |
Definition at line 897 of file station_cmd.cpp.
References _settings_game, CommandCost::AddCost(), AXIS_X, CheckBuildableTile(), CheckOwnership(), ClearTile_Station(), CMD_LANDSCAPE_CLEAR, GameSettings::construction, CountBits(), DC_AUTO, DiagDirToAxis(), DoCommand(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), GetAllRoadBits(), GetRoadBits(), GetRoadOwner(), GetRoadStopDir(), GetRoadTypes(), GetStationIndex(), HasBit(), HasExactlyOneBit(), IsDriveThroughStopTile(), IsNormalRoadTile(), IsRoadStop(), IsTileType(), IsTruckStop(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), MP_STATION, OWNER_NONE, OWNER_TOWN, return_cmd_error, ROAD_NONE, ConstructionSettings::road_stop_on_competitor_road, ConstructionSettings::road_stop_on_town_road, ROAD_X, ROAD_Y, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_NONE, and TILE_AREA_LOOP.
Referenced by CmdBuildRoadStop().
CommandCost ClearTile_Station | ( | TileIndex | tile, |
DoCommandFlag | flags | ||
) |
Clear a single tile of a station.
tile | The tile to clear. |
flags | The DoCommand flags related to the "command". |
Definition at line 4041 of file station_cmd.cpp.
References CanRemoveRoadWithStop(), CMD_ERROR, DC_AUTO, GetStationType(), HasTileRoadType(), IsDriveThroughStopTile(), RemoveAirport(), RemoveBuoy(), RemoveDock(), RemoveRailStation(), RemoveRailWaypoint(), RemoveRoadStop(), return_cmd_error, ROADTYPE_TRAM, and SetDParam().
Referenced by CheckFlatLandRailStation(), CheckFlatLandRoadStop(), and IsValidTileForWaypoint().
CommandCost CmdBuildAirport | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Place an Airport.
tile | tile where airport will be built |
flags | operation to perform |
p1 |
|
p2 | various bitstuffed elements
|
text | unused |
Definition at line 2185 of file station_cmd.cpp.
References _settings_game, AAT_BUILT, OrthogonalTileArea::Add(), AddAnimatedTile(), CommandCost::AddCost(), Station::AddFacility(), AirportFTAClass::AIRPLANES, Station::airport, AirportGetNearestTown(), ANIM_STATUS_NO_ANIMATION, AirportTileSpec::animation, AT_OILRIG, BuildStationPart(), CheckFlatLand(), CheckIfAuthorityAllowsNewStation(), ClosestTownFromTile(), CMD_ERROR, DC_EXEC, DIR_E, DIR_W, DirtyCompanyInfrastructureWindows(), StationSettings::distant_join_stations, GameSettings::economy, FACIL_AIRPORT, BaseStation::facilities, CommandCost::Failed(), FindJoiningStation(), Airport::flags, GB(), AirportTileSpec::Get(), AirportSpec::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetAirport(), GetAirportNoiseLevelForTown(), SpecializedStation< Station, false >::GetIfValid(), AirportTileTableIterator::GetStationGfx(), GetTranslatedAirportTileID(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, InvalidateWindowData(), AirportSpec::IsAvailable(), SpecializedStation< Station, false >::IsValidID(), Airport::layout, MakeAirport(), Town::MaxTownNoise(), Town::noise_reached, NUM_AIRPORTS, AirportSpec::num_table, BaseStation::owner, Station::RecomputeIndustriesNear(), BaseStation::rect, return_cmd_error, AirportSpec::rotation, Airport::rotation, SetDParam(), SetStationTileRandomBits(), SetWindowDirty(), AirportSpec::size_x, AirportSpec::size_y, GameSettings::station, EconomySettings::station_noise_level, StationSettings::station_spread, AnimationInfo::status, Swap(), AirportSpec::table, OrthogonalTileArea::tile, BaseStation::town, Airport::type, UpdateAirplanesOnNewStation(), UpdateStationAcceptance(), Station::UpdateVirtCoord(), WATER_CLASS_INVALID, WC_SELECT_STATION, WC_STATION_LIST, WC_STATION_VIEW, WC_TOWN_VIEW, and Town::xy.
CommandCost CmdBuildDock | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Build a dock/haven.
tile | tile where dock will be built |
flags | operation to perform |
p1 | (bit 0) - allow docks directly adjacent to other docks. |
p2 | bit 16-31: station ID to join (NEW_STATION if build new one) |
text | unused |
Definition at line 2464 of file station_cmd.cpp.
References _settings_game, Station::AddFacility(), BuildStationPart(), CheckIfAuthorityAllowsNewStation(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, DC_EXEC, DirtyCompanyInfrastructureWindows(), StationSettings::distant_join_stations, Station::dock_tile, DoCommand(), EXPENSES_CONSTRUCTION, FACIL_DOCK, CommandCost::Failed(), FindJoiningStation(), GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), SpecializedStation< Station, false >::GetIfValid(), GetInclinedSlopeDirection(), GetTileSlope(), GetWaterClass(), OrthogonalTileArea::h, HasBit(), HasTileWaterGround(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_DIAGDIR, INVALID_TILE, InvalidateWindowData(), IsBridgeAbove(), IsTileFlat(), IsTileType(), SpecializedStation< Station, false >::IsValidID(), MakeDock(), MP_WATER, BaseStation::owner, Station::RecomputeIndustriesNear(), BaseStation::rect, return_cmd_error, ReverseDiagDir(), SetWindowWidgetDirty(), GameSettings::station, OrthogonalTileArea::tile, TileOffsByDiagDir(), ToTileIndexDiff(), UpdateStationAcceptance(), Station::UpdateVirtCoord(), OrthogonalTileArea::w, WATER_CLASS_CANAL, WC_SELECT_STATION, WC_STATION_LIST, WC_STATION_VIEW, and WID_SV_SHIPS.
CommandCost CmdBuildRailStation | ( | TileIndex | tile_org, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Build rail station.
tile_org | northern most position of station dragging/placement |
flags | operation to perform |
p1 | various bitstuffed elements
|
p2 | various bitstuffed elements
|
text | unused |
Definition at line 1162 of file station_cmd.cpp.
References _current_company, _settings_game, CommandCost::AddCost(), Station::AddFacility(), AddTrackToSignalBuffer(), AllocaM, AllocateSpecToStation(), SmallVector< T, S >::Append(), AXIS_X, AxisToDiagDir(), AxisToTrack(), BuildStationPart(), BaseStation::cached_anim_triggers, CALLBACK_FAILED, StationSpec::callback_mask, CanExpandRailStation(), CBID_STATION_AVAILABILITY, CBID_STATION_TILE_LAYOUT, CBM_STATION_AVAIL, CheckFlatLandRailStation(), CheckIfAuthorityAllowsNewStation(), CMD_ERROR, Convert8bitBooleanCallback(), DC_EXEC, DeallocateSpecFromStation(), DeleteAnimatedTile(), DirtyCompanyInfrastructureWindows(), StationSpec::disallowed_lengths, StationSpec::disallowed_platforms, StationSettings::distant_join_stations, ErrorUnknownCallbackResult(), FACIL_TRAIN, CommandCost::Failed(), FindJoiningStation(), FreeTrainTrackReservation(), GB(), NewGRFClass< Tspec, Tid, Tmax >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetCustomStationSpecIndex(), GetPlatformInfo(), GetRailStationAxis(), GetRailType(), NewGRFClass< Tspec, Tid, Tmax >::GetSpecCount(), GetStationGfx(), GetStationLayout(), GetTrainForReservation(), Train::GetVehicleTrackdir(), StationSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, HasBit(), HasStationReservation(), HasStationTileRail(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Company::infrastructure, INVALID_TILE, InvalidateWindowData(), IsCompatibleTrainStationTile(), IsRailStationTile(), IsStationTileBlocked(), SpecializedStation< Station, false >::IsValidID(), SmallVector< T, S >::Length(), MakeRailStation(), Station::MarkTilesDirty(), min(), SpecializedVehicle< T, Type >::Next(), BaseStation::owner, CompanyInfrastructure::rail, RailBuildCost(), Station::RecomputeIndustriesNear(), BaseStation::rect, return_cmd_error, ReverseTrackdir(), SAT_BUILT, SetAnimationFrame(), SetCustomStationSpecIndex(), SetRailStationPlatformReservation(), SetStationGfx(), SetStationTileRandomBits(), SetWindowWidgetDirty(), STAT_CLASS_WAYP, CompanyInfrastructure::station, GameSettings::station, StationSettings::station_spread, OrthogonalTileArea::tile, Vehicle::tile, TILE_AREA_LOOP, TileDiffXY(), TileOffsByDiagDir(), TrackdirToExitdir(), BaseStation::train_station, AnimationInfo::triggers, TryPathReserve(), UpdateStationAcceptance(), Station::UpdateVirtCoord(), ValParamRailtype(), WC_SELECT_STATION, WC_STATION_LIST, WC_STATION_VIEW, WID_SV_TRAINS, and YapfNotifyTrackLayoutChange().
CommandCost CmdBuildRoadStop | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Build a bus or truck stop.
tile | Northernmost tile of the stop. |
flags | Operation to perform. |
p1 | bit 0..7: Width of the road stop. bit 8..15: Length of the road stop. |
p2 | bit 0: 0 For bus stops, 1 for truck stops. bit 1: 0 For normal stops, 1 for drive-through. bit 2..3: The roadtypes. bit 5: Allow stations directly adjacent to other stations. bit 6..7: Entrance direction (DiagDirection) for normal stops. bit 6: Axis of the road for drive-through stops. bit 16..31: Station ID to join (NEW_STATION if build new one). |
text | Unused. |
Definition at line 1753 of file station_cmd.cpp.
References _current_company, _settings_game, OrthogonalTileArea::Add(), CommandCost::AddCost(), Station::AddFacility(), AxisToDiagDir(), BuildStationPart(), Station::bus_station, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_roadstop_pool >::CanAllocateItem(), CheckFlatLandRoadStop(), CheckIfAuthorityAllowsNewStation(), CMD_ERROR, CountBits(), DC_EXEC, DiagDirToAxis(), DirtyCompanyInfrastructureWindows(), StationSettings::distant_join_stations, EXPENSES_CONSTRUCTION, FACIL_BUS_STOP, FACIL_TRUCK_STOP, CommandCost::Failed(), FIND_FIRST_BIT, FindJoiningRoadStop(), FindRoadStopSpot(), FOR_EACH_SET_ROADTYPE, GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), GetRoadBits(), GetRoadOwner(), GetRoadTypes(), OrthogonalTileArea::h, HasBit(), HasExactlyOneBit(), HasRoadTypesAvail(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Company::infrastructure, INVALID_TILE, InvalidateWindowData(), IsNormalRoadTile(), IsRoadStop(), IsTileType(), SpecializedStation< Station, false >::IsValidID(), IsValidTile(), RoadStop::MakeDriveThrough(), MakeDriveThroughRoadStop(), MakeRoadStop(), MarkTileDirtyByTile(), MP_STATION, BaseStation::owner, Station::RecomputeIndustriesNear(), BaseStation::rect, RemoveRoadStop(), return_cmd_error, CompanyInfrastructure::road, ROADSTOP_BUS, ROADSTOP_TRUCK, ROADTYPE_ROAD, ROADTYPE_TRAM, SetWindowWidgetDirty(), GameSettings::station, StationSettings::station_spread, TILE_AREA_LOOP, TileAddWrap(), Station::truck_station, UpdateStationAcceptance(), Station::UpdateVirtCoord(), OrthogonalTileArea::w, WC_SELECT_STATION, WC_STATION_LIST, WC_STATION_VIEW, and WID_SV_ROADVEHS.
CommandCost CmdOpenCloseAirport | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Open/close an airport to incoming aircraft.
tile | Unused. |
flags | Operation to perform. |
p1 | Station ID of the airport. |
p2 | Unused. |
text | unused |
Definition at line 2407 of file station_cmd.cpp.
References Station::airport, AIRPORT_CLOSED_block, CheckOwnership(), CMD_ERROR, DC_EXEC, FACIL_AIRPORT, BaseStation::facilities, CommandCost::Failed(), Airport::flags, SpecializedStation< Station, false >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, SpecializedStation< Station, false >::IsValidID(), BaseStation::owner, OWNER_NONE, SetWindowWidgetDirty(), WC_STATION_VIEW, and WID_SV_CLOSE_AIRPORT.
CommandCost CmdRemoveFromRailStation | ( | TileIndex | start, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Remove a single tile from a rail station.
This allows for custom-built station with holes and weird layouts
start | tile of station piece to remove |
flags | operation to perform |
p1 | start_tile |
p2 | various bitstuffed elements
|
text | unused |
Definition at line 1579 of file station_cmd.cpp.
References SmallVector< T, S >::Begin(), CMD_ERROR, SmallVector< T, S >::End(), CommandCost::Failed(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, MapSize(), Station::MarkTilesDirty(), Station::RecomputeIndustriesNear(), RemoveFromRailBaseStation(), SetWindowWidgetDirty(), OrthogonalTileArea::tile, BaseStation::train_station, WC_STATION_VIEW, and WID_SV_TRAINS.
CommandCost CmdRemoveFromRailWaypoint | ( | TileIndex | start, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Remove a single tile from a waypoint.
This allows for custom-built waypoint with holes and weird layouts
start | tile of waypoint piece to remove |
flags | operation to perform |
p1 | start_tile |
p2 | various bitstuffed elements
|
text | unused |
Definition at line 1614 of file station_cmd.cpp.
References CMD_ERROR, HasBit(), MapSize(), and RemoveFromRailBaseStation().
CommandCost CmdRemoveRoadStop | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Remove bus or truck stops.
tile | Northernmost tile of the removal area. |
flags | Operation to perform. |
p1 | bit 0..7: Width of the removal area. bit 8..15: Height of the removal area. |
p2 | bit 0: 0 For bus stops, 1 for truck stops. |
p2 | bit 1: 0 to keep roads of all drive-through stops, 1 to remove them. |
text | Unused. |
Definition at line 2011 of file station_cmd.cpp.
References _current_company, CommandCost::AddCost(), AxisToRoadBits(), ClosestTownFromTile(), CMD_ERROR, CountBits(), DC_BANKRUPT, DC_EXEC, DiagDirToAxis(), DirtyCompanyInfrastructureWindows(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), FOR_EACH_SET_ROADTYPE, GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), GetRoadOwner(), GetRoadStopDir(), GetRoadStopType(), GetRoadTypes(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Company::infrastructure, INVALID_TILE, IsDriveThroughStopTile(), IsRoadStop(), IsTileType(), IsValidTile(), lengthof, MakeRoadNormal(), MP_STATION, OWNER_NONE, RemoveRoadStop(), CompanyInfrastructure::road, ROAD_NONE, ROADTYPE_END, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_NONE, SetBit(), TILE_AREA_LOOP, and TileAddWrap().
CommandCost CmdRenameStation | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Rename a station.
tile | unused |
flags | operation to perform |
p1 | station ID that is to be renamed |
p2 | unused |
text | the new name or an empty string when resetting to the default |
Definition at line 3723 of file station_cmd.cpp.
References CheckOwnership(), CMD_ERROR, DC_EXEC, CommandCost::Failed(), free(), SpecializedStation< Station, false >::GetIfValid(), InvalidateWindowData(), MAX_LENGTH_STATION_NAME_CHARS, BaseStation::name, BaseStation::owner, return_cmd_error, stredup(), StrEmpty(), Station::UpdateVirtCoord(), Utf8StringLength(), and WC_STATION_LIST.
|
static |
Check whether the tile is a mine.
tile | the tile to investigate. |
Definition at line 154 of file station_cmd.cpp.
References CC_LIQUID, CC_MAIL, CC_PASSENGERS, CargoSpec::classes, CT_INVALID, CargoSpec::Get(), Industry::GetByTile(), GetIndustrySpec(), INDUSTRYLIFE_EXTRACTIVE, IsTileType(), lengthof, IndustrySpec::life_type, MP_INDUSTRY, Industry::produced_cargo, and Industry::type.
|
static |
Check whether the tile is a tree.
tile | the tile to investigate. |
Definition at line 191 of file station_cmd.cpp.
References IsTileType(), and MP_TREES.
|
static |
Check whether the tile is water.
tile | the tile to investigate. |
Definition at line 181 of file station_cmd.cpp.
References IsTileType(), IsWater(), and MP_WATER.
|
static |
Counts the numbers of tiles matching a specific type in the area around.
tile | the center tile of the 'count area' |
cmp | the comparator/matcher ( |
Definition at line 135 of file station_cmd.cpp.
References INVALID_TILE, and TileAddWrap().
void DeleteStaleLinks | ( | Station * | from | ) |
Check all next hops of cargo packets in this station for existance of a a valid link they may use to travel on.
Reroute any cargo not having a valid link and remove timed out links found like this from the linkgraph. We're not all links here as that is expensive and useless. A link no one is using doesn't hurt either.
from | Station to check. |
Definition at line 3445 of file station_cmd.cpp.
References _date, LinkGraph::Node::Begin(), LinkGraph::COMPRESSION_INTERVAL, FlowStatMap::DeleteFlows(), DistanceManhattan(), LinkGraph::Node::End(), GoodsEntry::flows, SpecializedStation< Station, false >::Get(), OrderList::GetFirstOrder(), OrderList::GetFirstSharedVehicle(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::GetIfValid(), Station::goods, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_DATE, LinkGraph::LastCompression(), LinkGraph::EdgeWrapper< Tedge >::LastRestrictedUpdate(), LinkGraph::EdgeWrapper< Tedge >::LastUnrestrictedUpdate(), LinkGraph::EdgeWrapper< Tedge >::LastUpdate(), GoodsEntry::link_graph, LinkGraph::MIN_TIMEOUT_DISTANCE, Order::next, Vehicle::NextShared(), GoodsEntry::node, NUM_CARGO, LinkGraph::Node::RemoveEdge(), RerouteCargo(), FlowStatMap::RestrictFlows(), LinkRefresher::Run(), and BaseStation::xy.
|
static |
This is called right after a station was deleted.
It checks if the whole station is free of substations, and if so, the station will be deleted after a little while.
st | Station |
Definition at line 708 of file station_cmd.cpp.
References BaseStation::delete_ctr, InvalidateWindowData(), BaseStation::IsInUse(), BaseStation::owner, and WC_STATION_LIST.
Referenced by RemoveAirport(), RemoveDock(), RemoveFromRailBaseStation(), and RemoveRoadStop().
CommandCost FindJoiningBaseStation | ( | StationID | existing_station, |
StationID | station_to_join, | ||
bool | adjacent, | ||
TileArea | ta, | ||
T ** | st | ||
) |
Find a nearby station that joins this station.
T | the class to find a station for |
error_message | the error message when building a station on top of others |
existing_station | an existing station we build over |
station_to_join | the station to join to |
adjacent | whether adjacent stations are allowed |
ta | the area of the newly build station |
st | 'return' pointer for the found station |
Definition at line 1081 of file station_cmd.cpp.
References _settings_game, StationSettings::adjacent_stations, CommandCost::Failed(), GetStationAround(), return_cmd_error, and GameSettings::station.
|
static |
Find a nearby station that joins this road stop.
existing_stop | an existing road stop we build over |
station_to_join | the station to join to |
adjacent | whether adjacent stations are allowed |
ta | the area of the newly build station |
st | 'return' pointer for the found station |
Definition at line 1732 of file station_cmd.cpp.
Referenced by CmdBuildRoadStop().
|
static |
Find a nearby station that joins this station.
existing_station | an existing station we build over |
station_to_join | the station to join to |
adjacent | whether adjacent stations are allowed |
ta | the area of the newly build station |
st | 'return' pointer for the found station |
Definition at line 1126 of file station_cmd.cpp.
Referenced by CmdBuildAirport(), CmdBuildDock(), and CmdBuildRailStation().
CommandCost FindJoiningWaypoint | ( | StationID | existing_waypoint, |
StationID | waypoint_to_join, | ||
bool | adjacent, | ||
TileArea | ta, | ||
Waypoint ** | wp | ||
) |
Find a nearby waypoint that joins this waypoint.
existing_waypoint | an existing waypoint we build over |
waypoint_to_join | the waypoint to join to |
adjacent | whether adjacent waypoints are allowed |
ta | the area of the newly build waypoint |
wp | 'return' pointer for the found waypoint |
Definition at line 1140 of file station_cmd.cpp.
Referenced by CmdBuildRailWaypoint().
|
static |
Find a station action 0 property 24 station name, or reduce the free_names if needed.
tile | the tile to search |
user_data | the StationNameInformation to base the search on |
Definition at line 221 of file station_cmd.cpp.
References StationNameInformation::free_names, GetIndustrySpec(), GetIndustryType(), StationNameInformation::indtypes, IsTileType(), and MP_INDUSTRY.
truck_station | Determines whether a stop is ROADSTOP_BUS or ROADSTOP_TRUCK |
st | The Station to do the whole procedure for |
Definition at line 1706 of file station_cmd.cpp.
References Station::bus_stops, RoadStop::next, and Station::truck_stops.
Referenced by CmdBuildRoadStop().
void FindStationsAroundTiles | ( | const TileArea & | location, |
StationList * | stations | ||
) |
Find all stations around a rectangular producer (industry, house, headquarter, ...)
location | The location/area of the producer |
stations | The list to store the stations in |
Definition at line 3755 of file station_cmd.cpp.
References _settings_game, CA_UNMODIFIED, GameSettings::construction, ConstructionSettings::freeform_edges, SpecializedStation< Station, false >::GetByTile(), Station::GetCatchmentRadius(), OrthogonalTileArea::h, SmallVector< T, S >::Include(), IsTileType(), MapSizeX(), MapSizeY(), MAX_CATCHMENT, StationSettings::modified_catchment, MP_STATION, GameSettings::station, OrthogonalTileArea::tile, TileX(), TileXY(), TileY(), and OrthogonalTileArea::w.
Referenced by StationFinder::GetStations(), and WhoCanServiceIndustry().
CargoArray GetAcceptanceAroundTiles | ( | TileIndex | tile, |
int | w, | ||
int | h, | ||
int | rad, | ||
uint32 * | always_accepted | ||
) |
Get the acceptance of cargoes around the tile in 1/8.
tile | Center of the search area |
w | X extent of area |
h | Y extent of area |
rad | Search radius in addition to given area |
always_accepted | bitmask of cargo accepted by houses and headquarters; can be NULL |
Definition at line 527 of file station_cmd.cpp.
References MapSizeX(), MapSizeY(), max(), min(), TileX(), TileXY(), and TileY().
Referenced by DrawStationCoverageAreaText(), and UpdateStationAcceptance().
|
static |
Get a mask of the cargo types that the station accepts.
st | Station to query |
Definition at line 443 of file station_cmd.cpp.
References GoodsEntry::GES_ACCEPTANCE, Station::goods, HasBit(), NUM_CARGO, and GoodsEntry::status.
Referenced by UpdateStationAcceptance().
uint8 GetAirportNoiseLevelForTown | ( | const AirportSpec * | as, |
TileIterator & | it, | ||
TileIndex | town_tile | ||
) |
Get a possible noise reduction factor based on distance from town center.
The further you get, the less noise you generate. So all those folks at city council can now happily slee... work in their offices
as | airport information |
it | An iterator over all airport tiles. |
town_tile | TileIndex of town's center, the one who will receive the airport's candidature |
Definition at line 2103 of file station_cmd.cpp.
References _settings_game, GameSettings::difficulty, GetMinimalAirportDistanceToTile(), AirportSpec::noise_level, and DifficultySettings::town_council_tolerance.
Referenced by CmdBuildAirport(), RemoveAirport(), and UpdateAirportsNoise().
Find the closest deleted station of the current company.
tile | the tile to search from. |
Definition at line 359 of file station_cmd.cpp.
References _current_company, DistanceManhattan(), BaseStation::IsInUse(), BaseStation::owner, and BaseStation::xy.
Referenced by BuildStationPart().
|
static |
Computes the minimal distance from town's xy to any airport's tile.
it | An iterator over all airport tiles. |
town_tile | town's tile (t->xy) |
Definition at line 2083 of file station_cmd.cpp.
References DistanceManhattan(), INVALID_TILE, and min().
Referenced by AirportGetNearestTown(), and GetAirportNoiseLevelForTown().
CargoArray GetProductionAroundTiles | ( | TileIndex | tile, |
int | w, | ||
int | h, | ||
int | rad | ||
) |
Get the cargo types being produced around the tile (in a rectangle).
tile | Northtile of area |
w | X extent of the area |
h | Y extent of the area |
rad | Search radius in addition to the given area |
Definition at line 474 of file station_cmd.cpp.
References CT_INVALID, OrthogonalTileArea::Intersects(), lengthof, Industry::location, MapSizeX(), MapSizeY(), max(), min(), Industry::produced_cargo, TILE_AREA_LOOP, TileX(), TileXY(), and TileY().
Referenced by DrawStationCoverageAreaText().
CommandCost GetStationAround | ( | TileArea | ta, |
StationID | closest_station, | ||
T ** | st | ||
) |
Look for a station around the given tile area.
ta | the area to search over |
closest_station | the closest station found so far |
st | to 'return' the found station |
Definition at line 99 of file station_cmd.cpp.
References GetStationIndex(), OrthogonalTileArea::h, IsTileType(), MP_STATION, return_cmd_error, OrthogonalTileArea::tile, TILE_AREA_LOOP, TileDiffXY(), and OrthogonalTileArea::w.
Referenced by FindJoiningBaseStation().
void GetStationLayout | ( | byte * | layout, |
int | numtracks, | ||
int | plat_len, | ||
const StationSpec * | statspec | ||
) |
Create the station layout for the given number of tracks and platform length.
layout | The layout to write to. |
numtracks | The number of tracks to write. |
plat_len | The length of the platforms. |
statspec | The specification of the station to (possibly) get the layout from. |
Definition at line 1045 of file station_cmd.cpp.
Referenced by CmdBuildRailStation(), and CmdBuildRailWaypoint().
bool HasStationInUse | ( | StationID | station, |
bool | include_company, | ||
CompanyID | company | ||
) |
Tests whether the company's vehicles have this station in orders.
station | station ID |
include_company | If true only check vehicles of company, if false only check vehicles of other companies |
company | company ID |
Definition at line 2430 of file station_cmd.cpp.
References FOR_ALL_VEHICLES, Order::GetDestination(), Order::IsType(), and Vehicle::owner.
Referenced by CompanyStationsWindow::BuildStationsList(), and RemoveBuoy().
void IncreaseStats | ( | Station * | st, |
CargoID | cargo, | ||
StationID | next_station_id, | ||
uint | capacity, | ||
uint | usage, | ||
EdgeUpdateMode | mode | ||
) |
Increase capacity for a link stat given by station cargo and next hop.
st | Station to get the link stats from. |
cargo | Cargo to increase stat for. |
next_station_id | Station the consist will be travelling to next. |
capacity | Capacity to add to link stat. |
usage | Usage to add to link stat. |
mode | Update mode to be applied. |
Definition at line 3520 of file station_cmd.cpp.
References LinkGraph::AddNode(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::CanAllocateItem(), DEBUG, SpecializedStation< Station, false >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::Get(), Station::goods, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, LinkGraphSchedule::instance, GoodsEntry::link_graph, LinkGraph::Merge(), GoodsEntry::node, LinkGraphSchedule::Queue(), LinkGraph::Size(), and LinkGraphSchedule::Unqueue().
Referenced by Vehicle::BeginLoading(), IncreaseStats(), and LinkRefresher::RefreshStats().
Increase capacity for all link stats associated with vehicles in the given consist.
st | Station to get the link stats from. |
front | First vehicle in the consist. |
next_station_id | Station the consist will be travelling to next. |
Definition at line 3572 of file station_cmd.cpp.
References Vehicle::cargo, Vehicle::cargo_type, EUM_INCREASE, IncreaseStats(), min(), Vehicle::Next(), Vehicle::refit_cap, and VehicleCargoList::StoredCount().
bool IsHangar | ( | TileIndex | t | ) |
Check whether the given tile is a hangar.
t | the tile to of whether it is a hangar. |
Definition at line 74 of file station_cmd.cpp.
References Station::airport, SpecializedStation< Station, false >::GetByTile(), Airport::GetHangarTile(), Airport::GetSpec(), IsAirport(), IsTileType(), MP_STATION, and AirportSpec::nof_depots.
Referenced by IsHangarTile().
|
static |
Remove an airport.
tile | TileIndex been queried |
flags | operation to perform |
Definition at line 2320 of file station_cmd.cpp.
References _current_company, _settings_game, CommandCost::AddCost(), Station::airport, AirportGetNearestTown(), CheckOwnership(), OrthogonalTileArea::Clear(), CMD_ERROR, DC_EXEC, DeleteAnimatedTile(), DeleteNewGRFInspectWindow(), DeleteStationIfEmpty(), DeleteWindowById(), DirtyCompanyInfrastructureWindows(), GameSettings::economy, EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, FACIL_AIRPORT, BaseStation::facilities, CommandCost::Failed(), FLYING, FOR_ALL_AIRCRAFT, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetAirportNoiseLevelForTown(), SpecializedStation< Station, false >::GetByTile(), Airport::GetHangarTile(), Airport::GetNumHangars(), Airport::GetSpec(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWindowData(), IsHangarTile(), Aircraft::IsNormalAircraft(), Town::noise_reached, BaseStation::owner, OWNER_WATER, Airport::psa, Station::RecomputeIndustriesNear(), BaseStation::rect, OrderBackup::Reset(), SetWindowDirty(), Aircraft::state, EconomySettings::station_noise_level, Aircraft::targetairport, OrthogonalTileArea::tile, TILE_AREA_LOOP, BaseStation::town, Station::UpdateVirtCoord(), WC_STATION_VIEW, WC_TOWN_VIEW, WC_VEHICLE_DEPOT, and Town::xy.
Referenced by ClearTile_Station().
|
static |
Remove a dock.
tile | TileIndex been queried |
flags | operation to perform |
Definition at line 2556 of file station_cmd.cpp.
References CheckOwnership(), Vehicle::current_order, DC_EXEC, DeleteStationIfEmpty(), Vehicle::dest_tile, DirtyCompanyInfrastructureWindows(), Station::dock_tile, EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, FACIL_DOCK, BaseStation::facilities, CommandCost::Failed(), FOR_ALL_SHIPS, Order::Free(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), SpecializedStation< Station, false >::GetByTile(), GetDockDirection(), GetDockOffset(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, Order::IsType(), Vehicle::LeaveStation(), MarkTileDirtyByTile(), BaseStation::owner, Station::RecomputeIndustriesNear(), BaseStation::rect, SetWindowWidgetDirty(), CommandCost::Succeeded(), Vehicle::tile, TILE_ADD, TileOffsByDiagDir(), ToTileIndexDiff(), Station::UpdateVirtCoord(), WC_STATION_VIEW, and WID_SV_SHIPS.
Referenced by ClearTile_Station().
CommandCost RemoveFromRailBaseStation | ( | TileArea | ta, |
SmallVector< T *, 4 > & | affected_stations, | ||
DoCommandFlag | flags, | ||
Money | removal_cost, | ||
bool | keep_rail | ||
) |
Remove a number of tiles from any rail station within the area.
ta | the area to clear station tile from. |
affected_stations | the stations affected. |
flags | the command flags. |
removal_cost | the cost for removing the tile, including the rail. |
keep_rail | whether to keep the rail of the station. |
T | the type of station to remove. |
Definition at line 1458 of file station_cmd.cpp.
References _current_company, CommandCost::AddCost(), AddTrackToSignalBuffer(), SmallVector< T, S >::Begin(), CheckOwnership(), DC_EXEC, DeallocateSpecFromStation(), DeleteNewGRFInspectWindow(), DeleteStationIfEmpty(), DirtyCompanyInfrastructureWindows(), SmallVector< T, S >::End(), EnsureNoVehicleOnGround(), error(), EXPENSES_CONSTRUCTION, FACIL_TRAIN, CommandCost::Failed(), FreeTrainTrackReservation(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetCustomStationSpecIndex(), GetRailStationTrack(), GetRailType(), GetTileOwner(), GetTrainForReservation(), Train::GetVehicleTrackdir(), Vehicle::GetVehicleTrackdir(), HasStationReservation(), HasStationTileRail(), SmallVector< T, S >::Include(), INVALID_TILE, IsRailStationTile(), IsStationTileBlocked(), Vehicle::Next(), SpecializedVehicle< T, Type >::Next(), OWNER_WATER, ReverseTrackdir(), SetRailStationPlatformReservation(), SetWindowWidgetDirty(), Vehicle::tile, TILE_AREA_LOOP, TrackdirToExitdir(), TrackToTrackBits(), TryPathReserve(), WC_STATION_VIEW, WID_SV_TRAINS, and YapfNotifyTrackLayoutChange().
Referenced by CmdRemoveFromRailStation(), CmdRemoveFromRailWaypoint(), and RemoveRailStation().
CommandCost RemoveRailStation | ( | T * | st, |
DoCommandFlag | flags, | ||
Money | removal_cost | ||
) |
Remove a rail station/waypoint.
st | The station/waypoint to remove the rail part from |
flags | operation to perform |
removal_cost | the cost for removing a tile |
T | the type of station to remove |
Definition at line 1635 of file station_cmd.cpp.
References _current_company, CommandCost::AddCost(), CheckOwnership(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), OrthogonalTileArea::h, OWNER_WATER, RemoveFromRailBaseStation(), TILE_AREA_LOOP, and OrthogonalTileArea::w.
Referenced by ClearTile_Station(), RemoveRailStation(), and RemoveRailWaypoint().
|
static |
Remove a rail station.
tile | Tile of the station. |
flags | operation to perform |
Definition at line 1669 of file station_cmd.cpp.
References _current_company, CMD_REMOVE_FROM_RAIL_STATION, DC_EXEC, DoCommand(), SpecializedStation< Station, false >::GetByTile(), OWNER_WATER, Station::RecomputeIndustriesNear(), and RemoveRailStation().
|
static |
Remove a rail waypoint.
tile | Tile of the waypoint. |
flags | operation to perform |
Definition at line 1690 of file station_cmd.cpp.
References _current_company, CMD_REMOVE_FROM_RAIL_WAYPOINT, DC_EXEC, DoCommand(), SpecializedStation< Waypoint, true >::GetByTile(), OWNER_WATER, and RemoveRailStation().
Referenced by ClearTile_Station().
|
static |
Remove a bus station/truck stop.
tile | TileIndex been queried |
flags | operation to perform |
Definition at line 1903 of file station_cmd.cpp.
References _current_company, OrthogonalTileArea::Add(), Station::bus_station, Station::bus_stops, CheckOwnership(), OrthogonalTileArea::Clear(), RoadStop::ClearDriveThrough(), Vehicle::current_order, DC_BANKRUPT, DC_EXEC, DeleteStationIfEmpty(), Vehicle::dest_tile, DirtyCompanyInfrastructureWindows(), EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, FACIL_BUS_STOP, FACIL_TRUCK_STOP, BaseStation::facilities, CommandCost::Failed(), FindVehicleOnPos(), SpecializedVehicle< T, Type >::First(), FOR_EACH_SET_ROADTYPE, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), RoadStop::GetByTile(), SpecializedStation< Station, false >::GetByTile(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), RoadVehicle::GetOrderStationLocation(), GetRoadOwner(), GetRoadTypes(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Company::infrastructure, IsDriveThroughStopTile(), IsTruckStop(), Order::IsType(), RoadStop::next, BaseStation::owner, OWNER_WATER, Station::RecomputeIndustriesNear(), BaseStation::rect, CompanyInfrastructure::road, ROADSTOP_BUS, ROADSTOP_TRUCK, SetWindowWidgetDirty(), Station::truck_station, Station::truck_stops, Station::UpdateVirtCoord(), WC_STATION_VIEW, and WID_SV_ROADVEHS.
Referenced by ClearTile_Station(), CmdBuildRoadStop(), and CmdRemoveRoadStop().
Reroute cargo of type c at station st or in any vehicles unloading there.
Make sure the cargo's new next hop is neither "avoid" nor "avoid2".
st | Station to be rerouted at. |
c | Type of cargo. |
avoid | Original next hop of cargo, avoid this. |
avoid2 | Another station to be avoided when rerouting. |
Definition at line 3421 of file station_cmd.cpp.
References Vehicle::cargo, GoodsEntry::cargo, Vehicle::cargo_type, Station::goods, Vehicle::Next(), VehicleCargoList::Reroute(), and StationCargoList::Reroute().
Referenced by DeleteStaleLinks(), LinkGraphJob::~LinkGraphJob(), and Station::~Station().
|
static |
Items contains the two cargo names that are to be accepted or rejected.
msg is the string id of the message to display.
Definition at line 457 of file station_cmd.cpp.
References AddNewsItem(), CargoSpec::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, NF_INCOLOUR, NF_SMALL, NR_STATION, NT_ACCEPTANCE, and SetDParam().
Referenced by UpdateStationAcceptance().
bool SplitGroundSpriteForOverlay | ( | const TileInfo * | ti, |
SpriteID * | ground, | ||
RailTrackOffset * | overlay_offset | ||
) |
Check whether a sprite is a track sprite, which can be replaced by a non-track ground sprite and a rail overlay.
If the ground sprite is suitable, ground is replaced with the new non-track ground sprite, and overlay_offset is set to the overlay to draw.
ti | Positional info for the tile to decide snowyness etc. May be NULL. | |
[in,out] | ground | Groundsprite to draw. |
[out] | overlay_offset | Overlay to draw. |
Definition at line 2626 of file station_cmd.cpp.
References _settings_game, GameSettings::game_creation, GetSnowLine(), GetTropicZone(), GameCreationSettings::landscape, RTO_X, RTO_Y, TileInfo::tile, TILE_HEIGHT, TROPICZONE_DESERT, and TileInfo::z.
Referenced by DrawStationTile().
|
static |
This function is called for each station once every 250 ticks.
Not all stations will get the tick at the same time.
st | the station receiving the tick. |
Definition at line 3207 of file station_cmd.cpp.
References ClrBit(), BaseStation::delete_ctr, FACIL_WAYPOINT, BaseStation::facilities, SpecializedStation< Station, false >::From(), GoodsEntry::GES_ACCEPTED_BIGTICK, SpecializedStation< Station, false >::IsExpected(), BaseStation::IsInUse(), NUM_CARGO, TriggerWatchedCargoCallbacks(), and UpdateStationAcceptance().
void StationMonthlyLoop | ( | ) |
Monthly loop for stations.
Definition at line 3626 of file station_cmd.cpp.
References ClrBit(), GB(), GoodsEntry::GES_CURRENT_MONTH, GoodsEntry::GES_LAST_MONTH, Station::goods, NUM_CARGO, SB(), and GoodsEntry::status.
Referenced by OnNewMonth().
void TriggerWatchedCargoCallbacks | ( | Station * | st | ) |
Run the watched cargo callback for all houses in the catchment area.
st | Station. |
Definition at line 3180 of file station_cmd.cpp.
References GoodsEntry::GES_ACCEPTED_BIGTICK, Station::GetCatchmentRect(), Station::goods, HasBit(), IsTileType(), MP_HOUSE, NUM_CARGO, SetBit(), GoodsEntry::status, TILE_AREA_LOOP, TileXY(), and WatchedCargoCallback().
Referenced by StationHandleBigTick().
|
static |
Truncate the cargo by a specific amount.
cs | The type of cargo to perform the truncation for. |
ge | The goods entry, of the station, to truncate. |
amount | The amount to truncate the cargo by. |
Definition at line 3240 of file station_cmd.cpp.
References GoodsEntry::cargo, SpecializedStation< Station, false >::GetIfValid(), Station::goods, CargoSpec::Index(), max(), GoodsEntry::max_waiting_cargo, and StationCargoList::Truncate().
void UpdateAllStationVirtCoords | ( | ) |
Update the virtual coords needed to draw the station sign for all stations.
Definition at line 429 of file station_cmd.cpp.
References BaseStation::UpdateVirtCoord().
Referenced by CmdRenameTown(), and UpdateAllVirtCoords().
void UpdateStationAcceptance | ( | Station * | st, |
bool | show_msg | ||
) |
Update the acceptance for a station.
st | Station to update |
show_msg | controls whether to display a message that acceptance was changed. |
Definition at line 562 of file station_cmd.cpp.
References _local_company, Station::always_accepted, CC_PASSENGERS, CT_INVALID, FACIL_BUS_STOP, FACIL_TRUCK_STOP, BaseStation::facilities, GoodsEntry::GES_ACCEPTANCE, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::Get(), GetAcceptanceAroundTiles(), GetAcceptanceMask(), Station::GetCatchmentRadius(), Station::goods, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsCargoInClass(), BaseStation::IsInUse(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::IsValidID(), lengthof, GoodsEntry::link_graph, GoodsEntry::node, NUM_CARGO, BaseStation::owner, BaseStation::rect, SB(), SetWindowWidgetDirty(), ShowRejectOrAcceptNews(), GoodsEntry::status, TileXY(), WC_STATION_VIEW, and WID_SV_ACCEPT_RATING_LIST.
Referenced by AfterLoadGame(), CmdBuildAirport(), CmdBuildDock(), CmdBuildRailStation(), CmdBuildRoadStop(), and StationHandleBigTick().
|
static |
Definition at line 2446 of file station_cmd.cpp.
const TileTypeProcs _tile_type_station_procs |