12 #ifndef STATION_BASE_H 13 #define STATION_BASE_H 27 static const byte INITIAL_STATION_RATING = 175;
38 typedef std::map<uint32, StationID> SharesMap;
55 inline FlowStat(StationID st, uint flow,
bool restricted =
false)
70 inline void AppendShare(StationID st, uint flow,
bool restricted =
false)
121 assert(!this->
shares.empty());
124 return this->
shares.upper_bound(rand)->second;
136 assert(!this->
shares.empty());
142 StationID
GetVia(StationID excluded, StationID excluded2 = INVALID_STATION)
const;
154 uint GetFlow()
const;
155 uint GetFlowVia(StationID via)
const;
156 uint GetFlowFrom(StationID from)
const;
157 uint GetFlowFromVia(StationID from, StationID via)
const;
159 void AddFlow(StationID origin, StationID via, uint amount);
160 void PassOnFlow(StationID origin, StationID via, uint amount);
162 void RestrictFlows(StationID via);
163 void ReleaseFlows(StationID via);
164 void FinalizeLocalConsumption(StationID
self);
216 time_since_pickup(255),
217 rating(INITIAL_STATION_RATING),
221 link_graph(INVALID_LINK_GRAPH),
275 return HasBit(this->status, GES_RATING);
283 inline StationID
GetVia(StationID source)
const 285 FlowStatMap::const_iterator flow_it(this->flows.find(source));
286 return flow_it != this->flows.end() ? flow_it->second.GetVia() : INVALID_STATION;
297 inline StationID
GetVia(StationID source, StationID excluded, StationID excluded2 = INVALID_STATION)
const 299 FlowStatMap::const_iterator flow_it(this->flows.find(source));
300 return flow_it != this->flows.end() ? flow_it->second.GetVia(excluded, excluded2) : INVALID_STATION;
334 return this->GetSpec()->fsm;
340 return this->GetSpec()->nof_depots > 0;
354 switch (this->rotation) {
363 default: NOT_REACHED();
378 return this->GetRotatedTileFromOffset(as->
depot_table[i].
ti);
435 if (this->GetRotatedTileFromOffset(as->
depot_table[i].
ti) == tile) {
467 byte time_since_load;
468 byte time_since_unload;
470 byte last_vehicle_type;
471 std::list<Vehicle *> loading_vehicles;
482 void MarkTilesDirty(
bool cargo_change)
const;
484 void UpdateVirtCoord();
487 uint GetPlatformLength(
TileIndex tile)
const;
488 void RecomputeIndustriesNear();
489 static void RecomputeIndustriesNearForAll();
491 uint GetCatchmentRadius()
const;
492 Rect GetCatchmentRect()
const;
499 inline bool TileBelongsToAirport(
TileIndex tile)
const 504 uint32 GetNewGRFVariable(
const ResolverObject &
object, byte variable, byte parameter,
bool *available)
const;
509 #define FOR_ALL_STATIONS(var) FOR_ALL_BASE_STATIONS_OF_TYPE(Station, var) 523 if (!st->TileBelongsToAirport(this->tile)) ++(*
this);
528 (*this).OrthogonalTileIterator::operator++();
529 while (this->tile !=
INVALID_TILE && !st->TileBelongsToAirport(this->tile)) {
530 (*this).OrthogonalTileIterator::operator++();
static void Swap(T &a, T &b)
Type safe swap operation.
byte type
Type of this airport,.
IndustryVector industries_near
Cached list of industries near the station that can accept cargo,.
const HangarTileTable * GetHangarDataByTile(TileIndex tile) const
Retrieve hangar information of a hangar at a given tile.
Finite sTate mAchine (FTA) of an airport.
Types related to the industry.
const AirportSpec * GetSpec() const
Get the AirportSpec that from the airport type of this airport.
TileArea bus_station
Tile area the bus 'station' part covers.
Minimal stack that uses a pool to avoid pointers.
const Station * st
The station the airport is a part of.
Direction GetHangarExitDirection(TileIndex tile) const
Get the exit direction of the hangar at a specific tile.
byte size_y
size of airport in y direction
Iterator to iterate over all tiles belonging to an airport.
SharesMap shares
Shares of flow to be sent via specified station (or consumed locally).
bool HasVehicleEverTriedLoading() const
Reports whether a vehicle has ever tried to load the cargo at this station.
static bool IsAirportTile(TileIndex t)
Is this tile a station tile and an airport tile?
uint GetNumHangars() const
Get the number of hangars on this airport.
byte hangar_num
The hangar to which this tile belongs.
bool HasHangar() const
Check if this airport has at least one hangar.
CargoList that is used for stations.
const AirportFTAClass * GetFTA() const
Get the finite-state machine for this airport or the finite-state machine for the dummy airport in ca...
void SwapShares(FlowStat &other)
Swap the shares maps, and thus the content of this FlowStat with the other one.
Functionality related to the temporary and persistent storage arrays for NewGRFs. ...
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Interface for SpriteGroup-s to access the gamestate.
Set when cargo was delivered for final delivery during the current STATION_ACCEPTANCE_TICKS interval...
TileIndex dock_tile
The location of the dock.
Set when cargo was delivered for final delivery this month.
const HangarTileTable * depot_table
gives the position of the depots on the airports
A standard stop for buses.
Stores station stats for a single cargo.
StationFacility
The facilities a station might be having.
static const AirportSpec dummy
The dummy airport.
A list of all hangar tiles in an airport.
virtual TileIterator * Clone() const
Allocate a new iterator that is a copy of this one.
StationPool _station_pool
The pool of stations.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
bool HasRating() const
Does this cargo have a rating at this station?
byte nof_depots
the number of hangar tiles in this airport
static uint32 RandomRange(uint32 limit)
Pick a random number between 0 and limit - 1, inclusive.
RoadStopType
Types of RoadStops.
Direction
Defines the 8 directions on the map.
NewGRF handling of airports.
Pseudo random number generator.
uint32 always_accepted
Bitmask of always accepted cargo types (by houses, HQs, industry tiles when industry doesn't accept c...
int16 y
The y value of the coordinate.
Set when cargo was delivered for final delivery last month.
Base class for cargo packets.
void ScaleToMonthly(uint runtime)
Scale all shares from link graph's runtime to monthly values.
Buses, trucks and trams belong to this class.
uint GetShare(StationID st) const
Get flow for a station.
byte amount_fract
Fractional part of the amount in the cargo list.
byte rating
Station rating for this cargo.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
RoadStop * truck_stops
All the truck stops.
This indicates whether a cargo has a rating at the station.
StationID GetVia(StationID source) const
Get the best next hop for a cargo packet from station source.
LinkGraphID link_graph
Link graph this station belongs to.
uint unrestricted
Limit for unrestricted shares.
GoodsEntryStatus
Status of this cargo for the station.
FlowStat()
Invalid constructor.
static bool IsRailStationTile(TileIndex t)
Is this tile a station tile and a rail station?
const Direction * rotation
the rotation of each tiletable
StationID GetVia() const
Get a station a package can be routed to.
TileArea truck_station
Tile area the truck 'station' part covers.
byte status
Status of this cargo, see GoodsEntryStatus.
byte layout
Airport layout number.
FlowStat(StationID st, uint flow, bool restricted=false)
Create a FlowStat with an initial entry.
int16 x
The x value of the coordinate.
StationID GetVia(StationID source, StationID excluded, StationID excluded2=INVALID_STATION) const
Get the best next hop for a cargo packet from station source, optionally excluding one or two station...
NodeID node
ID of node in link graph referring to this goods entry.
Represents the covered area of e.g.
Class for pooled persistent storage of data.
Base class for tile iterators.
static const AirportSpec * Get(byte type)
Retrieve airport spec for the given airport.
PersistentStorage * psa
Persistent storage for NewGRF airports.
All airport-related information.
static DirDiff DirDifference(Direction d0, Direction d1)
Calculate the difference between two directions.
static Direction ChangeDir(Direction d, DirDiff delta)
Change a direction by a given difference.
void RestrictShare(StationID st)
Restrict a flow by moving it to the end of the map and decreasing the amount of unrestricted flow...
uint64 flags
stores which blocks on the airport are taken. was 16 bit earlier on, then 32
static const SharesMap empty_sharesmap
Static instance of FlowStat::SharesMap.
DiagDirection
Enumeration for diagonal directions.
byte last_speed
Maximum speed (up to 255) of the last vehicle that tried to load this cargo.
Declaration of link graph types used for cargo distribution.
byte last_age
Age in years (up to 255) of the last vehicle that tried to load this cargo.
TileIndex GetHangarTile(uint hangar_num) const
Get the first tile of the given hangar.
TileIndexDiffC ti
Tile offset from the top-most airport tile.
DirectionByte rotation
How this airport is rotated.
RoadStop * bus_stops
All the road stops.
Base class for all pools.
FlowStatMap flows
Planned flows through this station.
void ChangeShare(StationID st, int flow)
Change share for specified station.
StationID GetViaWithRestricted(bool &is_restricted) const
Get a station a package can be routed to.
Maximal number of cargo types in a game.
A pair-construct of a TileIndexDiff.
void ReleaseShare(StationID st)
Release ("unrestrict") a flow by moving it to the begin of the map and increasing the amount of unres...
static TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between to tiles from a TileIndexDiffC struct.
uint GetUnrestricted() const
Return total amount of unrestricted shares.
Set when a vehicle ever delivered cargo to the station for final delivery.
uint GetHangarNum(TileIndex tile) const
Get the hangar number of the hangar at a specific tile.
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
StationType
Station types.
Direction dir
Direction of the exit.
uint max_waiting_cargo
Max cargo from this station waiting at any station.
uint32 TileIndex
The index/ID of a Tile.
void Invalidate()
Reduce all flows to minimum capacity so that they don't get in the way of link usage statistics too m...
const SharesMap * GetShares() const
Get the actual shares as a const pointer so that they can be iterated over.
byte size_x
size of airport in x direction
void AppendShare(StationID st, uint flow, bool restricted=false)
Add some flow to the end of the shares map.
bool TileBelongsToRailStation(TileIndex tile) const
Check whether a specific tile belongs to this station.
Flow statistics telling how much flow should be sent along a link.
A Stop for a Road Vehicle.
Iterator to iterate over a tile area (rectangle) of the map.
Base classes/functions for base stations.
Flow descriptions by origin stations.
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
Airport airport
Tile area the airport covers.
TileIndex GetRotatedTileFromOffset(TileIndexDiffC tidc) const
Add the tileoffset to the base tile of this airport but rotate it first.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Specification of a rectangle with absolute coordinates of all edges.
IndustryType indtype
Industry type to get the name from.
byte time_since_pickup
Number of rating-intervals (up to 255) since the last vehicle tried to load this cargo.
Defines the data structure for an airport.
Set when the station accepts the cargo currently for final deliveries.
Class defining several overloaded accessors so we don't have to cast base stations that often...
AirportTileIterator(const Station *st)
Construct the iterator.