OpenTTD Source  20240917-master-g9ab0a47812
station_func.h File Reference
#include "sprite.h"
#include "rail_type.h"
#include "road_type.h"
#include "vehicle_type.h"
#include "economy_func.h"
#include "rail.h"
#include "road.h"
#include "linkgraph/linkgraph_type.h"
#include "industry_type.h"

Go to the source code of this file.

Functions

void ModifyStationRatingAround (TileIndex tile, Owner owner, int amount, uint radius)
 
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.
 
void ClearAllStationCachedNames ()
 
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, CargoTypes *always_accepted=nullptr)
 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...
 
CargoTypes GetAcceptanceMask (const Station *st)
 Get a mask of the cargo types that the station accepts. More...
 
CargoTypes GetEmptyMask (const Station *st)
 Get a mask of the cargo types that are empty at the station. More...
 
void SetRailStationTileFlags (TileIndex tile, const StationSpec *statspec)
 Set rail station tile flags for the given tile. More...
 
const DrawTileSpritesGetStationTileLayout (StationType st, uint8_t gfx)
 Get station tile layout for a station type and its station gfx. More...
 
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)
 
void UpdateStationDockingTiles (Station *st)
 
void RemoveDockingTile (TileIndex t)
 
void ClearDockingTilesCheckingNeighbours (TileIndex tile)
 Clear docking tile status from tiles around a removed dock, if the tile has no neighbours which would keep it as a docking tile. 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, uint32_t time)
 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, uint32_t time, 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...
 
Money StationMaintenanceCost (uint32_t 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 716 of file station.cpp.

References FACIL_AIRPORT, BaseStation::facilities, SpecializedStation< Station, false >::Iterate(), and BaseStation::owner.

◆ ClearDockingTilesCheckingNeighbours()

void ClearDockingTilesCheckingNeighbours ( TileIndex  tile)

Clear docking tile status from tiles around a removed dock, if the tile has no neighbours which would keep it as a docking tile.

Parameters
tileEx-dock tile to check.

Definition at line 2909 of file station_cmd.cpp.

References DIAGDIR_BEGIN, DIAGDIR_END, IsValidTile(), and TileOffsByDiagDir().

◆ GetAcceptanceAroundTiles()

CargoArray GetAcceptanceAroundTiles ( TileIndex  center_tile,
int  w,
int  h,
int  rad,
CargoTypes *  always_accepted 
)

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

Parameters
center_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 nullptr
indIndustry associated with neutral station (e.g. oil rig) or nullptr

Definition at line 585 of file station_cmd.cpp.

References _settings_game, OrthogonalTileArea::Expand(), Industry::GetByTile(), IsTileType(), MP_INDUSTRY, StationSettings::serve_neutral_industries, and GameSettings::station.

◆ GetAcceptanceMask()

CargoTypes GetAcceptanceMask ( const Station st)

Get a mask of the cargo types that the station accepts.

Parameters
stStation to query
Returns
the expected mask

Definition at line 501 of file station_cmd.cpp.

References GoodsEntry::GES_ACCEPTANCE, Station::goods, HasBit(), and SetBit().

Referenced by StationViewWindow::DrawAcceptedCargo(), and UpdateStationAcceptance().

◆ GetEmptyMask()

CargoTypes GetEmptyMask ( const Station st)

Get a mask of the cargo types that are empty at the station.

Parameters
stStation to query
Returns
the empty mask

Definition at line 516 of file station_cmd.cpp.

References Station::goods, and SetBit().

Referenced by TriggerRoadStopRandomisation().

◆ GetProductionAroundTiles()

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

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

Parameters
north_tileNorthern most tile of area
wX extent of the area
hY extent of the area
radSearch radius in addition to the given area

Definition at line 547 of file station_cmd.cpp.

References OrthogonalTileArea::Expand(), GetIndustryIndex(), IsTileType(), and MP_INDUSTRY.

◆ GetStationTileLayout()

const DrawTileSprites* GetStationTileLayout ( StationType  st,
uint8_t  gfx 
)

Get station tile layout for a station type and its station gfx.

Parameters
stStation type to draw.
gfxStationGfx of tile to draw.
Returns
Tile layout to draw.

Definition at line 3025 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 2769 of file station_cmd.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_orderlist_pool >::Iterate(), Order::next, and Vehicle::owner.

Referenced by CompanyStationsWindow::BuildStationsList(), and RemoveBuoy().

◆ IncreaseStats() [1/2]

void IncreaseStats ( Station st,
CargoID  cargo,
StationID  next_station_id,
uint  capacity,
uint  usage,
uint32_t  time,
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 4131 of file station_cmd.cpp.

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

Referenced by IncreaseStats().

◆ IncreaseStats() [2/2]

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

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 4183 of file station_cmd.cpp.

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

◆ 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 4013 of file station_cmd.cpp.

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

◆ SetRailStationTileFlags()

void SetRailStationTileFlags ( TileIndex  tile,
const StationSpec statspec 
)

Set rail station tile flags for the given tile.

Parameters
tileTile to set flags on.
statspecStatspec of the tile.

Definition at line 1326 of file station_cmd.cpp.

References StationSpec::Blocked, GetStationGfx(), GetStationTileFlags(), StationSpec::NoWires, StationSpec::Pylons, SetStationTileBlocked(), SetStationTileHavePylons(), and SetStationTileHaveWires().

◆ ShowStationViewWindow()

void ShowStationViewWindow ( StationID  station)

Opens StationViewWindow for given station.

Parameters
stationstation which window should be opened

Definition at line 2178 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 nullptr.
[in,out]groundGroundsprite to draw.
[out]overlay_offsetOverlay to draw.
Returns
true if overlay can be drawn.

Definition at line 3041 of file station_cmd.cpp.

◆ StationMaintenanceCost()

Money StationMaintenanceCost ( uint32_t  num)
inline

Calculates the maintenance cost of a number of station tiles.

Parameters
numNumber of station tiles.
Returns
Total cost.

Definition at line 60 of file station_func.h.

◆ UpdateStationAcceptance()