OpenTTD
Functions
station_func.h File Reference

Functions related to stations. More...

#include "sprite.h"
#include "rail_type.h"
#include "road_type.h"
#include "vehicle_type.h"
#include "economy_func.h"
#include "rail.h"
#include "linkgraph/linkgraph_type.h"

Go to the source code of this file.

Functions

void ModifyStationRatingAround (TileIndex tile, Owner owner, int amount, uint radius)
 
void FindStationsAroundTiles (const TileArea &location, StationList *stations)
 Find all stations around a rectangular producer (industry, house, headquarter, ...) More...
 
void ShowStationViewWindow (StationID station)
 Opens StationViewWindow for given station. More...
 
void UpdateAllStationVirtCoords ()
 Update the virtual coords needed to draw the station sign for all stations. More...
 
CargoArray GetProductionAroundTiles (TileIndex tile, int w, int h, int rad)
 Get the cargo types being produced around the tile (in a rectangle). More...
 
CargoArray GetAcceptanceAroundTiles (TileIndex tile, int w, int h, int rad, uint32 *always_accepted=NULL)
 Get the acceptance of cargoes around the tile in 1/8. More...
 
void UpdateStationAcceptance (Station *st, bool show_msg)
 Update the acceptance for a station. More...
 
const DrawTileSpritesGetStationTileLayout (StationType st, byte gfx)
 
void StationPickerDrawSprite (int x, int y, StationType st, RailType railtype, RoadType roadtype, int image)
 
bool HasStationInUse (StationID station, bool include_company, CompanyID company)
 Tests whether the company's vehicles have this station in orders. More...
 
void DeleteOilRig (TileIndex t)
 
bool IsStationTileBlocked (TileIndex tile)
 Check whether a rail station tile is NOT traversable. More...
 
bool CanStationTileHavePylons (TileIndex tile)
 Check if a rail station tile shall have pylons when electrified. More...
 
bool CanStationTileHaveWires (TileIndex tile)
 Check if a rail station tile shall have wires when electrified. More...
 
void UpdateAirportsNoise ()
 Recalculate the noise generated by the airports of each town.
 
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. More...
 
void IncreaseStats (Station *st, const Vehicle *v, StationID next_station_id)
 Increase capacity for all link stats associated with vehicles in the given consist. More...
 
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. More...
 
void RerouteCargo (Station *st, CargoID c, StationID avoid, StationID avoid2)
 Reroute cargo of type c at station st or in any vehicles unloading there. More...
 
static Money StationMaintenanceCost (uint32 num)
 Calculates the maintenance cost of a number of station tiles. More...
 
Money AirportMaintenanceCost (Owner owner)
 Calculates the maintenance cost of all airports of a company. More...
 

Detailed Description

Functions related to stations.

Definition in file station_func.h.

Function Documentation

◆ AirportMaintenanceCost()

Money AirportMaintenanceCost ( Owner  owner)

Calculates the maintenance cost of all airports of a company.

Parameters
ownerCompany.
Returns
Total cost.

Definition at line 558 of file station.cpp.

Referenced by CompanyInfrastructureWindow::GetTotalMaintenanceCost().

◆ CanStationTileHavePylons()

bool CanStationTileHavePylons ( TileIndex  tile)

Check if a rail station tile shall have pylons when electrified.

Parameters
tileTile to test.
Returns
Tile shall have pylons.
Note
This could be cached (during build) in the map array to save on all the dereferencing.

Definition at line 864 of file newgrf_station.cpp.

◆ CanStationTileHaveWires()

bool CanStationTileHaveWires ( TileIndex  tile)

Check if a rail station tile shall have wires when electrified.

Parameters
tileTile to test.
Returns
Tile shall have wires.
Note
This could be cached (during build) in the map array to save on all the dereferencing.

Definition at line 878 of file newgrf_station.cpp.

Referenced by MaskWireBits().

◆ FindStationsAroundTiles()

void FindStationsAroundTiles ( const TileArea location,
StationList stations 
)

Find all stations around a rectangular producer (industry, house, headquarter, ...)

Parameters
locationThe location/area of the producer
stationsThe list to store the stations in

Definition at line 3778 of file station_cmd.cpp.

References _settings_game, CA_UNMODIFIED, MAX_CATCHMENT, StationSettings::modified_catchment, and GameSettings::station.

Referenced by StationFinder::GetStations(), and WhoCanServiceIndustry().

◆ GetAcceptanceAroundTiles()

CargoArray GetAcceptanceAroundTiles ( TileIndex  tile,
int  w,
int  h,
int  rad,
uint32 *  always_accepted 
)

Get the acceptance of cargoes around the tile in 1/8.

Parameters
tileCenter of the search area
wX extent of area
hY extent of area
radSearch radius in addition to given area
always_acceptedbitmask of cargo accepted by houses and headquarters; can be NULL

Definition at line 527 of file station_cmd.cpp.

Referenced by UpdateStationAcceptance().

◆ GetProductionAroundTiles()

CargoArray GetProductionAroundTiles ( TileIndex  tile,
int  w,
int  h,
int  rad 
)

Get the cargo types being produced around the tile (in a rectangle).

Parameters
tileNorthtile of area
wX extent of the area
hY extent of the area
radSearch radius in addition to the given area

Definition at line 474 of file station_cmd.cpp.

◆ HasStationInUse()

bool HasStationInUse ( StationID  station,
bool  include_company,
CompanyID  company 
)

Tests whether the company's vehicles have this station in orders.

Parameters
stationstation ID
include_companyIf true only check vehicles of company, if false only check vehicles of other companies
companycompany ID

Definition at line 2434 of file station_cmd.cpp.

References FOR_ALL_VEHICLES, and Vehicle::owner.

Referenced by RemoveBuoy().

◆ IncreaseStats() [1/2]

void IncreaseStats ( Station st,
const Vehicle front,
StationID  next_station_id 
)

Increase capacity for all link stats associated with vehicles in the given consist.

Parameters
stStation to get the link stats from.
frontFirst vehicle in the consist.
next_station_idStation the consist will be travelling to next.

Definition at line 3595 of file station_cmd.cpp.

References Vehicle::cargo, Vehicle::cargo_type, EUM_INCREASE, IncreaseStats(), min(), Vehicle::Next(), Vehicle::refit_cap, and VehicleCargoList::StoredCount().

◆ IncreaseStats() [2/2]

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.

Parameters
stStation to get the link stats from.
cargoCargo to increase stat for.
next_station_idStation the consist will be travelling to next.
capacityCapacity to add to link stat.
usageUsage to add to link stat.
modeUpdate mode to be applied.

Definition at line 3543 of file station_cmd.cpp.

References SpecializedStation< Station, false >::Get(), Station::goods, and GoodsEntry::link_graph.

Referenced by IncreaseStats().

◆ IsStationTileBlocked()

bool IsStationTileBlocked ( TileIndex  tile)

Check whether a rail station tile is NOT traversable.

Parameters
tileTile to test.
Returns
Station tile is blocked.
Note
This could be cached (during build) in the map array to save on all the dereferencing.

Definition at line 851 of file newgrf_station.cpp.

Referenced by CmdConvertRail().

◆ RerouteCargo()

void RerouteCargo ( Station st,
CargoID  c,
StationID  avoid,
StationID  avoid2 
)

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".

Parameters
stStation to be rerouted at.
cType of cargo.
avoidOriginal next hop of cargo, avoid this.
avoid2Another station to be avoided when rerouting.

Definition at line 3427 of file station_cmd.cpp.

References GoodsEntry::cargo, Vehicle::cargo, Vehicle::cargo_type, Station::goods, Vehicle::Next(), VehicleCargoList::Reroute(), and StationCargoList::Reroute().

◆ ShowStationViewWindow()

void ShowStationViewWindow ( StationID  station)

Opens StationViewWindow for given station.

Parameters
stationstation which window should be opened

Definition at line 2110 of file station_gui.cpp.

◆ SplitGroundSpriteForOverlay()

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.

Parameters
tiPositional info for the tile to decide snowyness etc. May be NULL.
[in,out]groundGroundsprite to draw.
[out]overlay_offsetOverlay to draw.
Returns
true if overlay can be drawn.

Definition at line 2630 of file station_cmd.cpp.

◆ StationMaintenanceCost()

static Money StationMaintenanceCost ( uint32  num)
inlinestatic

Calculates the maintenance cost of a number of station tiles.

Parameters
numNumber of station tiles.
Returns
Total cost.

Definition at line 61 of file station_func.h.

Referenced by CompanyInfrastructureWindow::GetTotalMaintenanceCost().

◆ UpdateAllStationVirtCoords()

void UpdateAllStationVirtCoords ( )

Update the virtual coords needed to draw the station sign for all stations.

Definition at line 429 of file station_cmd.cpp.

Referenced by CmdRenameTown(), and UpdateAllVirtCoords().

◆ UpdateStationAcceptance()

void UpdateStationAcceptance ( Station st,
bool  show_msg 
)