OpenTTD Source  20241121-master-g67a0fccfad
station_func.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #ifndef STATION_FUNC_H
11 #define STATION_FUNC_H
12 
13 #include "sprite.h"
14 #include "rail_type.h"
15 #include "road_type.h"
16 #include "vehicle_type.h"
17 #include "economy_func.h"
18 #include "rail.h"
19 #include "road.h"
21 #include "industry_type.h"
22 
23 void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius);
24 
25 void ShowStationViewWindow(StationID station);
27 void ClearAllStationCachedNames();
28 
29 CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad);
30 CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, CargoTypes *always_accepted = nullptr);
31 
32 void UpdateStationAcceptance(Station *st, bool show_msg);
33 CargoTypes GetAcceptanceMask(const Station *st);
34 CargoTypes GetEmptyMask(const Station *st);
35 
36 void SetRailStationTileFlags(TileIndex tile, const StationSpec *statspec);
37 const DrawTileSprites *GetStationTileLayout(StationType st, uint8_t gfx);
38 void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image);
39 
40 bool HasStationInUse(StationID station, bool include_company, CompanyID company);
41 
42 void DeleteOilRig(TileIndex t);
43 void UpdateStationDockingTiles(Station *st);
44 void RemoveDockingTile(TileIndex t);
46 
47 void UpdateAirportsNoise();
48 
49 bool SplitGroundSpriteForOverlay(const TileInfo *ti, SpriteID *ground, RailTrackOffset *overlay_offset);
50 
51 void IncreaseStats(Station *st, const Vehicle *v, StationID next_station_id, uint32_t time);
52 void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint capacity, uint usage, uint32_t time, EdgeUpdateMode mode);
53 void RerouteCargo(Station *st, CargoID c, StationID avoid, StationID avoid2);
54 
60 inline Money StationMaintenanceCost(uint32_t num)
61 {
62  return (_price[PR_INFRASTRUCTURE_STATION] * num * (1 + IntSqrt(num))) >> 7; // 7 bits scaling.
63 }
64 
66 
67 #endif /* STATION_FUNC_H */
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:22
Owner
Enum for all companies/owners.
Definition: company_type.h:18
uint32_t IntSqrt(uint32_t num)
Compute the integer square root.
Definition: math_func.cpp:42
Functions related to the economy.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:18
Types related to the industry.
Declaration of link graph types used for cargo distribution.
EdgeUpdateMode
Special modes for updating links.
Rail specific functions.
RailTrackOffset
Offsets for sprites within an overlay/underlay set.
Definition: rail.h:70
The different types of rail.
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
Road specific functions.
Enums and other types related to roads.
RoadType
The different roadtypes we support.
Definition: road_type.h:25
Base for drawing complex sprites.
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.
CargoTypes GetEmptyMask(const Station *st)
Get a mask of the cargo types that are empty at the station.
void ClearDockingTilesCheckingNeighbours(TileIndex tile)
Clear docking tile status from tiles around a removed dock, if the tile has no neighbours which would...
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 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.
bool HasStationInUse(StationID station, bool include_company, CompanyID company)
Tests whether the company's vehicles have this station in orders.
Money AirportMaintenanceCost(Owner owner)
Calculates the maintenance cost of all airports of a company.
Definition: station.cpp:709
Money StationMaintenanceCost(uint32_t num)
Calculates the maintenance cost of a number of station tiles.
Definition: station_func.h:60
void ShowStationViewWindow(StationID station)
Opens StationViewWindow for given station.
void UpdateAllStationVirtCoords()
Update the virtual coords needed to draw the station sign for all stations.
CargoTypes GetAcceptanceMask(const Station *st)
Get a mask of the cargo types that the station accepts.
void UpdateAirportsNoise()
Recalculate the noise generated by the airports of each town.
void UpdateStationAcceptance(Station *st, bool show_msg)
Update the acceptance for a station.
void SetRailStationTileFlags(TileIndex tile, const StationSpec *statspec)
Set rail station tile flags for the given tile.
CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad)
Get the cargo types being produced around the tile (in a rectangle).
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 ra...
const DrawTileSprites * GetStationTileLayout(StationType st, uint8_t gfx)
Get station tile layout for a station type and its station gfx.
StationType
Station types.
Definition: station_type.h:31
Class for storing amounts of cargo.
Definition: cargo_type.h:114
Ground palette sprite of a tile, together with its sprite layout.
Definition: sprite.h:58
Station specification.
Station data structure.
Definition: station_base.h:439
Tile information, used while rendering the tile.
Definition: tile_cmd.h:43
Vehicle data structure.
Definition: vehicle_base.h:244
Types related to vehicles.