OpenTTD Source 20260621-master-g720d10536d
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 "newgrf_airport.h"
17#include "cargopacket.h"
18#include "industry_type.h"
20#include "newgrf_storage.h"
21#include "bitmap_type.h"
22
23static const uint8_t INITIAL_STATION_RATING = 175;
24static const uint8_t MAX_STATION_RATING = 255;
25
33class FlowStat {
34public:
35 typedef std::map<uint32_t, StationID> SharesMap;
36
37 static const SharesMap empty_sharesmap;
38
44 inline FlowStat() {NOT_REACHED();}
45
52 inline FlowStat(StationID st, uint flow, bool restricted = false)
53 {
54 assert(flow > 0);
55 this->shares[flow] = st;
56 this->unrestricted = restricted ? 0 : flow;
57 }
58
67 inline void AppendShare(StationID st, uint flow, bool restricted = false)
68 {
69 assert(flow > 0);
70 this->shares[(--this->shares.end())->first + flow] = st;
71 if (!restricted) this->unrestricted += flow;
72 }
73
74 uint GetShare(StationID st) const;
75
76 void ChangeShare(StationID st, int flow);
77
78 void RestrictShare(StationID st);
79
80 void ReleaseShare(StationID st);
81
82 void ScaleToMonthly(uint runtime);
83
89 inline const SharesMap *GetShares() const { return &this->shares; }
90
95 inline uint GetUnrestricted() const { return this->unrestricted; }
96
102 inline void SwapShares(FlowStat &other)
103 {
104 this->shares.swap(other.shares);
105 std::swap(this->unrestricted, other.unrestricted);
106 }
107
116 inline StationID GetViaWithRestricted(bool &is_restricted) const
117 {
118 assert(!this->shares.empty());
119 uint rand = RandomRange((--this->shares.end())->first);
120 is_restricted = rand >= this->unrestricted;
121 return this->shares.upper_bound(rand)->second;
122 }
123
131 inline StationID GetVia() const
132 {
133 assert(!this->shares.empty());
134 return this->unrestricted > 0 ?
135 this->shares.upper_bound(RandomRange(this->unrestricted))->second :
136 StationID::Invalid();
137 }
138
139 StationID GetVia(StationID excluded, StationID excluded2 = StationID::Invalid()) const;
140
141 void Invalidate();
142
143private:
144 SharesMap shares{};
145 uint unrestricted = 0;
146};
147
149class FlowStatMap : public std::map<StationID, FlowStat> {
150public:
151 uint GetFlow() const;
152 uint GetFlowVia(StationID via) const;
153 uint GetFlowFrom(StationID from) const;
154 uint GetFlowFromVia(StationID from, StationID via) const;
155
156 void AddFlow(StationID origin, StationID via, uint amount);
157 void PassOnFlow(StationID origin, StationID via, uint amount);
158 std::vector<StationID> DeleteFlows(StationID via);
159 void RestrictFlows(StationID via);
160 void ReleaseFlows(StationID via);
161 void FinalizeLocalConsumption(StationID self);
162};
163
169 enum class State : uint8_t {
175
185
191
197
203
209 };
210
213
217
218 bool IsEmpty() const
219 {
220 return this->cargo.TotalCount() == 0 && this->flows.empty();
221 }
222 };
223
225 NodeID node = INVALID_NODE;
226 LinkGraphID link_graph = LinkGraphID::Invalid();
227
229
235 uint8_t time_since_pickup = 255;
236
237 uint8_t rating = INITIAL_STATION_RATING;
238
248 uint8_t last_speed = 0;
249
254 uint8_t last_age = 255;
255
256 uint8_t amount_fract = 0;
257
263 bool HasVehicleEverTriedLoading() const { return this->last_speed != 0; }
264
269 inline bool HasRating() const
270 {
271 return this->status.Test(GoodsEntry::State::Rating);
272 }
273
279 inline StationID GetVia(StationID source) const
280 {
281 if (!this->HasData()) return StationID::Invalid();
282
283 FlowStatMap::const_iterator flow_it(this->GetData().flows.find(source));
284 return flow_it != this->GetData().flows.end() ? flow_it->second.GetVia() : StationID::Invalid();
285 }
286
295 inline StationID GetVia(StationID source, StationID excluded, StationID excluded2 = StationID::Invalid()) const
296 {
297 if (!this->HasData()) return StationID::Invalid();
298
299 FlowStatMap::const_iterator flow_it(this->GetData().flows.find(source));
300 return flow_it != this->GetData().flows.end() ? flow_it->second.GetVia(excluded, excluded2) : StationID::Invalid();
301 }
302
307 [[debug_inline]] inline bool HasData() const { return this->data != nullptr; }
308
312 void ClearData() { this->data.reset(); }
313
319 [[debug_inline]] inline const GoodsEntryData &GetData() const
320 {
321 assert(this->HasData());
322 return *this->data;
323 }
324
331 {
332 assert(this->HasData());
333 return *this->data;
334 }
335
341 {
342 if (!this->HasData()) this->data = std::make_unique<GoodsEntryData>();
343 return *this->data;
344 }
345
346 uint8_t ConvertState() const;
347
353 inline uint AvailableCount() const
354 {
355 return this->HasData() ? this->GetData().cargo.AvailableCount() : 0;
356 }
357
363 inline uint TotalCount() const
364 {
365 return this->HasData() ? this->GetData().cargo.TotalCount() : 0;
366 }
367
368private:
369 std::unique_ptr<GoodsEntryData> data = nullptr;
370};
371
373struct Airport : public TileArea {
374 Airport() : TileArea(INVALID_TILE, 0, 0) {}
375
377 uint8_t type = 0;
378 uint8_t layout = 0;
380
382
388 const AirportSpec *GetSpec() const
389 {
390 if (this->tile == INVALID_TILE) return &AirportSpec::dummy;
391 return AirportSpec::Get(this->type);
392 }
393
400 const AirportFTAClass *GetFTA() const
401 {
402 return this->GetSpec()->fsm;
403 }
404
409 inline bool HasHangar() const
410 {
411 return !this->GetSpec()->depots.empty();
412 }
413
423 {
424 const AirportSpec *as = this->GetSpec();
425 switch (this->rotation) {
426 case Direction::N: return this->tile + ToTileIndexDiff(tidc);
427
428 case Direction::E: return this->tile + TileDiffXY(tidc.y, as->size_x - 1 - tidc.x);
429
430 case Direction::S: return this->tile + TileDiffXY(as->size_x - 1 - tidc.x, as->size_y - 1 - tidc.y);
431
432 case Direction::W: return this->tile + TileDiffXY(as->size_y - 1 - tidc.y, tidc.x);
433
434 default: NOT_REACHED();
435 }
436 }
437
444 inline TileIndex GetHangarTile(uint hangar_num) const
445 {
446 for (const auto &depot : this->GetSpec()->depots) {
447 if (depot.hangar_num == hangar_num) {
448 return this->GetRotatedTileFromOffset(depot.ti);
449 }
450 }
451 NOT_REACHED();
452 }
453
461 {
462 const AirportSpec *as = this->GetSpec();
464 return ChangeDir(htt->dir, DirDifference(this->rotation, as->layouts[0].rotation));
465 }
466
473 inline uint GetHangarNum(TileIndex tile) const
474 {
476 return htt->hangar_num;
477 }
478
483 inline uint GetNumHangars() const
484 {
485 uint num = 0;
486 uint counted = 0;
487 for (const auto &depot : this->GetSpec()->depots) {
488 if (!HasBit(counted, depot.hangar_num)) {
489 num++;
490 SetBit(counted, depot.hangar_num);
491 }
492 }
493 return num;
494 }
495
496private:
504 {
505 for (const auto &depot : this->GetSpec()->depots) {
506 if (this->GetRotatedTileFromOffset(depot.ti) == tile) {
507 return &depot;
508 }
509 }
510 NOT_REACHED();
511 }
512};
513
515 uint distance = 0;
516 Industry *industry = nullptr;
517
518 bool operator== (const IndustryListEntry &other) const { return this->distance == other.distance && this->industry == other.industry; };
519};
520
522 bool operator() (const IndustryListEntry &lhs, const IndustryListEntry &rhs) const;
523};
524
525typedef std::set<IndustryListEntry, IndustryCompare> IndustryList;
526struct RoadVehicle;
527
529struct Station final : SpecializedStation<Station, false> {
530public:
531 RoadStop *GetPrimaryRoadStop(RoadStopType type) const
532 {
533 return type == RoadStopType::Bus ? bus_stops : truck_stops;
534 }
535
536 RoadStop *GetPrimaryRoadStop(const RoadVehicle *v) const;
537
538 RoadStop *bus_stops = nullptr;
542
546
547 IndustryType indtype = IT_INVALID;
548
550
551 StationVehicleTypes had_vehicle_of_type{};
552
553 uint8_t time_since_load = 0;
554 uint8_t time_since_unload = 0;
555
556 VehicleType last_vehicle_type = VehicleType::Invalid;
557 std::list<Vehicle *> loading_vehicles{};
558 std::array<GoodsEntry, NUM_CARGO> goods;
560
561 IndustryList industries_near{};
562 Industry *industry = nullptr;
563
564 Station(StationID index, TileIndex tile = INVALID_TILE);
565 ~Station() override;
566
567 void AddFacility(StationFacility new_facility_bit, TileIndex facil_xy);
568
569 void MarkTilesDirty(bool cargo_change) const;
570
571 void UpdateVirtCoord() override;
572
573 void MoveSign(TileIndex new_xy) override;
574
575 void AfterStationTileSetChange(bool adding, StationType type);
576
577 uint GetPlatformLength(TileIndex tile, DiagDirection dir) const override;
578 uint GetPlatformLength(TileIndex tile) const override;
579 void RecomputeCatchment(bool no_clear_nearby_lists = false);
580 static void RecomputeCatchmentForAll();
581
582 uint GetCatchmentRadius() const;
583 Rect GetCatchmentRect() const;
584 bool CatchmentCoversTown(TownID t) const;
585 void AddIndustryToDeliver(Industry *ind, TileIndex tile);
588
589 inline bool TileIsInCatchment(TileIndex tile) const
590 {
591 return this->catchment_tiles.HasTile(tile);
592 }
593
594 inline bool TileBelongsToRailStation(TileIndex tile) const override
595 {
596 return IsRailStationTile(tile) && GetStationIndex(tile) == this->index;
597 }
598
599 inline bool TileBelongsToRoadStop(TileIndex tile) const
600 {
601 return IsStationRoadStopTile(tile) && GetStationIndex(tile) == this->index;
602 }
603
604 inline bool TileBelongsToAirport(TileIndex tile) const
605 {
606 return IsAirportTile(tile) && GetStationIndex(tile) == this->index;
607 }
608
609 uint32_t GetNewGRFVariable(const ResolverObject &object, uint8_t variable, uint8_t parameter, bool &available) const override;
610
611 TileArea GetTileArea(StationType type) const override;
612};
613
616private:
617 const Station *st = nullptr;
618
619public:
625 {
626 if (!st->TileBelongsToAirport(this->tile)) ++(*this);
627 }
628
629 inline TileIterator& operator ++() override
630 {
632 while (this->tile != INVALID_TILE && !st->TileBelongsToAirport(this->tile)) {
634 }
635 return *this;
636 }
637
638 std::unique_ptr<TileIterator> Clone() const override
639 {
640 return std::make_unique<AirportTileIterator>(*this);
641 }
642};
643
644void RebuildStationKdtree();
645
653template <typename Func>
654void ForAllStationsAroundTiles(const TileArea &ta, Func func)
655{
656 /* There are no stations, so we will never find anything. */
657 if (Station::GetNumItems() == 0) return;
658
659 /* Not using, or don't have a nearby stations list, so we need to scan. */
660 FlatSet<StationID> seen_stations;
661
662 /* Scan an area around the building covering the maximum possible station
663 * to find the possible nearby stations. */
664 uint max_c = _settings_game.station.modified_catchment ? MAX_CATCHMENT : CA_UNMODIFIED;
665 TileArea ta_ext = TileArea(ta).Expand(max_c);
666 for (TileIndex tile : ta_ext) {
667 if (!IsTileType(tile, TileType::Station)) continue;
668 seen_stations.insert(GetStationIndex(tile));
669 }
670
671 for (StationID stationid : seen_stations) {
672 Station *st = Station::GetIfValid(stationid);
673 if (st == nullptr) continue; /* Waypoint */
674
675 /* Check if station is attached to an industry */
676 if (!_settings_game.station.serve_neutral_industries && st->industry != nullptr) continue;
677
678 /* Test if the tile is within the station's catchment */
679 for (TileIndex tile : ta) {
680 if (st->TileIsInCatchment(tile)) {
681 if (func(st, tile)) break;
682 }
683 }
684 }
685}
686
687#endif /* STATION_BASE_H */
EnumBitSet< AirportBlock, uint64_t > AirportBlocks
Bitset of AirportBlock elements.
Definition airport.h:135
Base classes/functions for base stations.
Bitmap functions.
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:113
Base class for cargo packets.
std::unique_ptr< TileIterator > Clone() const override
Allocate a new iterator that is a copy of this one.
TileIterator & operator++() override
Move ourselves to the next tile in the rectangle on the map.
const Station * st
The station the airport is a part of.
AirportTileIterator(const Station *st)
Construct the iterator.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Represents a tile area containing containing individually set tiles.
Definition bitmap_type.h:18
bool HasTile(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.
OrthogonalTileIterator(const OrthogonalTileArea &ta)
Construct the iterator.
TileIterator & operator++() override
Move ourselves to the next tile in the rectangle on the map.
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.
TileIterator(TileIndex tile=INVALID_TILE)
Initialise the iterator starting at this tile.
TileIndex tile
The current tile we are at.
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 related to the industry.
Declaration of link graph types used for cargo distribution.
#define Rect
Macro that prevents name conflicts between included headers.
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:28
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:222
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.
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.
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.
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.
uint8_t rating
Station rating for this cargo.
bool HasData() const
Test if this goods entry has optional cargo packet/flow data.
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
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.
Definition tilearea.cpp:123
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:455
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...
Rect GetCatchmentRect() const
Determines catchment rectangle of this station.
Definition station.cpp:369
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:537
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:430
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.
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:469
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:392
void RemoveIndustryToDeliver(Industry *ind)
Remove nearby industry from station's industries_near list.
Definition station.cpp:418
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
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
VehicleType
Available vehicle types.
@ Invalid
Non-existing type of vehicle.