OpenTTD Source 20261129-master-g72a8bdc861
station_base.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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef STATION_BASE_H
11#define STATION_BASE_H
12
13#include "core/flatset_type.hpp"
14#include "core/random_func.hpp"
15#include "base_station_base.h"
16#include "misc/history_type.hpp"
17#include "newgrf_airport.h"
18#include "cargopacket.h"
19#include "industry_type.h"
21#include "newgrf_storage.h"
22#include "tilearea_bitmap.h"
23
24static const uint8_t INITIAL_STATION_RATING = 175;
25static const uint8_t MAX_STATION_RATING = 255;
26
34class FlowStat {
35public:
36 typedef std::map<uint32_t, StationID> SharesMap;
37
38 static const SharesMap empty_sharesmap;
39
45 inline FlowStat() {NOT_REACHED();}
46
53 inline FlowStat(StationID st, uint flow, bool restricted = false)
54 {
55 assert(flow > 0);
56 this->shares[flow] = st;
57 this->unrestricted = restricted ? 0 : flow;
58 }
59
68 inline void AppendShare(StationID st, uint flow, bool restricted = false)
69 {
70 assert(flow > 0);
71 this->shares[(--this->shares.end())->first + flow] = st;
72 if (!restricted) this->unrestricted += flow;
73 }
74
75 uint GetShare(StationID st) const;
76
77 void ChangeShare(StationID st, int flow);
78
79 void RestrictShare(StationID st);
80
81 void ReleaseShare(StationID st);
82
83 void ScaleToMonthly(uint runtime);
84
90 inline const SharesMap *GetShares() const { return &this->shares; }
91
96 inline uint GetUnrestricted() const { return this->unrestricted; }
97
103 inline void SwapShares(FlowStat &other)
104 {
105 this->shares.swap(other.shares);
106 std::swap(this->unrestricted, other.unrestricted);
107 }
108
117 inline StationID GetViaWithRestricted(bool &is_restricted) const
118 {
119 assert(!this->shares.empty());
120 uint rand = RandomRange((--this->shares.end())->first);
121 is_restricted = rand >= this->unrestricted;
122 return this->shares.upper_bound(rand)->second;
123 }
124
132 inline StationID GetVia() const
133 {
134 assert(!this->shares.empty());
135 return this->unrestricted > 0 ?
136 this->shares.upper_bound(RandomRange(this->unrestricted))->second :
137 StationID::Invalid();
138 }
139
140 StationID GetVia(StationID excluded, StationID excluded2 = StationID::Invalid()) const;
141
142 void Invalidate();
143
144private:
145 SharesMap shares{};
146 uint unrestricted = 0;
147};
148
150class FlowStatMap : public std::map<StationID, FlowStat> {
151public:
152 uint GetFlow() const;
153 uint GetFlowVia(StationID via) const;
154 uint GetFlowFrom(StationID from) const;
155 uint GetFlowFromVia(StationID from, StationID via) const;
156
157 void AddFlow(StationID origin, StationID via, uint amount);
158 void PassOnFlow(StationID origin, StationID via, uint amount);
159 std::vector<StationID> DeleteFlows(StationID via);
160 void RestrictFlows(StationID via);
161 void ReleaseFlows(StationID via);
162 void FinalizeLocalConsumption(StationID self);
163};
164
170 enum class State : uint8_t {
176
186
192
198
204
210 };
211
214
218
219 bool IsEmpty() const
220 {
221 return this->cargo.TotalCount() == 0 && this->flows.empty();
222 }
223 };
224
227 uint16_t rx_accepted;
228 uint16_t rx_waiting;
229 uint16_t rx_supply;
230 uint16_t rx_lost;
231 uint8_t rating;
232 };
233
237
238 uint32_t accumulated_waiting = 0;
239 uint32_t supply = 0;
240 uint32_t lost = 0;
241 uint32_t accepted = 0;
242 };
243
245 NodeID node = INVALID_NODE;
246 LinkGraphID link_graph = LinkGraphID::Invalid();
247
249
255 uint8_t time_since_pickup = 255;
256
257 uint8_t rating = INITIAL_STATION_RATING;
258
268 uint8_t last_speed = 0;
269
274 uint8_t last_age = 255;
275
276 uint8_t amount_fract = 0;
277
278 uint16_t accumulated_rating = 0;
279
285 bool HasVehicleEverTriedLoading() const { return this->last_speed != 0; }
286
291 inline bool HasRating() const
292 {
293 return this->status.Test(GoodsEntry::State::Rating);
294 }
295
301 inline StationID GetVia(StationID source) const
302 {
303 if (!this->HasData()) return StationID::Invalid();
304
305 FlowStatMap::const_iterator flow_it(this->GetData().flows.find(source));
306 return flow_it != this->GetData().flows.end() ? flow_it->second.GetVia() : StationID::Invalid();
307 }
308
317 inline StationID GetVia(StationID source, StationID excluded, StationID excluded2 = StationID::Invalid()) const
318 {
319 if (!this->HasData()) return StationID::Invalid();
320
321 FlowStatMap::const_iterator flow_it(this->GetData().flows.find(source));
322 return flow_it != this->GetData().flows.end() ? flow_it->second.GetVia(excluded, excluded2) : StationID::Invalid();
323 }
324
329 [[debug_inline]] inline bool HasData() const { return this->data != nullptr; }
330
334 void ClearData() { this->data.reset(); }
335
341 [[debug_inline]] inline const GoodsEntryData &GetData() const
342 {
343 assert(this->HasData());
344 return *this->data;
345 }
346
353 {
354 assert(this->HasData());
355 return *this->data;
356 }
357
363 {
364 if (!this->HasData()) this->data = std::make_unique<GoodsEntryData>();
365 return *this->data;
366 }
367
372 inline bool HasHistory() const { return this->stats != nullptr; }
373
378 inline const CargoHistoryData &GetHistory() const
379 {
380 assert(this->HasHistory());
381 return *this->stats;
382 }
383
389 {
390 assert(this->HasHistory());
391 return *this->stats;
392 }
393
399 {
400 if (!this->HasHistory()) this->stats = std::make_unique<CargoHistoryData>();
401 return *this->stats;
402 }
403
404 uint8_t ConvertState() const;
405
411 inline uint AvailableCount() const
412 {
413 return this->HasData() ? this->GetData().cargo.AvailableCount() : 0;
414 }
415
421 inline uint TotalCount() const
422 {
423 return this->HasData() ? this->GetData().cargo.TotalCount() : 0;
424 }
425
426private:
427 std::unique_ptr<GoodsEntryData> data = nullptr;
428 std::unique_ptr<CargoHistoryData> stats;
429};
430
432struct Airport : public TileArea {
433 Airport() : TileArea(INVALID_TILE, 0, 0) {}
434
436 uint8_t type = 0;
437 uint8_t layout = 0;
439
441
447 const AirportSpec *GetSpec() const
448 {
449 if (this->tile == INVALID_TILE) return &AirportSpec::dummy;
450 return AirportSpec::Get(this->type);
451 }
452
459 const AirportFTAClass *GetFTA() const
460 {
461 return this->GetSpec()->fsm;
462 }
463
468 inline bool HasHangar() const
469 {
470 return !this->GetSpec()->depots.empty();
471 }
472
482 {
483 const AirportSpec *as = this->GetSpec();
484 switch (this->rotation) {
485 case Direction::N: return this->tile + ToTileIndexDiff(tidc);
486
487 case Direction::E: return this->tile + TileDiffXY(tidc.y, as->size_x - 1 - tidc.x);
488
489 case Direction::S: return this->tile + TileDiffXY(as->size_x - 1 - tidc.x, as->size_y - 1 - tidc.y);
490
491 case Direction::W: return this->tile + TileDiffXY(as->size_y - 1 - tidc.y, tidc.x);
492
493 default: NOT_REACHED();
494 }
495 }
496
503 inline TileIndex GetHangarTile(uint hangar_num) const
504 {
505 for (const auto &depot : this->GetSpec()->depots) {
506 if (depot.hangar_num == hangar_num) {
507 return this->GetRotatedTileFromOffset(depot.ti);
508 }
509 }
510 NOT_REACHED();
511 }
512
520 {
521 const AirportSpec *as = this->GetSpec();
523 return ChangeDir(htt->dir, DirDifference(this->rotation, as->layouts[0].rotation));
524 }
525
532 inline uint GetHangarNum(TileIndex tile) const
533 {
535 return htt->hangar_num;
536 }
537
542 inline uint GetNumHangars() const
543 {
544 uint num = 0;
545 uint counted = 0;
546 for (const auto &depot : this->GetSpec()->depots) {
547 if (!HasBit(counted, depot.hangar_num)) {
548 num++;
549 SetBit(counted, depot.hangar_num);
550 }
551 }
552 return num;
553 }
554
555private:
563 {
564 for (const auto &depot : this->GetSpec()->depots) {
565 if (this->GetRotatedTileFromOffset(depot.ti) == tile) {
566 return &depot;
567 }
568 }
569 NOT_REACHED();
570 }
571};
572
574 uint distance = 0;
575 Industry *industry = nullptr;
576
577 bool operator== (const IndustryListEntry &other) const { return this->distance == other.distance && this->industry == other.industry; };
578};
579
581 bool operator() (const IndustryListEntry &lhs, const IndustryListEntry &rhs) const;
582};
583
584typedef std::set<IndustryListEntry, IndustryCompare> IndustryList;
585struct RoadVehicle;
586
588struct Station final : SpecializedStation<Station, false> {
589public:
590 RoadStop *GetPrimaryRoadStop(RoadStopType type) const
591 {
592 return type == RoadStopType::Bus ? bus_stops : truck_stops;
593 }
594
595 RoadStop *GetPrimaryRoadStop(const RoadVehicle *v) const;
596
597 RoadStop *bus_stops = nullptr;
601
605
606 IndustryType indtype = IT_INVALID;
607
609
610 StationVehicleTypes had_vehicle_of_type{};
611
612 uint8_t time_since_load = 0;
613 uint8_t time_since_unload = 0;
614
615 VehicleType last_vehicle_type = VehicleType::Invalid;
616 std::list<Vehicle *> loading_vehicles{};
617 std::array<GoodsEntry, NUM_CARGO> goods;
619
620 IndustryList industries_near{};
621 Industry *industry = nullptr;
622
624
625 Station(StationID index, TileIndex tile = INVALID_TILE);
626 ~Station() override;
627
628 void AddFacility(StationFacility new_facility_bit, TileIndex facil_xy);
629
630 void MarkTilesDirty(bool cargo_change) const;
631
632 void UpdateVirtCoord() override;
633
634 void MoveSign(TileIndex new_xy) override;
635
636 void AfterStationTileSetChange(bool adding, StationType type);
637
638 uint GetPlatformLength(TileIndex tile, DiagDirection dir) const override;
639 uint GetPlatformLength(TileIndex tile) const override;
640 void RecomputeCatchment(bool no_clear_nearby_lists = false);
641 static void RecomputeCatchmentForAll();
642
643 uint GetCatchmentRadius() const;
644 bool CatchmentCoversTown(TownID t) const;
645 void AddIndustryToDeliver(Industry *ind, TileIndex tile);
648
649 inline bool TileIsInCatchment(TileIndex tile) const
650 {
651 return this->catchment_tiles.Contains(tile);
652 }
653
654 inline bool TileBelongsToRailStation(TileIndex tile) const override
655 {
656 return IsRailStationTile(tile) && GetStationIndex(tile) == this->index;
657 }
658
659 inline bool TileBelongsToRoadStop(TileIndex tile) const
660 {
661 return IsStationRoadStopTile(tile) && GetStationIndex(tile) == this->index;
662 }
663
664 inline bool TileBelongsToAirport(TileIndex tile) const
665 {
666 return IsAirportTile(tile) && GetStationIndex(tile) == this->index;
667 }
668
669 uint32_t GetNewGRFVariable(const ResolverObject &object, uint8_t variable, uint8_t parameter, bool &available) const override;
670
671 TileArea GetTileArea(StationType type) const override;
672};
673
674void RebuildStationKdtree();
675
683template <typename Func>
684void ForAllStationsAroundTiles(const TileArea &ta, Func func)
685{
686 /* There are no stations, so we will never find anything. */
687 if (Station::GetNumItems() == 0) return;
688
689 /* Not using, or don't have a nearby stations list, so we need to scan. */
690 FlatSet<StationID> seen_stations;
691
692 /* Scan an area around the building covering the maximum possible station
693 * to find the possible nearby stations. */
694 uint max_c = _settings_game.station.modified_catchment ? MAX_CATCHMENT : CA_UNMODIFIED;
695 TileArea ta_ext = TileArea(ta).Expand(max_c);
696 for (TileIndex tile : ta_ext) {
697 if (!IsTileType(tile, TileType::Station)) continue;
698 seen_stations.insert(GetStationIndex(tile));
699 }
700
701 for (StationID stationid : seen_stations) {
702 Station *st = Station::GetIfValid(stationid);
703 if (st == nullptr) continue; /* Waypoint */
704
705 /* Check if station is attached to an industry */
706 if (!_settings_game.station.serve_neutral_industries && st->industry != nullptr) continue;
707
708 /* Test if the tile is within the station's catchment */
709 for (TileIndex tile : ta) {
710 if (st->TileIsInCatchment(tile)) {
711 if (func(st, tile)) break;
712 }
713 }
714 }
715}
716
717#endif /* STATION_BASE_H */
EnumBitSet< AirportBlock, uint64_t > AirportBlocks
Bitset of AirportBlock elements.
Definition airport.h:135
Base classes/functions for base stations.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
EnumBitSet< CargoType, uint64_t > CargoTypes
Bitset of CargoType elements.
Definition cargo_type.h:115
Base class for cargo packets.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Represents a tile area containing containing individually set tiles.
bool Contains(TileIndex tile) const
Test if a tile is part of the tile area.
Enum-as-bit-set wrapper.
Flat set implementation that uses a sorted vector for storage.
std::pair< const_iterator, bool > insert(const Tkey &key)
Insert a key into the set, if it does not already exist.
Flow descriptions by origin stations.
uint GetFlow() const
Get the sum of all flows from this FlowStatMap.
void PassOnFlow(StationID origin, StationID via, uint amount)
Pass on some flow, remembering it as invalid, for later subtraction from locally consumed flow.
std::vector< StationID > DeleteFlows(StationID via)
Delete all flows at a station for specific cargo and destination.
void AddFlow(StationID origin, StationID via, uint amount)
Add some flow from "origin", going via "via".
uint GetFlowFrom(StationID from) const
Get the sum of flows from a specific station from this FlowStatMap.
void FinalizeLocalConsumption(StationID self)
Subtract invalid flows from locally consumed flow.
void ReleaseFlows(StationID via)
Release all flows at a station for specific cargo and destination.
uint GetFlowFromVia(StationID from, StationID via) const
Get the flow from a specific station via a specific other station.
uint GetFlowVia(StationID via) const
Get the sum of flows via a specific station from this FlowStatMap.
void RestrictFlows(StationID via)
Restrict all flows at a station for specific cargo and destination.
static const SharesMap empty_sharesmap
Static instance of FlowStat::SharesMap.
void ScaleToMonthly(uint runtime)
Scale all shares from link graph's runtime to monthly values.
void RestrictShare(StationID st)
Restrict a flow by moving it to the end of the map and decreasing the amount of unrestricted flow.
uint GetShare(StationID st) const
Get flow for a station.
void SwapShares(FlowStat &other)
Swap the shares maps, and thus the content of this FlowStat with the other one.
uint GetUnrestricted() const
Return total amount of unrestricted shares.
StationID GetVia() const
Get a station a package can be routed to.
StationID GetViaWithRestricted(bool &is_restricted) const
Get a station a package can be routed to.
const SharesMap * GetShares() const
Get the actual shares as a const pointer so that they can be iterated over.
SharesMap shares
Shares of flow to be sent via specified station (or consumed locally).
void ReleaseShare(StationID st)
Release ("unrestrict") a flow by moving it to the begin of the map and increasing the amount of unres...
void ChangeShare(StationID st, int flow)
Change share for specified station.
void AppendShare(StationID st, uint flow, bool restricted=false)
Add some flow to the end of the shares map.
FlowStat()
Invalid constructor.
void Invalidate()
Reduce all flows to minimum capacity so that they don't get in the way of link usage statistics too m...
uint unrestricted
Limit for unrestricted shares.
FlowStat(StationID st, uint flow, bool restricted=false)
Create a FlowStat with an initial entry.
TileIndex tile
The base tile of the area.
OrthogonalTileArea & Expand(int rad)
Expand a tile area by rad tiles in each direction, keeping within map bounds.
CargoList that is used for stations.
uint TotalCount() const
Returns total count of cargo at the station, including cargo which is already reserved for loading.
uint AvailableCount() const
Returns sum of cargo still available for loading at the station.
DirDiff DirDifference(Direction d0, Direction d1)
Calculate the difference between two directions.
Direction ChangeDir(Direction d, DirDiff delta)
Change a direction by a given difference.
Direction
Defines the 8 directions on the map.
@ Invalid
Flag for an invalid direction.
DiagDirection
Enumeration for diagonal directions.
Flat set container implementation.
void MarkTilesDirty(bool cargo_change) const
Marks the tiles of the station as dirty.
Definition station.cpp:250
Types for storing historical data.
std::array< T, HISTORY_RECORDS > HistoryData
Container type for storing history data.
uint64_t ValidHistoryMask
Mask of valid history records.
Types related to the industry.
Declaration of link graph types used for cargo distribution.
TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between two tiles from a TileIndexDiffC struct.
Definition map_func.h:444
TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
Definition map_func.h:392
NewGRF handling of airports.
Functionality related to the temporary and persistent storage arrays for NewGRFs.
Pseudo random number generator.
uint32_t RandomRange(uint32_t limit, const std::source_location location=std::source_location::current())
Pick a random number between 0 and limit - 1, inclusive.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:61
void ForAllStationsAroundTiles(const TileArea &ta, Func func)
Call a function on all stations that have any part of the requested area within their catchment.
bool IsStationRoadStopTile(Tile t)
Is tile t a road stop station?
bool IsAirportTile(Tile t)
Is this tile a station tile and an airport tile?
bool IsRailStationTile(Tile t)
Is this tile a station tile and a rail station?
StationID GetStationIndex(Tile t)
Get StationID from a tile.
Definition station_map.h:26
RoadStopType
Types of RoadStops.
@ Bus
A standard stop for buses.
StationFacility
The facilities a station might be having.
StationType
Station types.
static constexpr uint MAX_CATCHMENT
Maximum catchment for airports with "modified catchment" enabled.
static constexpr uint CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
EnumBitSet< StationVehicleType, uint8_t > StationVehicleTypes
Bitset of StationVehicleType elements.
#define debug_inline
When making a (pure) debug build, the compiler will by default disable inlining of functions.
Definition stdafx.h:212
Finite sTate mAchine (FTA) of an airport.
Definition airport.h:161
Defines the data structure for an airport.
std::vector< AirportTileLayout > layouts
List of layouts composing the airport.
static const AirportSpec dummy
The dummy airport.
const struct AirportFTAClass * fsm
the finite statemachine for the default airports
uint8_t size_y
size of airport in y direction
uint8_t size_x
size of airport in x direction
static const AirportSpec * Get(uint8_t type)
Retrieve airport spec for the given airport.
std::span< const HangarTileTable > depots
Position of the depots on the airports.
All airport-related information.
AirportBlocks blocks
stores which blocks on the airport are taken. was 16 bit earlier on, then 32
TileIndex GetRotatedTileFromOffset(TileIndexDiffC tidc) const
Add the tileoffset to the base tile of this airport but rotate it first.
bool HasHangar() const
Check if this airport has at least one hangar.
uint GetHangarNum(TileIndex tile) const
Get the hangar number of the hangar at a specific tile.
Direction rotation
How this airport is rotated.
uint8_t type
Type of this airport,.
Direction GetHangarExitDirection(TileIndex tile) const
Get the exit direction of the hangar at a specific tile.
PersistentStorage * psa
Persistent storage for NewGRF airports.
uint GetNumHangars() const
Get the number of hangars on this airport.
const AirportFTAClass * GetFTA() const
Get the finite-state machine for this airport or the finite-state machine for the dummy airport in ca...
TileIndex GetHangarTile(uint hangar_num) const
Get the first tile of the given hangar.
const HangarTileTable * GetHangarDataByTile(TileIndex tile) const
Retrieve hangar information of a hangar at a given tile.
const AirportSpec * GetSpec() const
Get the AirportSpec that from the airport type of this airport.
uint8_t layout
Airport layout number.
Storage for station cargo history.
uint32_t supply
Cargo supplied over the last period.
HistoryData< CargoHistory > history
Historical cargo data.
uint32_t lost
Cargo lost over the last period.
uint32_t accumulated_waiting
Accumulated waiting over the last period.
uint32_t accepted
Cargo accepted over the last period.
Individual data point for station cargo history.
uint16_t rx_waiting
Compressed cargo waiting.
uint16_t rx_lost
Compressed cargo lost.
uint16_t rx_accepted
Compressed cargo accepted.
uint8_t rating
Cargo rating.
uint16_t rx_supply
Compressed cargo supply.
FlowStatMap flows
Planned flows through this station.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
Stores station stats for a single cargo.
uint max_waiting_cargo
Max cargo from this station waiting at any station.
bool HasRating() const
Does this cargo have a rating at this station?
StationID GetVia(StationID source, StationID excluded, StationID excluded2=StationID::Invalid()) const
Get the best next hop for a cargo packet from station source, optionally excluding one or two station...
void ClearData()
Clear optional cargo packet/flow data.
std::unique_ptr< CargoHistoryData > stats
Optional cargo history data.
uint16_t accumulated_rating
Accumulated rating over the last month.
const CargoHistoryData & GetHistory() const
Get the cargo history data.
uint8_t last_speed
Maximum speed (up to 255) of the last vehicle that tried to load this cargo.
uint TotalCount() const
Returns total count of cargo at the station, including cargo which is already reserved for loading.
uint8_t last_age
Age in years (up to 255) of the last vehicle that tried to load this cargo.
CargoHistoryData & GetHistory()
Get the cargo history data.
uint8_t time_since_pickup
Number of rating-intervals (up to 255) since the last vehicle tried to load this cargo.
std::unique_ptr< GoodsEntryData > data
Optional cargo packet and flow data.
States status
Status of this cargo, see State.
NodeID node
ID of node in link graph referring to this goods entry.
State
Status of this cargo for the station.
@ LastMonth
Set when cargo was delivered for final delivery last month.
@ Acceptance
Set when the station accepts the cargo currently for final deliveries.
@ EverAccepted
Set when a vehicle ever delivered cargo to the station for final delivery.
@ Rating
This indicates whether a cargo has a rating at the station.
@ AcceptedBigtick
Set when cargo was delivered for final delivery during the current STATION_ACCEPTANCE_TICKS interval.
@ CurrentMonth
Set when cargo was delivered for final delivery this month.
const GoodsEntryData & GetData() const
Get optional cargo packet/flow data.
uint8_t amount_fract
Fractional part of the amount in the cargo list.
LinkGraphID link_graph
Link graph this station belongs to.
bool HasVehicleEverTriedLoading() const
Reports whether a vehicle has ever tried to load the cargo at this station.
CargoHistoryData & GetOrCreateHistory()
Get or create the cargo history data.
uint8_t rating
Station rating for this cargo.
bool HasData() const
Test if this goods entry has optional cargo packet/flow data.
bool HasHistory() const
Test if cargo history is present.
GoodsEntryData & GetOrCreateData()
Get optional cargo packet/flow data.
GoodsEntryData & GetData()
Get non-const optional cargo packet/flow data.
uint AvailableCount() const
Returns sum of cargo still available for loading at the station.
uint8_t ConvertState() const
Convert GoodsEntry status to the form required for NewGRF variables.
EnumBitSet< State, uint8_t > States
Bitset of State elements.
StationID GetVia(StationID source) const
Get the best next hop for a cargo packet from station source.
A list of all hangar tiles in an airport.
Direction dir
Direction of the exit.
uint8_t hangar_num
The hangar to which this tile belongs.
Defines the internal data of a functional industry.
Definition industry.h:64
Class for pooled persistent storage of data.
A Stop for a Road Vehicle.
Buses, trucks and trams belong to this class.
Definition roadveh.h:105
SpecializedStation(StationID index, TileIndex tile)
static Station * GetIfValid(auto index)
Station data structure.
TileArea GetTileArea(StationType type) const override
Get the tile area for a given station type.
uint GetPlatformLength(TileIndex tile, DiagDirection dir) const override
Determines the REMAINING length of a platform, starting at (and including) the given tile.
Definition station.cpp:292
~Station() override
Clean up a station by clearing vehicle orders, invalidating windows and removing link stats.
Definition station.cpp:84
RoadStop * bus_stops
All the road stops.
bool CatchmentCoversTown(TownID t) const
Test if the given town ID is covered by our catchment area.
Definition station.cpp:434
TileArea ship_station
Tile area the ship 'station' part covers.
IndustryType indtype
Industry type to get the name from.
IndustryList industries_near
Cached list of industries near the station that can accept cargo,.
TileArea docking_station
Tile area the docking tiles cover.
CargoTypes always_accepted
Bitmask of always accepted cargo types (by houses, HQs, industry tiles when industry doesn't accept c...
Industry * industry
NOSAVE: Associated industry for neutral stations. (Rebuilt on load from Industry->st).
void MoveSign(TileIndex new_xy) override
Move the station main coordinate somewhere else.
static void RecomputeCatchmentForAll()
Recomputes catchment of all stations.
Definition station.cpp:513
std::array< GoodsEntry, NUM_CARGO > goods
Goods at this station.
void RemoveFromAllNearbyLists()
Remove this station from the nearby stations lists of nearby towns and industries.
Definition station.cpp:409
TileArea bus_station
Tile area the bus 'station' part covers.
bool TileBelongsToRailStation(TileIndex tile) const override
Check whether a specific tile belongs to this station.
ValidHistoryMask valid_cargo_history
Mask of valid cargo history records.
BitmapTileArea catchment_tiles
NOSAVE: Set of individual tiles covered by catchment area.
void RecomputeCatchment(bool no_clear_nearby_lists=false)
Recompute tiles covered in our catchment area.
Definition station.cpp:447
uint GetCatchmentRadius() const
Determines the catchment radius of the station.
Definition station.cpp:346
void AfterStationTileSetChange(bool adding, StationType type)
After adding/removing tiles to station, update some station-related stuff.
Airport airport
Tile area the airport covers.
void UpdateVirtCoord() override
Update the virtual coords needed to draw the station sign.
TileArea truck_station
Tile area the truck 'station' part covers.
void AddIndustryToDeliver(Industry *ind, TileIndex tile)
Add nearby industry to station's industries_near list if it accepts cargo.
Definition station.cpp:371
void RemoveIndustryToDeliver(Industry *ind)
Remove nearby industry from station's industries_near list.
Definition station.cpp:397
RoadStop * truck_stops
All the truck stops.
void AddFacility(StationFacility new_facility_bit, TileIndex facil_xy)
Called when new facility is built on the station.
Definition station.cpp:233
A pair-construct of a TileIndexDiff.
Definition map_type.h:31
int16_t x
The x value of the coordinate.
Definition map_type.h:32
int16_t y
The y value of the coordinate.
Definition map_type.h:33
static bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Definition tile_map.h:150
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
Definition tile_type.h:92
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition tile_type.h:100
@ Station
A tile of a station or airport.
Definition tile_type.h:54
Classes for storing and iterating a tile area.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
VehicleType
Available vehicle types.
@ Invalid
Non-existing type of vehicle.