OpenTTD Source  12.0-beta2
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"
19 #include "newgrf_storage.h"
20 #include "bitmap_type.h"
21 #include <map>
22 #include <set>
23 
24 static const byte INITIAL_STATION_RATING = 175;
25 
33 class FlowStat {
34 public:
35  typedef std::map<uint32, 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  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  INVALID_STATION;
137  }
138 
139  StationID GetVia(StationID excluded, StationID excluded2 = INVALID_STATION) const;
140 
141  void Invalidate();
142 
143 private:
144  SharesMap shares;
146 };
147 
149 class FlowStatMap : public std::map<StationID, FlowStat> {
150 public:
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  StationIDStack DeleteFlows(StationID via);
159  void RestrictFlows(StationID via);
160  void ReleaseFlows(StationID via);
161  void FinalizeLocalConsumption(StationID self);
162 };
163 
167 struct GoodsEntry {
175 
185 
191 
197 
203 
209  };
210 
211  GoodsEntry() :
212  status(0),
213  time_since_pickup(255),
214  rating(INITIAL_STATION_RATING),
215  last_speed(0),
216  last_age(255),
217  amount_fract(0),
218  link_graph(INVALID_LINK_GRAPH),
219  node(INVALID_NODE),
221  {}
222 
223  byte status;
224 
231 
232  byte rating;
233 
244 
249  byte last_age;
250 
253 
254  LinkGraphID link_graph;
255  NodeID node;
258 
264  bool HasVehicleEverTriedLoading() const { return this->last_speed != 0; }
265 
270  inline bool HasRating() const
271  {
272  return HasBit(this->status, GES_RATING);
273  }
274 
280  inline StationID GetVia(StationID source) const
281  {
282  FlowStatMap::const_iterator flow_it(this->flows.find(source));
283  return flow_it != this->flows.end() ? flow_it->second.GetVia() : INVALID_STATION;
284  }
285 
294  inline StationID GetVia(StationID source, StationID excluded, StationID excluded2 = INVALID_STATION) const
295  {
296  FlowStatMap::const_iterator flow_it(this->flows.find(source));
297  return flow_it != this->flows.end() ? flow_it->second.GetVia(excluded, excluded2) : INVALID_STATION;
298  }
299 };
300 
302 struct Airport : public TileArea {
303  Airport() : TileArea(INVALID_TILE, 0, 0) {}
304 
305  uint64 flags;
306  byte type;
307  byte layout;
309 
311 
317  const AirportSpec *GetSpec() const
318  {
319  if (this->tile == INVALID_TILE) return &AirportSpec::dummy;
320  return AirportSpec::Get(this->type);
321  }
322 
329  const AirportFTAClass *GetFTA() const
330  {
331  return this->GetSpec()->fsm;
332  }
333 
335  inline bool HasHangar() const
336  {
337  return this->GetSpec()->nof_depots > 0;
338  }
339 
349  {
350  const AirportSpec *as = this->GetSpec();
351  switch (this->rotation) {
352  case DIR_N: return this->tile + ToTileIndexDiff(tidc);
353 
354  case DIR_E: return this->tile + TileDiffXY(tidc.y, as->size_x - 1 - tidc.x);
355 
356  case DIR_S: return this->tile + TileDiffXY(as->size_x - 1 - tidc.x, as->size_y - 1 - tidc.y);
357 
358  case DIR_W: return this->tile + TileDiffXY(as->size_y - 1 - tidc.y, tidc.x);
359 
360  default: NOT_REACHED();
361  }
362  }
363 
370  inline TileIndex GetHangarTile(uint hangar_num) const
371  {
372  const AirportSpec *as = this->GetSpec();
373  for (uint i = 0; i < as->nof_depots; i++) {
374  if (as->depot_table[i].hangar_num == hangar_num) {
375  return this->GetRotatedTileFromOffset(as->depot_table[i].ti);
376  }
377  }
378  NOT_REACHED();
379  }
380 
388  {
389  const AirportSpec *as = this->GetSpec();
391  return ChangeDir(htt->dir, DirDifference(this->rotation, as->rotation[0]));
392  }
393 
400  inline uint GetHangarNum(TileIndex tile) const
401  {
403  return htt->hangar_num;
404  }
405 
407  inline uint GetNumHangars() const
408  {
409  uint num = 0;
410  uint counted = 0;
411  const AirportSpec *as = this->GetSpec();
412  for (uint i = 0; i < as->nof_depots; i++) {
413  if (!HasBit(counted, as->depot_table[i].hangar_num)) {
414  num++;
415  SetBit(counted, as->depot_table[i].hangar_num);
416  }
417  }
418  return num;
419  }
420 
421 private:
429  {
430  const AirportSpec *as = this->GetSpec();
431  for (uint i = 0; i < as->nof_depots; i++) {
432  if (this->GetRotatedTileFromOffset(as->depot_table[i].ti) == tile) {
433  return as->depot_table + i;
434  }
435  }
436  NOT_REACHED();
437  }
438 };
439 
441  bool operator() (const Industry *lhs, const Industry *rhs) const;
442 };
443 
444 typedef std::set<Industry *, IndustryCompare> IndustryList;
445 
447 struct Station FINAL : SpecializedStation<Station, false> {
448 public:
449  RoadStop *GetPrimaryRoadStop(RoadStopType type) const
450  {
451  return type == ROADSTOP_BUS ? bus_stops : truck_stops;
452  }
453 
454  RoadStop *GetPrimaryRoadStop(const struct RoadVehicle *v) const;
455 
460 
464 
465  IndustryType indtype;
466 
468 
469  StationHadVehicleOfType had_vehicle_of_type;
470 
471  byte time_since_load;
472  byte time_since_unload;
473 
474  byte last_vehicle_type;
475  std::list<Vehicle *> loading_vehicles;
477  CargoTypes always_accepted;
478 
479  IndustryList industries_near;
481 
483  ~Station();
484 
485  void AddFacility(StationFacility new_facility_bit, TileIndex facil_xy);
486 
487  void MarkTilesDirty(bool cargo_change) const;
488 
489  void UpdateVirtCoord() override;
490 
491  void MoveSign(TileIndex new_xy) override;
492 
493  void AfterStationTileSetChange(bool adding, StationType type);
494 
495  uint GetPlatformLength(TileIndex tile, DiagDirection dir) const override;
496  uint GetPlatformLength(TileIndex tile) const override;
497  void RecomputeCatchment();
498  static void RecomputeCatchmentForAll();
499 
500  uint GetCatchmentRadius() const;
501  Rect GetCatchmentRect() const;
502  bool CatchmentCoversTown(TownID t) const;
503  void AddIndustryToDeliver(Industry *ind);
505 
506  inline bool TileIsInCatchment(TileIndex tile) const
507  {
508  return this->catchment_tiles.HasTile(tile);
509  }
510 
511  inline bool TileBelongsToRailStation(TileIndex tile) const override
512  {
513  return IsRailStationTile(tile) && GetStationIndex(tile) == this->index;
514  }
515 
516  inline bool TileBelongsToAirport(TileIndex tile) const
517  {
518  return IsAirportTile(tile) && GetStationIndex(tile) == this->index;
519  }
520 
521  uint32 GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const override;
522 
523  void GetTileArea(TileArea *ta, StationType type) const override;
524 };
525 
528 private:
529  const Station *st;
530 
531 public:
537  {
538  if (!st->TileBelongsToAirport(this->tile)) ++(*this);
539  }
540 
542  {
543  (*this).OrthogonalTileIterator::operator++();
544  while (this->tile != INVALID_TILE && !st->TileBelongsToAirport(this->tile)) {
545  (*this).OrthogonalTileIterator::operator++();
546  }
547  return *this;
548  }
549 
550  virtual TileIterator *Clone() const
551  {
552  return new AirportTileIterator(*this);
553  }
554 };
555 
556 void RebuildStationKdtree();
557 
565 template<typename Func>
566 void ForAllStationsAroundTiles(const TileArea &ta, Func func)
567 {
568  /* Not using, or don't have a nearby stations list, so we need to scan. */
569  std::set<StationID> seen_stations;
570 
571  /* Scan an area around the building covering the maximum possible station
572  * to find the possible nearby stations. */
574  TileArea ta_ext = TileArea(ta).Expand(max_c);
575  for (TileIndex tile : ta_ext) {
576  if (IsTileType(tile, MP_STATION)) seen_stations.insert(GetStationIndex(tile));
577  }
578 
579  for (StationID stationid : seen_stations) {
580  Station *st = Station::GetIfValid(stationid);
581  if (st == nullptr) continue; /* Waypoint */
582 
583  /* Check if station is attached to an industry */
584  if (!_settings_game.station.serve_neutral_industries && st->industry != nullptr) continue;
585 
586  /* Test if the tile is within the station's catchment */
587  for (TileIndex tile : ta) {
588  if (st->TileIsInCatchment(tile)) {
589  if (func(st, tile)) break;
590  }
591  }
592  }
593 }
594 
595 #endif /* STATION_BASE_H */
RoadVehicle
Buses, trucks and trams belong to this class.
Definition: roadveh.h:107
CA_UNMODIFIED
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition: station_type.h:82
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:83
FlowStat::ScaleToMonthly
void ScaleToMonthly(uint runtime)
Scale all shares from link graph's runtime to monthly values.
Definition: station_cmd.cpp:4582
TileIterator::tile
TileIndex tile
The current tile we are at.
Definition: tilearea_type.h:107
Station::docking_station
TileArea docking_station
Tile area the docking tiles cover.
Definition: station_base.h:463
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:4445
Airport::GetHangarExitDirection
Direction GetHangarExitDirection(TileIndex tile) const
Get the exit direction of the hangar at a specific tile.
Definition: station_base.h:387
SmallStack
Minimal stack that uses a pool to avoid pointers.
Definition: smallstack_type.hpp:136
Station::goods
GoodsEntry goods[NUM_CARGO]
Goods at this station.
Definition: station_base.h:476
FlowStat::unrestricted
uint unrestricted
Limit for unrestricted shares.
Definition: station_base.h:145
Direction
Direction
Defines the 8 directions on the map.
Definition: direction_type.h:24
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:348
FlowStatMap::GetFlowVia
uint GetFlowVia(StationID via) const
Get the sum of flows via a specific station from this FlowStatMap.
Definition: station_cmd.cpp:4719
Airport::GetHangarNum
uint GetHangarNum(TileIndex tile) const
Get the hangar number of the hangar at a specific tile.
Definition: station_base.h:400
GameSettings::station
StationSettings station
settings related to station management
Definition: settings_type.h:587
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:266
Station::AfterStationTileSetChange
void AfterStationTileSetChange(bool adding, StationType type)
After adding/removing tiles to station, update some station-related stuff.
Definition: station_cmd.cpp:741
FlowStatMap::GetFlow
uint GetFlow() const
Get the sum of all flows from this FlowStatMap.
Definition: station_cmd.cpp:4705
ChangeDir
static Direction ChangeDir(Direction d, DirDiff delta)
Change a direction by a given difference.
Definition: direction_func.h:104
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:4545
AirportSpec::size_y
byte size_y
size of airport in y direction
Definition: newgrf_airport.h:106
Station
Station data structure.
Definition: station_base.h:447
Station::RecomputeCatchment
void RecomputeCatchment()
Recompute tiles covered in our catchment area.
Definition: station.cpp:406
SpecializedStation
Class defining several overloaded accessors so we don't have to cast base stations that often.
Definition: base_station_base.h:182
IsAirportTile
static bool IsAirportTile(TileIndex t)
Is this tile a station tile and an airport tile?
Definition: station_map.h:167
AirportTileIterator::Clone
virtual TileIterator * Clone() const
Allocate a new iterator that is a copy of this one.
Definition: station_base.h:550
AirportTileIterator::st
const Station * st
The station the airport is a part of.
Definition: station_base.h:529
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:102
Pool::PoolItem<&_station_pool >::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:235
Airport
All airport-related information.
Definition: station_base.h:302
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:4620
ResolverObject
Interface for SpriteGroup-s to access the gamestate.
Definition: newgrf_spritegroup.h:307
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
Station::MoveSign
void MoveSign(TileIndex new_xy) override
Move the station main coordinate somewhere else.
Definition: station_cmd.cpp:435
StationCargoList
CargoList that is used for stations.
Definition: cargopacket.h:449
Airport::layout
byte layout
Airport layout number.
Definition: station_base.h:307
AirportTileIterator::AirportTileIterator
AirportTileIterator(const Station *st)
Construct the iterator.
Definition: station_base.h:536
newgrf_airport.h
DirDifference
static DirDiff DirDifference(Direction d0, Direction d1)
Calculate the difference between two directions.
Definition: direction_func.h:68
AirportTileIterator::operator++
TileIterator & operator++()
Move ourselves to the next tile in the rectangle on the map.
Definition: station_base.h:541
RandomRange
static uint32 RandomRange(uint32 limit)
Pick a random number between 0 and limit - 1, inclusive.
Definition: random_func.hpp:81
DIR_W
@ DIR_W
West.
Definition: direction_type.h:32
Industry
Defines the internal data of a functional industry.
Definition: industry.h:66
Station::CatchmentCoversTown
bool CatchmentCoversTown(TownID t) const
Test if the given town ID is covered by our catchment area.
Definition: station.cpp:393
FlowStatMap::FinalizeLocalConsumption
void FinalizeLocalConsumption(StationID self)
Subtract invalid flows from locally consumed flow.
Definition: station_cmd.cpp:4638
DIR_N
@ DIR_N
North.
Definition: direction_type.h:26
AirportSpec
Defines the data structure for an airport.
Definition: newgrf_airport.h:98
FlowStat::GetShare
uint GetShare(StationID st) const
Get flow for a station.
Definition: station_cmd.cpp:4373
GoodsEntry::status
byte status
Status of this cargo, see GoodsEntryStatus.
Definition: station_base.h:223
GoodsEntry::amount_fract
byte amount_fract
Fractional part of the amount in the cargo list.
Definition: station_base.h:251
FlowStatMap::RestrictFlows
void RestrictFlows(StationID via)
Restrict all flows at a station for specific cargo and destination.
Definition: station_cmd.cpp:4683
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:329
ROADSTOP_BUS
@ ROADSTOP_BUS
A standard stop for buses.
Definition: station_type.h:45
FlowStatMap::GetFlowFrom
uint GetFlowFrom(StationID from) const
Get the sum of flows from a specific station from this FlowStatMap.
Definition: station_cmd.cpp:4733
FlowStat
Flow statistics telling how much flow should be sent along a link.
Definition: station_base.h:33
GoodsEntry::cargo
StationCargoList cargo
The cargo packets of cargo waiting in this station.
Definition: station_base.h:252
StationType
StationType
Station types.
Definition: station_type.h:32
ToTileIndexDiff
static TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between to tiles from a TileIndexDiffC struct.
Definition: map_func.h:230
Airport::HasHangar
bool HasHangar() const
Check if this airport has at least one hangar.
Definition: station_base.h:335
OrthogonalTileIterator
Iterator to iterate over a tile area (rectangle) of the map.
Definition: tilearea_type.h:153
MAX_CATCHMENT
@ MAX_CATCHMENT
Maximum catchment for airports with "modified catchment" enabled.
Definition: station_type.h:84
Airport::rotation
Direction rotation
How this airport is rotated.
Definition: station_base.h:308
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:294
TileIndexDiffC::y
int16 y
The y value of the coordinate.
Definition: map_type.h:59
FlowStatMap::DeleteFlows
StationIDStack DeleteFlows(StationID via)
Delete all flows at a station for specific cargo and destination.
Definition: station_cmd.cpp:4663
AirportSpec::rotation
const Direction * rotation
the rotation of each tiletable
Definition: newgrf_airport.h:101
StationSettings::serve_neutral_industries
bool serve_neutral_industries
company stations can serve industries with attached neutral stations
Definition: settings_type.h:548
GoodsEntry::GoodsEntryStatus
GoodsEntryStatus
Status of this cargo for the station.
Definition: station_base.h:169
FlowStatMap::ReleaseFlows
void ReleaseFlows(StationID via)
Release all flows at a station for specific cargo and destination.
Definition: station_cmd.cpp:4694
AirportSpec::Get
static const AirportSpec * Get(byte type)
Retrieve airport spec for the given airport.
Definition: newgrf_airport.cpp:97
AirportSpec::fsm
const struct AirportFTAClass * fsm
the finite statemachine for the default airports
Definition: newgrf_airport.h:99
GoodsEntry::GES_EVER_ACCEPTED
@ GES_EVER_ACCEPTED
Set when a vehicle ever delivered cargo to the station for final delivery.
Definition: station_base.h:190
BitmapTileArea
Represents a tile area containing containing individually set tiles.
Definition: bitmap_type.h:19
DIR_E
@ DIR_E
East.
Definition: direction_type.h:28
Station::RecomputeCatchmentForAll
static void RecomputeCatchmentForAll()
Recomputes catchment of all stations.
Definition: station.cpp:474
GoodsEntry::HasRating
bool HasRating() const
Does this cargo have a rating at this station?
Definition: station_base.h:270
TileIterator
Base class for tile iterators.
Definition: tilearea_type.h:105
Station::MarkTilesDirty
void MarkTilesDirty(bool cargo_change) const
Marks the tiles of the station as dirty.
Definition: station.cpp:217
GoodsEntry::last_speed
byte last_speed
Maximum speed (up to 255) of the last vehicle that tried to load this cargo.
Definition: station_base.h:243
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:208
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:89
GoodsEntry::GetVia
StationID GetVia(StationID source) const
Get the best next hop for a cargo packet from station source.
Definition: station_base.h:280
PersistentStorage
Class for pooled persistent storage of data.
Definition: newgrf_storage.h:221
Station::truck_station
TileArea truck_station
Tile area the truck 'station' part covers.
Definition: station_base.h:459
Airport::GetHangarDataByTile
const HangarTileTable * GetHangarDataByTile(TileIndex tile) const
Retrieve hangar information of a hangar at a given tile.
Definition: station_base.h:428
GoodsEntry::node
NodeID node
ID of node in link graph referring to this goods entry.
Definition: station_base.h:255
Airport::GetHangarTile
TileIndex GetHangarTile(uint hangar_num) const
Get the first tile of the given hangar.
Definition: station_base.h:370
Station::airport
Airport airport
Tile area the airport covers.
Definition: station_base.h:461
OrthogonalTileArea
Represents the covered area of e.g.
Definition: tilearea_type.h:18
Station::AddFacility
void AddFacility(StationFacility new_facility_bit, TileIndex facil_xy)
Called when new facility is built on the station.
Definition: station.cpp:201
Station::TileBelongsToRailStation
bool TileBelongsToRailStation(TileIndex tile) const override
Check whether a specific tile belongs to this station.
Definition: station_base.h:511
BitmapTileArea::HasTile
bool HasTile(TileIndex tile) const
Test if a tile is part of the tile area.
Definition: bitmap_type.h:100
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:53
Station::indtype
IndustryType indtype
Industry type to get the name from.
Definition: station_base.h:465
Station::~Station
~Station()
Clean up a station by clearing vehicle orders, invalidating windows and removing link stats.
Definition: station.cpp:86
Station::AddIndustryToDeliver
void AddIndustryToDeliver(Industry *ind)
Add nearby industry to station's industries_near list if it accepts cargo.
Definition: station.cpp:362
cargopacket.h
Airport::flags
uint64 flags
stores which blocks on the airport are taken. was 16 bit earlier on, then 32
Definition: station_base.h:305
DIR_S
@ DIR_S
South.
Definition: direction_type.h:30
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:4514
FlowStat::FlowStat
FlowStat(StationID st, uint flow, bool restricted=false)
Create a FlowStat with an initial entry.
Definition: station_base.h:52
Station::bus_station
TileArea bus_station
Tile area the bus 'station' part covers.
Definition: station_base.h:457
GoodsEntry::rating
byte rating
Station rating for this cargo.
Definition: station_base.h:232
AirportFTAClass
Finite sTate mAchine (FTA) of an airport.
Definition: airport.h:143
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:77
AirportSpec::dummy
static const AirportSpec dummy
The dummy airport.
Definition: newgrf_airport.h:135
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:67
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:477
IsRailStationTile
static bool IsRailStationTile(TileIndex t)
Is this tile a station tile and a rail station?
Definition: station_map.h:102
industry_type.h
GoodsEntry::link_graph
LinkGraphID link_graph
Link graph this station belongs to.
Definition: station_base.h:254
Station::truck_stops
RoadStop * truck_stops
All the truck stops.
Definition: station_base.h:458
Station::industry
Industry * industry
NOSAVE: Associated industry for neutral stations. (Rebuilt on load from Industry->st)
Definition: station_base.h:480
AirportTileIterator
Iterator to iterate over all tiles belonging to an airport.
Definition: station_base.h:527
HangarTileTable::dir
Direction dir
Direction of the exit.
Definition: newgrf_airport.h:91
IsTileType
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
Definition: tile_map.h:150
StationFacility
StationFacility
The facilities a station might be having.
Definition: station_type.h:50
FlowStatMap::AddFlow
void AddFlow(StationID origin, StationID via, uint amount)
Add some flow from "origin", going via "via".
Definition: station_cmd.cpp:4601
AirportSpec::size_x
byte size_x
size of airport in x direction
Definition: newgrf_airport.h:105
TileIndexDiffC
A pair-construct of a TileIndexDiff.
Definition: map_type.h:57
FlowStat::empty_sharesmap
static const SharesMap empty_sharesmap
Static instance of FlowStat::SharesMap.
Definition: station_base.h:37
GoodsEntry::GES_CURRENT_MONTH
@ GES_CURRENT_MONTH
Set when cargo was delivered for final delivery this month.
Definition: station_base.h:202
Station::industries_near
IndustryList industries_near
Cached list of industries near the station that can accept cargo,.
Definition: station_base.h:479
GoodsEntry
Stores station stats for a single cargo.
Definition: station_base.h:167
HangarTileTable::ti
TileIndexDiffC ti
Tile offset from the top-most airport tile.
Definition: newgrf_airport.h:90
GoodsEntry::last_age
byte last_age
Age in years (up to 255) of the last vehicle that tried to load this cargo.
Definition: station_base.h:249
FlowStat::GetViaWithRestricted
StationID GetViaWithRestricted(bool &is_restricted) const
Get a station a package can be routed to.
Definition: station_base.h:116
RoadStopType
RoadStopType
Types of RoadStops.
Definition: station_type.h:44
GoodsEntry::flows
FlowStatMap flows
Planned flows through this station.
Definition: station_base.h:256
Station::GetCatchmentRadius
uint GetCatchmentRadius() const
Determines the catchment radius of the station.
Definition: station.cpp:318
FlowStat::GetUnrestricted
uint GetUnrestricted() const
Return total amount of unrestricted shares.
Definition: station_base.h:95
OrthogonalTileArea::tile
TileIndex tile
The base tile of the area.
Definition: tilearea_type.h:19
FlowStatMap
Flow descriptions by origin stations.
Definition: station_base.h:149
Station::UpdateVirtCoord
void UpdateVirtCoord() override
Update the virtual coords needed to draw the station sign.
Definition: station_cmd.cpp:413
TileDiffXY
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
Definition: map_func.h:179
MP_STATION
@ MP_STATION
A tile of a station.
Definition: tile_type.h:51
NUM_CARGO
@ NUM_CARGO
Maximal number of cargo types in a game.
Definition: cargo_type.h:65
GoodsEntry::GES_ACCEPTANCE
@ GES_ACCEPTANCE
Set when the station accepts the cargo currently for final deliveries.
Definition: station_base.h:174
GetStationIndex
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
Definition: station_map.h:28
GoodsEntry::time_since_pickup
byte time_since_pickup
Number of rating-intervals (up to 255) since the last vehicle tried to load this cargo.
Definition: station_base.h:230
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:566
Station::GetCatchmentRect
Rect GetCatchmentRect() const
Determines catchment rectangle of this station.
Definition: station.cpp:341
FlowStat::GetVia
StationID GetVia() const
Get a station a package can be routed to.
Definition: station_base.h:131
base_station_base.h
Station::catchment_tiles
BitmapTileArea catchment_tiles
NOSAVE: Set of individual tiles covered by catchment area.
Definition: station_base.h:467
TileArea
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Definition: tilearea_type.h:102
Airport::GetNumHangars
uint GetNumHangars() const
Get the number of hangars on this airport.
Definition: station_base.h:407
linkgraph_type.h
IndustryCompare
Definition: station_base.h:440
SetBit
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Definition: bitmath_func.hpp:121
Station::RemoveFromAllNearbyLists
void RemoveFromAllNearbyLists()
Remove this station from the nearby stations lists of all towns and industries.
Definition: station.cpp:380
random_func.hpp
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:228
AirportSpec::depot_table
const HangarTileTable * depot_table
gives the position of the depots on the airports
Definition: newgrf_airport.h:103
Airport::type
byte type
Type of this airport,.
Definition: station_base.h:306
HangarTileTable::hangar_num
byte hangar_num
The hangar to which this tile belongs.
Definition: newgrf_airport.h:92
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:88
GoodsEntry::max_waiting_cargo
uint max_waiting_cargo
Max cargo from this station waiting at any station.
Definition: station_base.h:257
OrthogonalTileArea::Expand
OrthogonalTileArea & Expand(int rad)
Expand a tile area by rad tiles in each direction, keeping within map bounds.
Definition: tilearea.cpp:123
Station::bus_stops
RoadStop * bus_stops
All the road stops.
Definition: station_base.h:456
FlowStat::shares
SharesMap shares
Shares of flow to be sent via specified station (or consumed locally).
Definition: station_base.h:144
AirportSpec::nof_depots
byte nof_depots
the number of hangar tiles in this airport
Definition: newgrf_airport.h:104
StationHadVehicleOfType
StationHadVehicleOfType
The vehicles that may have visited a station.
Definition: station_type.h:62
RoadStop
A Stop for a Road Vehicle.
Definition: roadstop_base.h:22
Swap
static void Swap(T &a, T &b)
Type safe swap operation.
Definition: math_func.hpp:215
Airport::psa
PersistentStorage * psa
Persistent storage for NewGRF airports.
Definition: station_base.h:310
Airport::GetSpec
const AirportSpec * GetSpec() const
Get the AirportSpec that from the airport type of this airport.
Definition: station_base.h:317
HangarTileTable
A list of all hangar tiles in an airport.
Definition: newgrf_airport.h:89
Station::GetTileArea
void GetTileArea(TileArea *ta, StationType type) const override
Get the tile area for a given station type.
Definition: station_cmd.cpp:382
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
newgrf_storage.h
GoodsEntry::GES_RATING
@ GES_RATING
This indicates whether a cargo has a rating at the station.
Definition: station_base.h:184
GoodsEntry::HasVehicleEverTriedLoading
bool HasVehicleEverTriedLoading() const
Reports whether a vehicle has ever tried to load the cargo at this station.
Definition: station_base.h:264
Station::ship_station
TileArea ship_station
Tile area the ship 'station' part covers.
Definition: station_base.h:462
FlowStat::ChangeShare
void ChangeShare(StationID st, int flow)
Change share for specified station.
Definition: station_cmd.cpp:4464
FlowStat::FlowStat
FlowStat()
Invalid constructor.
Definition: station_base.h:44
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:4746
GoodsEntry::GES_LAST_MONTH
@ GES_LAST_MONTH
Set when cargo was delivered for final delivery last month.
Definition: station_base.h:196
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition: settings_type.h:547
TileIndexDiffC::x
int16 x
The x value of the coordinate.
Definition: map_type.h:58