10#ifndef BASE_STATION_BASE_H
11#define BASE_STATION_BASE_H
31 uint8_t random_bits = 0;
32 uint8_t animation_frame = 0;
37 enum StationRectMode : uint8_t {
71 std::vector<SpecMapping<StationSpec>>
speclist{};
118 inline const std::string &GetCachedName()
const
120 if (!this->
name.empty())
return this->
name;
121 if (this->cached_name.empty()) this->FillCachedName();
177 inline uint8_t GetRoadStopRandomBits(
TileIndex tile)
const
180 if (tile_data.tile == tile)
return tile_data.random_bits;
185 inline uint8_t GetRoadStopAnimationFrame(
TileIndex tile)
const
188 if (tile_data.tile == tile)
return tile_data.animation_frame;
194 bool SetRoadStopTileData(
TileIndex tile, uint8_t data,
bool animation);
198 inline bool SetRoadStopAnimationFrame(
TileIndex tile, uint8_t frame) {
return this->SetRoadStopTileData(tile, frame,
true); }
199 void RemoveRoadStopTileData(
TileIndex tile);
204 void FillCachedName()
const;
211template <
class T,
bool Tis_waypo
int>
292 return (
const T *)st;
310template <>
inline std::vector<SpecMapping<StationSpec>> &GetStationSpecList<StationSpec>(
BaseStation *bst) {
return bst->
speclist; }
311template <>
inline std::vector<SpecMapping<RoadStopSpec>> &GetStationSpecList<RoadStopSpec>(
BaseStation *bst) {
return bst->
roadstop_speclist; }
std::vector< SpecMapping< T > > & GetStationSpecList(BaseStation *bst)
Get spec mapping list for each supported custom spec type.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr bool Any(const Timpl &other) const
Test if any of the given values are set.
Common return value for all commands.
Types related to commands.
static constexpr Owner INVALID_OWNER
An invalid owner.
DiagDirection
Enumeration for diagonal directions.
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
Maps accessors for stations.
StationID GetStationIndex(Tile t)
Get StationID from a tile.
@ Dock
Station with a dock.
@ Waypoint
Station is a waypoint.
@ TruckStop
Station with truck stops.
@ Train
Station with train station.
@ Airport
Station with an airport.
@ BusStop
Station with bus stops.
StationType
Station types.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Base class for all station-ish types.
virtual uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint8_t variable, uint8_t parameter, bool &available) const =0
Helper function to get a NewGRF variable that isn't implemented by the base class.
std::vector< SpecMapping< RoadStopSpec > > roadstop_speclist
List of road stop specs of this station.
virtual uint GetPlatformLength(TileIndex tile) const =0
Obtain the length of a platform.
StringID string_id
Default name (town area) of station.
TileIndex xy
Base tile of the station.
std::vector< SpecMapping< StationSpec > > speclist
List of rail station specs of this station.
StationFacilities facilities
The facilities that this station has.
uint8_t cached_anim_triggers
NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen.
std::string cached_name
NOSAVE: Cache of the resolved name of the station, if not using a custom name.
TileArea train_station
Tile area the train 'station' part covers.
virtual uint GetPlatformLength(TileIndex tile, DiagDirection dir) const =0
Determines the REMAINING length of a platform, starting at (and including) the given tile.
uint8_t cached_roadstop_anim_triggers
NOSAVE: Combined animation trigger bitmask for road stops, used to determine if trigger processing sh...
Owner owner
The owner of this station.
virtual void GetTileArea(TileArea *ta, StationType type) const =0
Get the tile area for a given station type.
virtual void UpdateVirtCoord()=0
Update the coordinated of the sign (as shown in the viewport).
uint8_t delete_ctr
Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is ...
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
static void PostDestructor(size_t index)
Invalidating of the JoinStation window has to be done after removing item from the pool.
bool IsInUse() const
Check whether the base station currently is in use; in use means that it is not scheduled for deletio...
BaseStation(TileIndex tile)
Initialize the base station.
Town * town
The town this station is associated with.
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
virtual bool TileBelongsToRailStation(TileIndex tile) const =0
Check whether a specific tile belongs to this station.
CargoTypes cached_roadstop_cargo_triggers
NOSAVE: Combined cargo trigger bitmask for road stops.
uint16_t random_bits
Random bits assigned to this station.
TrackedViewportSign sign
NOSAVE: Dimensions of sign.
std::vector< RoadStopTileData > custom_roadstop_tile_data
List of custom road stop tile data.
uint8_t waiting_triggers
Waiting triggers (NewGRF) for this station.
TimerGameCalendar::Date build_date
Date of construction.
std::string name
Custom name.
CargoTypes cached_cargo_triggers
NOSAVE: Combined cargo trigger bitmask.
Represents the covered area of e.g.
Base class for all PoolItems.
static Titem * Get(auto index)
Returns Titem with given index.
Tindex index
Index of this pool item.
static bool IsValidID(auto index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Base class for all pools.
Specification of a rectangle with absolute coordinates of all edges.
Interface for SpriteGroup-s to access the gamestate.
const T * spec
Custom spec.
uint32_t grfid
GRF ID of this custom spec.
uint16_t localidx
Local ID within GRF of this custom spec.
Class defining several overloaded accessors so we don't have to cast base stations that often.
static bool IsValidID(auto index)
Tests whether given index is a valid index for station of this type.
static const T * From(const BaseStation *st)
Converts a const BaseStation to const SpecializedStation with type checking.
static bool IsExpected(const BaseStation *st)
Helper for checking whether the given station is of this type.
static T * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
static Pool::IterateWrapper< T > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
SpecializedStation(TileIndex tile)
Set station type correctly.
static T * Get(auto index)
Gets station with given index.
static T * GetIfValid(auto index)
Returns station if the index is a valid index for this station type.
static constexpr StationFacilities EXPECTED_FACIL
Specialized type.
static T * From(BaseStation *st)
Converts a BaseStation to SpecializedStation with type checking.
StationRect - used to track station spread out rectangle - cheaper than scanning whole map.
static bool ScanForStationTiles(StationID st_id, int left_a, int top_a, int right_a, int bottom_a)
Check whether station tiles of the given station id exist in the given rectangle.
bool PtInExtendedRect(int x, int y, int distance=0) const
Determines whether a given point (x, y) is within a certain distance of the station rectangle.
Specialised ViewportSign that tracks whether it is valid for entering into a Kdtree.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition of the game-calendar-timer.
Types related to viewports.