Functions

station_func.h File Reference

Functions related to stations. More...

#include "station_type.h"
#include "sprite.h"
#include "rail_type.h"
#include "road_type.h"
#include "cargo_type.h"
#include "company_type.h"
#include "vehicle_type.h"
#include "economy_func.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, ...).
void ShowStationViewWindow (StationID station)
 Opens StationViewWindow for given station.
void UpdateAllStationVirtCoords ()
 Update the virtual coords needed to draw the station sign for all stations.
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=NULL)
 Get the acceptance of cargos around the tile in 1/8.
void UpdateStationAcceptance (Station *st, bool show_msg)
 Update the acceptance for a station.
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.
void DeleteOilRig (TileIndex t)
bool IsStationTileBlocked (TileIndex tile)
 Check whether a rail station tile is NOT traversable.
bool IsStationTileElectrifiable (TileIndex tile)
 Check if a rail station tile can be electrified.
void UpdateAirportsNoise ()
 Recalculate the noise generated by the airports of each town.
void DecreaseFrozen (Station *st, const Vehicle *v, StationID next_station_id)
 Decrease the frozen values of all link stats associated with vehicles in the given consist (ie the consist is leaving the station).
void RecalcFrozen (Station *st)
 Recalculate all frozen values for all link stats of a station.
void RecalcFrozenIfLoading (const Vehicle *v)
 Recalculate the frozen value of the station the given vehicle is loading at if the vehicle is loading.
void IncreaseStats (Station *st, const Vehicle *v, StationID next_station_id, bool freeze)
 Either freeze or increase capacity for all link stats associated with vehicles in the given consist.
void DeleteStaleFlows (StationID at, CargoID c_id, StationID to)
 Delete all flows at a station for specific cargo and destination.
static Money StationMaintenanceCost (uint32 num)
 Calculates the maintenance cost of a number of station tiles.
Money AirportMaintenanceCost (Owner owner)
 Calculates the maintenance cost of all airports of a company.

Detailed Description

Functions related to stations.

Definition in file station_func.h.


Function Documentation

Money AirportMaintenanceCost ( Owner  owner  ) 
void DecreaseFrozen ( Station st,
const Vehicle front,
StationID  next_station_id 
)

Decrease the frozen values of all link stats associated with vehicles in the given consist (ie the consist is leaving the station).

Parameters:
st Station to decrease the frozen values on.
front First vehicle in the consist.
next_station_id Station the vehicle is leaving for.

Definition at line 3394 of file station_cmd.cpp.

References Vehicle::cargo_cap, Vehicle::cargo_type, DEBUG, LinkStat::Frozen(), Station::goods, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, LinkStat::IsNull(), GoodsEntry::link_stats, Vehicle::Next(), RecalcFrozen(), and LinkStat::Unfreeze().

Referenced by Vehicle::LeaveStation().

void DeleteStaleFlows ( StationID  at,
CargoID  c_id,
StationID  to 
)

Delete all flows at a station for specific cargo and destination.

Parameters:
at Station to delete flows from.
c_id Cargo for which flows shall be deleted.
to Remote station of flows to be deleted.

Definition at line 3264 of file station_cmd.cpp.

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

Referenced by Station::RunAverages(), and Station::~Station().

void FindStationsAroundTiles ( const TileArea location,
StationList stations 
)

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

Parameters:
location The location/area of the producer
stations The list to store the stations in

Definition at line 3643 of file station_cmd.cpp.

References _settings_game, SpecializedStation< Station, false >::GetByTile(), Station::GetCatchmentRadius(), TileArea::h, SmallVector< T, S >::Include(), INVALID_TILE, IsTileType(), MAX_CATCHMENT, StationSettings::modified_catchment, MP_STATION, GameSettings::station, TileArea::tile, TileAddWrap(), and TileArea::w.

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

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

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

Parameters:
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 530 of file station_cmd.cpp.

References MapSizeX(), MapSizeY(), max(), min(), TileX(), TileXY(), and TileY().

Referenced by AITileList_IndustryAccepting::AITileList_IndustryAccepting(), DrawStationCoverageAreaText(), AITile::GetCargoAcceptance(), and UpdateStationAcceptance().

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

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

Parameters:
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 477 of file station_cmd.cpp.

References CT_INVALID, TileArea::Intersects(), lengthof, Industry::location, MapSizeX(), MapSizeY(), max(), min(), Industry::produced_cargo, TILE_AREA_LOOP, TileX(), TileXY(), and TileY().

Referenced by DrawStationCoverageAreaText(), and AITile::GetCargoProduction().

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

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

Parameters:
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 2376 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,
const Vehicle front,
StationID  next_station_id,
bool  freeze 
)

Either freeze or increase capacity for all link stats associated with vehicles in the given consist.

Parameters:
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.
freeze If true, freeze capacity, otherwise increase capacity.

Definition at line 3427 of file station_cmd.cpp.

References Vehicle::cargo, Vehicle::cargo_cap, Vehicle::cargo_type, CargoList< Tinst, Tcont >::Count(), LinkStat::Freeze(), SpecializedStation< Station, false >::GetIfValid(), GetMovingAverageLength(), Station::goods, LinkStat::Increase(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, LinkStat::IsNull(), GoodsEntry::link_stats, and Vehicle::Next().

Referenced by Vehicle::BeginLoading(), and RecalcFrozen().

bool IsStationTileBlocked ( TileIndex  tile  ) 

Check whether a rail station tile is NOT traversable.

Parameters:
tile Tile 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 830 of file newgrf_station.cpp.

References StationSpec::blocked, GetStationGfx(), and HasBit().

Referenced by AfterLoadCompanyStats(), CmdBuildRailStation(), CmdConvertRail(), ExploreSegment(), IsCompatibleTrainStationTile(), AIRail::IsRailTile(), RemoveFromRailBaseStation(), and RemoveRailStation().

bool IsStationTileElectrifiable ( TileIndex  tile  ) 

Check if a rail station tile can be electrified.

Parameters:
tile Tile to test.
Returns:
Tile can be electrified.
Note:
This could be cached (during build) in the map array to save on all the dereferencing.

Definition at line 843 of file newgrf_station.cpp.

References GetStationGfx(), HasBit(), StationSpec::pylons, and StationSpec::wires.

Referenced by GetRailTrackBitsUniversal().

void RecalcFrozen ( Station st  ) 

Recalculate all frozen values for all link stats of a station.

This is done by adding up the capacities of all loading vehicles.

Parameters:
st Station.

Definition at line 3364 of file station_cmd.cpp.

References Vehicle::cur_implicit_order_index, OrderList::GetNextStoppingStation(), Station::goods, IncreaseStats(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, GoodsEntry::link_stats, Vehicle::list, and Vehicle::orders.

Referenced by DecreaseFrozen(), Vehicle::LeaveStation(), and RecalcFrozenIfLoading().

void RecalcFrozenIfLoading ( const Vehicle v  ) 

Recalculate the frozen value of the station the given vehicle is loading at if the vehicle is loading.

Parameters:
v Vehicle to be examined.

Definition at line 3352 of file station_cmd.cpp.

References Vehicle::current_order, SpecializedStation< Station, false >::Get(), Order::IsType(), Vehicle::last_station_visited, and RecalcFrozen().

Referenced by CmdCloneOrder(), CmdModifyOrder(), CmdMoveOrder(), DecloneOrder(), DeleteOrder(), DeleteVehicleOrders(), InsertOrder(), and RemoveOrderFromAllVehicles().

void ShowStationViewWindow ( StationID  station  ) 

Opens StationViewWindow for given station.

Parameters:
station station which window should be opened

Definition at line 1812 of file station_gui.cpp.

static Money StationMaintenanceCost ( uint32  num  )  [inline, static]

Calculates the maintenance cost of a number of station tiles.

Parameters:
num Number of station tiles.
Returns:
Total cost.

Definition at line 66 of file station_func.h.

References IntSqrt().

Referenced by CompaniesGenStatistics(), CompanyInfrastructureWindow::DrawWidget(), CompanyInfrastructureWindow::GetTotalMaintenanceCost(), and CompanyInfrastructureWindow::UpdateWidgetSize().

void UpdateAllStationVirtCoords (  ) 

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

Definition at line 432 of file station_cmd.cpp.

References BaseStation::UpdateVirtCoord().

Referenced by CmdRenameTown(), and UpdateAllVirtCoords().

void UpdateStationAcceptance ( Station st,
bool  show_msg 
)