OpenTTD Source: src/station_base.h Source File

OpenTTD Source 15.0-beta1

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 <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef STATION_BASE_H
11#define STATION_BASE_H
12
13#include "core/random_func.hpp"
14#include "base_station_base.h"
15#include "newgrf_airport.h"
16#include "cargopacket.h"
17#include "industry_type.h"
18#include "linkgraph/linkgraph_type.h"
19#include "newgrf_storage.h"
20#include "bitmap_type.h"
21
22static const uint8_t INITIAL_STATION_RATING = 175;
23static const uint8_t MAX_STATION_RATING = 255;
24
32 class FlowStat {
33public:
34 typedef std::map<uint32_t, StationID> SharesMap;
35
36 static const SharesMap empty_sharesmap;
37
43 inline FlowStat() {NOT_REACHED();}
44
51 inline FlowStat(StationID st, uint flow, bool restricted = false)
52 {
53 assert(flow > 0);
54 this->shares[flow] = st;
55 this->unrestricted = restricted ? 0 : flow;
56 }
57
66 inline void AppendShare(StationID st, uint flow, bool restricted = false)
67 {
68 assert(flow > 0);
69 this->shares[(--this->shares.end())->first + flow] = st;
70 if (!restricted) this->unrestricted += flow;
71 }
72
73 uint GetShare(StationID st) const;
74
75 void ChangeShare(StationID st, int flow);
76
77 void RestrictShare(StationID st);
78
79 void ReleaseShare(StationID st);
80
81 void ScaleToMonthly(uint runtime);
82
88 inline const SharesMap *GetShares() const { return &this->shares; }
89
94 inline uint GetUnrestricted() const { return this->unrestricted; }
95
101 inline void SwapShares(FlowStat &other)
102 {
103 this->shares.swap(other.shares);
104 Swap(this->unrestricted, other.unrestricted);
105 }
106
115 inline StationID GetViaWithRestricted(bool &is_restricted) const
116 {
117 assert(!this->shares.empty());
118 uint rand = RandomRange((--this->shares.end())->first);
119 is_restricted = rand >= this->unrestricted;
120 return this->shares.upper_bound(rand)->second;
121 }
122
130 inline StationID GetVia() const
131 {
132 assert(!this->shares.empty());
133 return this->unrestricted > 0 ?
134 this->shares.upper_bound(RandomRange(this->unrestricted))->second :
135 INVALID_STATION;
136 }
137
138 StationID GetVia(StationID excluded, StationID excluded2 = INVALID_STATION) const;
139
140 void Invalidate();
141
142private:
143 SharesMap shares;
144 uint unrestricted;
145};
146
148 class FlowStatMap : public std::map<StationID, FlowStat> {
149public:
150 uint GetFlow() const;
151 uint GetFlowVia(StationID via) const;
152 uint GetFlowFrom(StationID from) const;
153 uint GetFlowFromVia(StationID from, StationID via) const;
154
155 void AddFlow(StationID origin, StationID via, uint amount);
156 void PassOnFlow(StationID origin, StationID via, uint amount);
157 StationIDStack DeleteFlows(StationID via);
158 void RestrictFlows(StationID via);
159 void ReleaseFlows(StationID via);
160 void FinalizeLocalConsumption(StationID self);
161};
162
166 struct GoodsEntry {
168 enum GoodsEntryStatus {
173 GES_ACCEPTANCE,
174
183 GES_RATING,
184
189 GES_EVER_ACCEPTED,
190
195 GES_LAST_MONTH,
196
201 GES_CURRENT_MONTH,
202
207 GES_ACCEPTED_BIGTICK,
208 };
209
210 StationCargoList cargo{};
211 FlowStatMap flows{};
212
213 uint max_waiting_cargo = 0;
214 NodeID node = INVALID_NODE;
215 LinkGraphID link_graph = INVALID_LINK_GRAPH;
216
217 uint8_t status = 0;
218
224 uint8_t time_since_pickup = 255;
225
226 uint8_t rating = INITIAL_STATION_RATING;
227
237 uint8_t last_speed = 0;
238
243 uint8_t last_age = 255;
244
245 uint8_t amount_fract = 0;
246
252 bool HasVehicleEverTriedLoading() const { return this->last_speed != 0; }
253
258 inline bool HasRating() const
259 {
260 return HasBit(this->status, GES_RATING);
261 }
262
268 inline StationID GetVia(StationID source) const
269 {
270 FlowStatMap::const_iterator flow_it(this->flows.find(source));
271 return flow_it != this->flows.end() ? flow_it->second.GetVia() : INVALID_STATION;
272 }
273
282 inline StationID GetVia(StationID source, StationID excluded, StationID excluded2 = INVALID_STATION) const
283 {
284 FlowStatMap::const_iterator flow_it(this->flows.find(source));
285 return flow_it != this->flows.end() ? flow_it->second.GetVia(excluded, excluded2) : INVALID_STATION;
286 }
287};
288
290 struct Airport : public TileArea {
291 Airport() : TileArea(INVALID_TILE, 0, 0) {}
292
293 uint64_t flags;
294 uint8_t type;
295 uint8_t layout;
296 Direction rotation;
297
298 PersistentStorage *psa;
299
305 const AirportSpec *GetSpec() const
306 {
307 if (this->tile == INVALID_TILE) return &AirportSpec::dummy;
308 return AirportSpec::Get(this->type);
309 }
310
317 const AirportFTAClass *GetFTA() const
318 {
319 return this->GetSpec()->fsm;
320 }
321
323 inline bool HasHangar() const
324 {
325 return !this->GetSpec()->depots.empty();
326 }
327
336 inline TileIndex GetRotatedTileFromOffset(TileIndexDiffC tidc) const
337 {
338 const AirportSpec *as = this->GetSpec();
339 switch (this->rotation) {
340 case DIR_N: return this->tile + ToTileIndexDiff(tidc);
341
342 case DIR_E: return this->tile + TileDiffXY(tidc.y, as->size_x - 1 - tidc.x);
343
344 case DIR_S: return this->tile + TileDiffXY(as->size_x - 1 - tidc.x, as->size_y - 1 - tidc.y);
345
346 case DIR_W: return this->tile + TileDiffXY(as->size_y - 1 - tidc.y, tidc.x);
347
348 default: NOT_REACHED();
349 }
350 }
351
358 inline TileIndex GetHangarTile(uint hangar_num) const
359 {
360 for (const auto &depot : this->GetSpec()->depots) {
361 if (depot.hangar_num == hangar_num) {
362 return this->GetRotatedTileFromOffset(depot.ti);
363 }
364 }
365 NOT_REACHED();
366 }
367
374 inline Direction GetHangarExitDirection(TileIndex tile) const
375 {
376 const AirportSpec *as = this->GetSpec();
377 const HangarTileTable *htt = GetHangarDataByTile(tile);
378 return ChangeDir(htt->dir, DirDifference(this->rotation, as->layouts[0].rotation));
379 }
380
387 inline uint GetHangarNum(TileIndex tile) const
388 {
389 const HangarTileTable *htt = GetHangarDataByTile(tile);
390 return htt->hangar_num;
391 }
392
394 inline uint GetNumHangars() const
395 {
396 uint num = 0;
397 uint counted = 0;
398 for (const auto &depot : this->GetSpec()->depots) {
399 if (!HasBit(counted, depot.hangar_num)) {
400 num++;
401 SetBit(counted, depot.hangar_num);
402 }
403 }
404 return num;
405 }
406
407private:
414 inline const HangarTileTable *GetHangarDataByTile(TileIndex tile) const
415 {
416 for (const auto &depot : this->GetSpec()->depots) {
417 if (this->GetRotatedTileFromOffset(depot.ti) == tile) {
418 return &depot;
419 }
420 }
421 NOT_REACHED();
422 }
423};
424
425 struct IndustryListEntry {
426 uint distance;
427 Industry *industry;
428
429 bool operator== (const IndustryListEntry &other) const { return this->distance == other.distance && this->industry == other.industry; };
430};
431
432 struct IndustryCompare {
433 bool operator() (const IndustryListEntry &lhs, const IndustryListEntry &rhs) const;
434};
435
436typedef std::set<IndustryListEntry, IndustryCompare> IndustryList;
437
439 struct Station final : SpecializedStation<Station, false> {
440public:
441 RoadStop *GetPrimaryRoadStop(RoadStopType type) const
442 {
443 return type == ROADSTOP_BUS ? bus_stops : truck_stops;
444 }
445
446 RoadStop *GetPrimaryRoadStop(const struct RoadVehicle *v) const;
447
448 RoadStop *bus_stops;
449 TileArea bus_station;
450 RoadStop *truck_stops;
451 TileArea truck_station;
452
453 Airport airport;
454 TileArea ship_station;
455 TileArea docking_station;
456
457 IndustryType indtype;
458
459 BitmapTileArea catchment_tiles;
460
461 StationHadVehicleOfType had_vehicle_of_type;
462
463 uint8_t time_since_load;
464 uint8_t time_since_unload;
465
466 uint8_t last_vehicle_type;
467 std::list<Vehicle *> loading_vehicles;
468 GoodsEntry goods[NUM_CARGO];
469 CargoTypes always_accepted;
470
471 IndustryList industries_near;
472 Industry *industry;
473
474 Station(TileIndex tile = INVALID_TILE);
475 ~Station();
476
477 void AddFacility(StationFacility new_facility_bit, TileIndex facil_xy);
478
479 void MarkTilesDirty(bool cargo_change) const;
480
481 void UpdateVirtCoord() override;
482
483 void MoveSign(TileIndex new_xy) override;
484
485 void AfterStationTileSetChange(bool adding, StationType type);
486
487 uint GetPlatformLength(TileIndex tile, DiagDirection dir) const override;
488 uint GetPlatformLength(TileIndex tile) const override;
489 void RecomputeCatchment(bool no_clear_nearby_lists = false);
490 static void RecomputeCatchmentForAll();
491
492 uint GetCatchmentRadius() const;
493 Rect GetCatchmentRect() const;
494 bool CatchmentCoversTown(TownID t) const;
495 void AddIndustryToDeliver(Industry *ind, TileIndex tile);
496 void RemoveIndustryToDeliver(Industry *ind);
497 void RemoveFromAllNearbyLists();
498
499 inline bool TileIsInCatchment(TileIndex tile) const
500 {
501 return this->catchment_tiles.HasTile(tile);
502 }
503
504 inline bool TileBelongsToRailStation(TileIndex tile) const override
505 {
506 return IsRailStationTile(tile) && GetStationIndex(tile) == this->index;
507 }
508
509 inline bool TileBelongsToRoadStop(TileIndex tile) const
510 {
511 return IsStationRoadStopTile(tile) && GetStationIndex(tile) == this->index;
512 }
513
514 inline bool TileBelongsToAirport(TileIndex tile) const
515 {
516 return IsAirportTile(tile) && GetStationIndex(tile) == this->index;
517 }
518
519 uint32_t GetNewGRFVariable(const ResolverObject &object, uint8_t variable, uint8_t parameter, bool &available) const override;
520
521 void GetTileArea(TileArea *ta, StationType type) const override;
522};
523
525 class AirportTileIterator : public OrthogonalTileIterator {
526private:
527 const Station *st;
528
529public:
534 AirportTileIterator(const Station *st) : OrthogonalTileIterator(st->airport), st(st)
535 {
536 if (!st->TileBelongsToAirport(this->tile)) ++(*this);
537 }
538
539 inline TileIterator& operator ++() override
540 {
541 (*this).OrthogonalTileIterator::operator++();
542 while (this->tile != INVALID_TILE && !st->TileBelongsToAirport(this->tile)) {
543 (*this).OrthogonalTileIterator::operator++();
544 }
545 return *this;
546 }
547
548 std::unique_ptr<TileIterator> Clone() const override
549 {
550 return std::make_unique<AirportTileIterator>(*this);
551 }
552};
553
554void RebuildStationKdtree();
555
563template<typename Func>
564 void ForAllStationsAroundTiles(const TileArea &ta, Func func)
565{
566 /* There are no stations, so we will never find anything. */
567 if (Station::GetNumItems() == 0) return;
568
569 /* Not using, or don't have a nearby stations list, so we need to scan. */
570 std::set<StationID> seen_stations;
571
572 /* Scan an area around the building covering the maximum possible station
573 * to find the possible nearby stations. */
574 uint max_c = _settings_game.station.modified_catchment ? MAX_CATCHMENT : CA_UNMODIFIED;
575 TileArea ta_ext = TileArea(ta).Expand(max_c);
576 for (TileIndex tile : ta_ext) {
577 if (IsTileType(tile, MP_STATION)) seen_stations.insert(GetStationIndex(tile));
578 }
579
580 for (StationID stationid : seen_stations) {
581 Station *st = Station::GetIfValid(stationid);
582 if (st == nullptr) continue; /* Waypoint */
583
584 /* Check if station is attached to an industry */
585 if (!_settings_game.station.serve_neutral_industries && st->industry != nullptr) continue;
586
587 /* Test if the tile is within the station's catchment */
588 for (TileIndex tile : ta) {
589 if (st->TileIsInCatchment(tile)) {
590 if (func(st, tile)) break;
591 }
592 }
593 }
594}
595
596#endif /* STATION_BASE_H */
base_station_base.h
Base classes/functions for base stations.
HasBit
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition bitmath_func.hpp:103
SetBit
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
Definition bitmath_func.hpp:121
NUM_CARGO
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
Definition cargo_type.h:74
cargopacket.h
Base class for cargo packets.
AirportTileIterator
Iterator to iterate over all tiles belonging to an airport.
Definition station_base.h:525
AirportTileIterator::Clone
std::unique_ptr< TileIterator > Clone() const override
Allocate a new iterator that is a copy of this one.
Definition station_base.h:548
AirportTileIterator::operator++
TileIterator & operator++() override
Move ourselves to the next tile in the rectangle on the map.
Definition station_base.h:539
AirportTileIterator::st
const Station * st
The station the airport is a part of.
Definition station_base.h:527
AirportTileIterator::AirportTileIterator
AirportTileIterator(const Station *st)
Construct the iterator.
Definition station_base.h:534
BitmapTileArea
Represents a tile area containing containing individually set tiles.
Definition bitmap_type.h:18
BitmapTileArea::HasTile
bool HasTile(TileIndex tile) const
Test if a tile is part of the tile area.
Definition bitmap_type.h:99
FlowStatMap
Flow descriptions by origin stations.
Definition station_base.h:148
FlowStatMap::GetFlow
uint GetFlow() const
Get the sum of all flows from this FlowStatMap.
Definition station_cmd.cpp:5111
FlowStatMap::PassOnFlow
void PassOnFlow(StationID origin, StationID via, uint amount)
Pass on some flow, remembering it as invalid, for later subtraction from locally consumed flow.
Definition station_cmd.cpp:5026
FlowStatMap::AddFlow
void AddFlow(StationID origin, StationID via, uint amount)
Add some flow from "origin", going via "via".
Definition station_cmd.cpp:5007
FlowStatMap::GetFlowFrom
uint GetFlowFrom(StationID from) const
Get the sum of flows from a specific station from this FlowStatMap.
Definition station_cmd.cpp:5139
FlowStatMap::FinalizeLocalConsumption
void FinalizeLocalConsumption(StationID self)
Subtract invalid flows from locally consumed flow.
Definition station_cmd.cpp:5044
FlowStatMap::ReleaseFlows
void ReleaseFlows(StationID via)
Release all flows at a station for specific cargo and destination.
Definition station_cmd.cpp:5100
FlowStatMap::DeleteFlows
StationIDStack DeleteFlows(StationID via)
Delete all flows at a station for specific cargo and destination.
Definition station_cmd.cpp:5069
FlowStatMap::GetFlowFromVia
uint GetFlowFromVia(StationID from, StationID via) const
Get the flow from a specific station via a specific other station.
Definition station_cmd.cpp:5152
FlowStatMap::GetFlowVia
uint GetFlowVia(StationID via) const
Get the sum of flows via a specific station from this FlowStatMap.
Definition station_cmd.cpp:5125
FlowStatMap::RestrictFlows
void RestrictFlows(StationID via)
Restrict all flows at a station for specific cargo and destination.
Definition station_cmd.cpp:5089
FlowStat
Flow statistics telling how much flow should be sent along a link.
Definition station_base.h:32
FlowStat::empty_sharesmap
static const SharesMap empty_sharesmap
Static instance of FlowStat::SharesMap.
Definition station_base.h:36
FlowStat::ScaleToMonthly
void ScaleToMonthly(uint runtime)
Scale all shares from link graph's runtime to monthly values.
Definition station_cmd.cpp:4988
FlowStat::RestrictShare
void RestrictShare(StationID st)
Restrict a flow by moving it to the end of the map and decreasing the amount of unrestricted flow.
Definition station_cmd.cpp:4920
FlowStat::GetShare
uint GetShare(StationID st) const
Get flow for a station.
Definition station_cmd.cpp:4779
FlowStat::SwapShares
void SwapShares(FlowStat &other)
Swap the shares maps, and thus the content of this FlowStat with the other one.
Definition station_base.h:101
FlowStat::GetUnrestricted
uint GetUnrestricted() const
Return total amount of unrestricted shares.
Definition station_base.h:94
FlowStat::GetVia
StationID GetVia() const
Get a station a package can be routed to.
Definition station_base.h:130
FlowStat::GetViaWithRestricted
StationID GetViaWithRestricted(bool &is_restricted) const
Get a station a package can be routed to.
Definition station_base.h:115
FlowStat::GetShares
const SharesMap * GetShares() const
Get the actual shares as a const pointer so that they can be iterated over.
Definition station_base.h:88
FlowStat::shares
SharesMap shares
Shares of flow to be sent via specified station (or consumed locally).
Definition station_base.h:143
FlowStat::ReleaseShare
void ReleaseShare(StationID st)
Release ("unrestrict") a flow by moving it to the begin of the map and increasing the amount of unres...
Definition station_cmd.cpp:4951
FlowStat::ChangeShare
void ChangeShare(StationID st, int flow)
Change share for specified station.
Definition station_cmd.cpp:4870
FlowStat::AppendShare
void AppendShare(StationID st, uint flow, bool restricted=false)
Add some flow to the end of the shares map.
Definition station_base.h:66
FlowStat::FlowStat
FlowStat()
Invalid constructor.
Definition station_base.h:43
FlowStat::Invalidate
void Invalidate()
Reduce all flows to minimum capacity so that they don't get in the way of link usage statistics too m...
Definition station_cmd.cpp:4851
FlowStat::unrestricted
uint unrestricted
Limit for unrestricted shares.
Definition station_base.h:144
FlowStat::FlowStat
FlowStat(StationID st, uint flow, bool restricted=false)
Create a FlowStat with an initial entry.
Definition station_base.h:51
OrthogonalTileIterator
Iterator to iterate over a tile area (rectangle) of the map.
Definition tilearea_type.h:182
SmallStack
Minimal stack that uses a pool to avoid pointers.
Definition smallstack_type.hpp:135
StationCargoList
CargoList that is used for stations.
Definition cargopacket.h:529
TileIterator
Base class for tile iterators.
Definition tilearea_type.h:105
TileIterator::tile
TileIndex tile
The current tile we are at.
Definition tilearea_type.h:107
DirDifference
DirDiff DirDifference(Direction d0, Direction d1)
Calculate the difference between two directions.
Definition direction_func.h:68
ChangeDir
Direction ChangeDir(Direction d, DirDiff delta)
Change a direction by a given difference.
Definition direction_func.h:104
Direction
Direction
Defines the 8 directions on the map.
Definition direction_type.h:24
DIR_N
@ DIR_N
North.
Definition direction_type.h:26
DIR_S
@ DIR_S
South.
Definition direction_type.h:30
DIR_W
@ DIR_W
West.
Definition direction_type.h:32
DIR_E
@ DIR_E
East.
Definition direction_type.h:28
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition direction_type.h:73
Station::MarkTilesDirty
void MarkTilesDirty(bool cargo_change) const
Marks the tiles of the station as dirty.
Definition station.cpp:243
industry_type.h
Types related to the industry.
linkgraph_type.h
Declaration of link graph types used for cargo distribution.
ToTileIndexDiff
TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between two tiles from a TileIndexDiffC struct.
Definition map_func.h:440
TileDiffXY
TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
Definition map_func.h:389
Swap
constexpr void Swap(T &a, T &b)
Type safe swap operation.
Definition math_func.hpp:283
newgrf_airport.h
NewGRF handling of airports.
newgrf_storage.h
Functionality related to the temporary and persistent storage arrays for NewGRFs.
random_func.hpp
Pseudo random number generator.
RandomRange
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.
Definition random_func.hpp:88
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:57
ForAllStationsAroundTiles
void ForAllStationsAroundTiles(const TileArea &ta, Func func)
Call a function on all stations that have any part of the requested area within their catchment.
Definition station_base.h:564
IsStationRoadStopTile
bool IsStationRoadStopTile(Tile t)
Is tile t a road stop station?
Definition station_map.h:234
IsAirportTile
bool IsAirportTile(Tile t)
Is this tile a station tile and an airport tile?
Definition station_map.h:167
IsRailStationTile
bool IsRailStationTile(Tile t)
Is this tile a station tile and a rail station?
Definition station_map.h:102
GetStationIndex
StationID GetStationIndex(Tile t)
Get StationID from a tile.
Definition station_map.h:28
RoadStopType
RoadStopType
Types of RoadStops.
Definition station_type.h:45
ROADSTOP_BUS
@ ROADSTOP_BUS
A standard stop for buses.
Definition station_type.h:46
StationHadVehicleOfType
StationHadVehicleOfType
The vehicles that may have visited a station.
Definition station_type.h:64
StationFacility
StationFacility
The facilities a station might be having.
Definition station_type.h:52
StationType
StationType
Station types.
Definition station_type.h:31
MAX_CATCHMENT
static constexpr uint MAX_CATCHMENT
Maximum catchment for airports with "modified catchment" enabled.
Definition station_type.h:85
CA_UNMODIFIED
static constexpr uint CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition station_type.h:83
AirportFTAClass
Finite sTate mAchine (FTA) of an airport.
Definition airport.h:143
AirportSpec
Defines the data structure for an airport.
Definition newgrf_airport.h:105
AirportSpec::layouts
std::vector< AirportTileLayout > layouts
List of layouts composing the airport.
Definition newgrf_airport.h:107
AirportSpec::dummy
static const AirportSpec dummy
The dummy airport.
Definition newgrf_airport.h:138
AirportSpec::fsm
const struct AirportFTAClass * fsm
the finite statemachine for the default airports
Definition newgrf_airport.h:106
AirportSpec::size_y
uint8_t size_y
size of airport in y direction
Definition newgrf_airport.h:110
AirportSpec::size_x
uint8_t size_x
size of airport in x direction
Definition newgrf_airport.h:109
AirportSpec::Get
static const AirportSpec * Get(uint8_t type)
Retrieve airport spec for the given airport.
Definition newgrf_airport.cpp:55
AirportSpec::depots
std::span< const HangarTileTable > depots
Position of the depots on the airports.
Definition newgrf_airport.h:108
Airport
All airport-related information.
Definition station_base.h:290
Airport::GetRotatedTileFromOffset
TileIndex GetRotatedTileFromOffset(TileIndexDiffC tidc) const
Add the tileoffset to the base tile of this airport but rotate it first.
Definition station_base.h:336
Airport::HasHangar
bool HasHangar() const
Check if this airport has at least one hangar.
Definition station_base.h:323
Airport::GetHangarNum
uint GetHangarNum(TileIndex tile) const
Get the hangar number of the hangar at a specific tile.
Definition station_base.h:387
Airport::rotation
Direction rotation
How this airport is rotated.
Definition station_base.h:296
Airport::type
uint8_t type
Type of this airport,.
Definition station_base.h:294
Airport::GetHangarExitDirection
Direction GetHangarExitDirection(TileIndex tile) const
Get the exit direction of the hangar at a specific tile.
Definition station_base.h:374
Airport::psa
PersistentStorage * psa
Persistent storage for NewGRF airports.
Definition station_base.h:298
Airport::GetNumHangars
uint GetNumHangars() const
Get the number of hangars on this airport.
Definition station_base.h:394
Airport::flags
uint64_t flags
stores which blocks on the airport are taken. was 16 bit earlier on, then 32
Definition station_base.h:293
Airport::GetFTA
const AirportFTAClass * GetFTA() const
Get the finite-state machine for this airport or the finite-state machine for the dummy airport in ca...
Definition station_base.h:317
Airport::GetHangarTile
TileIndex GetHangarTile(uint hangar_num) const
Get the first tile of the given hangar.
Definition station_base.h:358
Airport::GetHangarDataByTile
const HangarTileTable * GetHangarDataByTile(TileIndex tile) const
Retrieve hangar information of a hangar at a given tile.
Definition station_base.h:414
Airport::GetSpec
const AirportSpec * GetSpec() const
Get the AirportSpec that from the airport type of this airport.
Definition station_base.h:305
Airport::layout
uint8_t layout
Airport layout number.
Definition station_base.h:295
GameSettings::station
StationSettings station
settings related to station management
Definition settings_type.h:604
GoodsEntry
Stores station stats for a single cargo.
Definition station_base.h:166
GoodsEntry::flows
FlowStatMap flows
Planned flows through this station.
Definition station_base.h:211
GoodsEntry::max_waiting_cargo
uint max_waiting_cargo
Max cargo from this station waiting at any station.
Definition station_base.h:213
GoodsEntry::HasRating
bool HasRating() const
Does this cargo have a rating at this station?
Definition station_base.h:258
GoodsEntry::GoodsEntryStatus
GoodsEntryStatus
Status of this cargo for the station.
Definition station_base.h:168
GoodsEntry::GES_ACCEPTANCE
@ GES_ACCEPTANCE
Set when the station accepts the cargo currently for final deliveries.
Definition station_base.h:173
GoodsEntry::GES_LAST_MONTH
@ GES_LAST_MONTH
Set when cargo was delivered for final delivery last month.
Definition station_base.h:195
GoodsEntry::GES_RATING
@ GES_RATING
This indicates whether a cargo has a rating at the station.
Definition station_base.h:183
GoodsEntry::GES_CURRENT_MONTH
@ GES_CURRENT_MONTH
Set when cargo was delivered for final delivery this month.
Definition station_base.h:201
GoodsEntry::GES_EVER_ACCEPTED
@ GES_EVER_ACCEPTED
Set when a vehicle ever delivered cargo to the station for final delivery.
Definition station_base.h:189
GoodsEntry::GES_ACCEPTED_BIGTICK
@ GES_ACCEPTED_BIGTICK
Set when cargo was delivered for final delivery during the current STATION_ACCEPTANCE_TICKS interval.
Definition station_base.h:207
GoodsEntry::last_speed
uint8_t last_speed
Maximum speed (up to 255) of the last vehicle that tried to load this cargo.
Definition station_base.h:237
GoodsEntry::last_age
uint8_t last_age
Age in years (up to 255) of the last vehicle that tried to load this cargo.
Definition station_base.h:243
GoodsEntry::time_since_pickup
uint8_t time_since_pickup
Number of rating-intervals (up to 255) since the last vehicle tried to load this cargo.
Definition station_base.h:224
GoodsEntry::node
NodeID node
ID of node in link graph referring to this goods entry.
Definition station_base.h:214
GoodsEntry::cargo
StationCargoList cargo
The cargo packets of cargo waiting in this station.
Definition station_base.h:210
GoodsEntry::amount_fract
uint8_t amount_fract
Fractional part of the amount in the cargo list.
Definition station_base.h:245
GoodsEntry::link_graph
LinkGraphID link_graph
Link graph this station belongs to.
Definition station_base.h:215
GoodsEntry::HasVehicleEverTriedLoading
bool HasVehicleEverTriedLoading() const
Reports whether a vehicle has ever tried to load the cargo at this station.
Definition station_base.h:252
GoodsEntry::GetVia
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...
Definition station_base.h:282
GoodsEntry::rating
uint8_t rating
Station rating for this cargo.
Definition station_base.h:226
GoodsEntry::status
uint8_t status
Status of this cargo, see GoodsEntryStatus.
Definition station_base.h:217
GoodsEntry::GetVia
StationID GetVia(StationID source) const
Get the best next hop for a cargo packet from station source.
Definition station_base.h:268
HangarTileTable
A list of all hangar tiles in an airport.
Definition newgrf_airport.h:91
HangarTileTable::dir
Direction dir
Direction of the exit.
Definition newgrf_airport.h:93
HangarTileTable::hangar_num
uint8_t hangar_num
The hangar to which this tile belongs.
Definition newgrf_airport.h:94
IndustryCompare
Definition station_base.h:432
IndustryListEntry
Definition station_base.h:425
Industry
Defines the internal data of a functional industry.
Definition industry.h:66
OrthogonalTileArea
Represents the covered area of e.g.
Definition tilearea_type.h:18
OrthogonalTileArea::tile
TileIndex tile
The base tile of the area.
Definition tilearea_type.h:19
OrthogonalTileArea::Expand
OrthogonalTileArea & Expand(int rad)
Expand a tile area by rad tiles in each direction, keeping within map bounds.
Definition tilearea.cpp:123
PersistentStorage
Class for pooled persistent storage of data.
Definition newgrf_storage.h:199
Pool::PoolItem<&_station_pool >::index
Tindex index
Index of this pool item.
Definition pool_type.hpp:238
Pool::PoolItem<&_station_pool >::GetNumItems
static size_t GetNumItems()
Returns number of valid items in the pool.
Definition pool_type.hpp:369
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition geometry_type.hpp:75
ResolverObject
Interface for SpriteGroup-s to access the gamestate.
Definition newgrf_spritegroup.h:296
RoadStop
A Stop for a Road Vehicle.
Definition roadstop_base.h:22
RoadVehicle
Buses, trucks and trams belong to this class.
Definition roadveh.h:98
SpecializedStation
Class defining several overloaded accessors so we don't have to cast base stations that often.
Definition base_station_base.h:217
SpecializedStation< Station, false >::GetIfValid
static Station * GetIfValid(size_t index)
Returns station if the index is a valid index for this station type.
Definition base_station_base.h:263
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition settings_type.h:565
StationSettings::serve_neutral_industries
bool serve_neutral_industries
company stations can serve industries with attached neutral stations
Definition settings_type.h:566
Station
Station data structure.
Definition station_base.h:439
Station::~Station
~Station()
Clean up a station by clearing vehicle orders, invalidating windows and removing link stats.
Definition station.cpp:83
Station::GetPlatformLength
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:285
Station::bus_stops
RoadStop * bus_stops
All the road stops.
Definition station_base.h:448
Station::CatchmentCoversTown
bool CatchmentCoversTown(TownID t) const
Test if the given town ID is covered by our catchment area.
Definition station.cpp:448
Station::ship_station
TileArea ship_station
Tile area the ship 'station' part covers.
Definition station_base.h:454
Station::indtype
IndustryType indtype
Industry type to get the name from.
Definition station_base.h:457
Station::industries_near
IndustryList industries_near
Cached list of industries near the station that can accept cargo,.
Definition station_base.h:471
Station::docking_station
TileArea docking_station
Tile area the docking tiles cover.
Definition station_base.h:455
Station::always_accepted
CargoTypes always_accepted
Bitmask of always accepted cargo types (by houses, HQs, industry tiles when industry doesn't accept c...
Definition station_base.h:469
Station::GetCatchmentRect
Rect GetCatchmentRect() const
Determines catchment rectangle of this station.
Definition station.cpp:362
Station::goods
GoodsEntry goods[NUM_CARGO]
Goods at this station.
Definition station_base.h:468
Station::GetTileArea
void GetTileArea(TileArea *ta, StationType type) const override
Get the tile area for a given station type.
Definition station_cmd.cpp:411
Station::industry
Industry * industry
NOSAVE: Associated industry for neutral stations. (Rebuilt on load from Industry->st)
Definition station_base.h:472
Station::MoveSign
void MoveSign(TileIndex new_xy) override
Move the station main coordinate somewhere else.
Definition station_cmd.cpp:464
Station::RecomputeCatchmentForAll
static void RecomputeCatchmentForAll()
Recomputes catchment of all stations.
Definition station.cpp:530
Station::RemoveFromAllNearbyLists
void RemoveFromAllNearbyLists()
Remove this station from the nearby stations lists of nearby towns and industries.
Definition station.cpp:423
Station::bus_station
TileArea bus_station
Tile area the bus 'station' part covers.
Definition station_base.h:449
Station::TileBelongsToRailStation
bool TileBelongsToRailStation(TileIndex tile) const override
Check whether a specific tile belongs to this station.
Definition station_base.h:504
Station::catchment_tiles
BitmapTileArea catchment_tiles
NOSAVE: Set of individual tiles covered by catchment area.
Definition station_base.h:459
Station::RecomputeCatchment
void RecomputeCatchment(bool no_clear_nearby_lists=false)
Recompute tiles covered in our catchment area.
Definition station.cpp:462
Station::GetCatchmentRadius
uint GetCatchmentRadius() const
Determines the catchment radius of the station.
Definition station.cpp:339
Station::AfterStationTileSetChange
void AfterStationTileSetChange(bool adding, StationType type)
After adding/removing tiles to station, update some station-related stuff.
Definition station_cmd.cpp:753
Station::airport
Airport airport
Tile area the airport covers.
Definition station_base.h:453
Station::UpdateVirtCoord
void UpdateVirtCoord() override
Update the virtual coords needed to draw the station sign.
Definition station_cmd.cpp:442
Station::truck_station
TileArea truck_station
Tile area the truck 'station' part covers.
Definition station_base.h:451
Station::AddIndustryToDeliver
void AddIndustryToDeliver(Industry *ind, TileIndex tile)
Add nearby industry to station's industries_near list if it accepts cargo.
Definition station.cpp:385
Station::RemoveIndustryToDeliver
void RemoveIndustryToDeliver(Industry *ind)
Remove nearby industry from station's industries_near list.
Definition station.cpp:411
Station::truck_stops
RoadStop * truck_stops
All the truck stops.
Definition station_base.h:450
Station::AddFacility
void AddFacility(StationFacility new_facility_bit, TileIndex facil_xy)
Called when new facility is built on the station.
Definition station.cpp:226
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
TileIndexDiffC
A pair-construct of a TileIndexDiff.
Definition map_type.h:31
TileIndexDiffC::x
int16_t x
The x value of the coordinate.
Definition map_type.h:32
TileIndexDiffC::y
int16_t y
The y value of the coordinate.
Definition map_type.h:33
IsTileType
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Definition tile_map.h:150
INVALID_TILE
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition tile_type.h:95
MP_STATION
@ MP_STATION
A tile of a station.
Definition tile_type.h:53
TileArea
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Definition tilearea_type.h:102