Make DeleteStaleLinks static
[openttd/fttd.git] / src / station_func.h
blob6ef30c69fab70da8aa3bb1665d4d1000ad219664
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
10 /** @file station_func.h Functions related to stations. */
12 #ifndef STATION_FUNC_H
13 #define STATION_FUNC_H
15 #include "sprite.h"
16 #include "rail_type.h"
17 #include "road_type.h"
18 #include "vehicle_type.h"
19 #include "economy_func.h"
20 #include "rail.h"
21 #include "map/coord.h"
22 #include "map/class.h"
23 #include "map/rail.h"
24 #include "map/depot.h"
25 #include "map/station.h"
26 #include "map/tilearea.h"
27 #include "linkgraph/linkgraph_type.h"
29 bool IsHangar(TileIndex t);
31 /**
32 * Is tile \a t an hangar tile?
33 * @param t Tile to check
34 * @return \c true if the tile is an hangar
36 static inline bool IsHangarTile(TileIndex t)
38 return IsStationTile(t) && IsHangar(t);
41 void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius);
43 void FindStationsAroundTiles(const TileArea &location, StationList *stations);
45 void ShowStationViewWindow(StationID station);
46 void UpdateAllStationVirtCoords();
48 CargoArray GetAreaProduction (const TileArea &area, int rad = 0);
49 CargoArray GetAreaAcceptance (const TileArea &area, int rad = 0, uint32 *always_accepted = NULL);
51 void UpdateStationAcceptance(Station *st, bool show_msg);
53 const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx);
55 void RailStationPickerDrawSprite (BlitArea *dpi, int x, int y, bool waypoint, RailType railtype, int image);
56 void RoadStationPickerDrawSprite (BlitArea *dpi, int x, int y, bool bus, bool tram, int image);
58 bool HasStationInUse(StationID station, bool include_company, CompanyID company);
60 void DeleteOilRig(TileIndex t);
62 /* Check if a rail station tile is traversable. */
63 bool IsStationTileBlocked(TileIndex tile);
65 /**
66 * Is the given tile a tile with a depot on it?
67 * @param tile the tile to check
68 * @return true if and only if there is a depot on the tile.
70 static inline bool IsDepotTile(TileIndex tile)
72 return IsGroundDepotTile(tile) || IsShipDepotTile(tile) || IsHangarTile(tile);
75 /**
76 * Check if a tile is a valid continuation to a railstation tile.
77 * The tile \a test_tile is a valid continuation to \a station_tile, if all of the following are true:
78 * \li \a test_tile is a rail station tile
79 * \li the railtype of \a test_tile is compatible with the railtype of \a station_tile
80 * \li the tracks on \a test_tile and \a station_tile are in the same direction
81 * \li both tiles belong to the same station
82 * \li \a test_tile is not blocked (@see IsStationTileBlocked)
83 * @param test_tile Tile to test
84 * @param station_tile Station tile to compare with
85 * @pre IsRailStationTile(station_tile)
86 * @return true if the two tiles are compatible
88 static inline bool IsCompatibleTrainStationTile(TileIndex test_tile, TileIndex station_tile)
90 assert(IsRailStationTile(station_tile));
91 return IsRailStationTile(test_tile) && IsCompatibleRail(GetRailType(test_tile), GetRailType(station_tile)) &&
92 GetRailStationAxis(test_tile) == GetRailStationAxis(station_tile) &&
93 GetStationIndex(test_tile) == GetStationIndex(station_tile) &&
94 !IsStationTileBlocked(test_tile);
97 bool CanStationTileHavePylons(TileIndex tile);
98 bool CanStationTileHaveWires(TileIndex tile);
100 void UpdateAirportsNoise();
102 bool SplitGroundSpriteForOverlay(const TileInfo *ti, SpriteID *ground, RailTrackOffset *overlay_offset);
104 void IncreaseStats(Station *st, const Vehicle *v, StationID next_station_id);
105 void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint capacity, uint usage, EdgeUpdateMode mode);
106 void RerouteCargo(Station *st, CargoID c, StationID avoid, StationID avoid2);
109 * Calculates the maintenance cost of a number of station tiles.
110 * @param num Number of station tiles.
111 * @return Total cost.
113 static inline Money StationMaintenanceCost(uint32 num)
115 return (_price[PR_INFRASTRUCTURE_STATION] * num * (1 + IntSqrt(num))) >> 7; // 7 bits scaling.
118 Money AirportMaintenanceCost(Owner owner);
120 #endif /* STATION_FUNC_H */