10 #ifndef NEWGRF_STATION_H
11 #define NEWGRF_STATION_H
47 uint32_t
GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter,
bool &available)
const override;
53 std::optional<TownScopeResolver>
town_scope = std::nullopt;
68 if (tsr !=
nullptr)
return tsr;
83 static const uint32_t STATION_CLASS_LABEL_DEFAULT =
'DFLT';
84 static const uint32_t STATION_CLASS_LABEL_WAYPOINT =
'WAYP';
120 animation({0, 0, 0, 0}) {}
174 std::unordered_map<uint16_t, std::vector<uint8_t>>
layouts;
191 return (length << 8U) | platforms;
205 uint32_t
GetPlatformInfo(
Axis axis, uint8_t tile,
int platforms,
int length,
int x,
int y,
bool centred);
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Types related to cargoes...
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
Common return value for all commands.
Struct containing information relating to NewGRF classes for stations and airports.
uint32_t global_id
Global ID for class, e.g. 'DFLT', 'WAYP', etc.
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Axis
Allow incrementing of DiagDirDiff variables.
@ INVALID_AXIS
Flag for an invalid Axis.
Type (helpers) for enums.
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definitions related to NewGRF animation.
StationAnimationTrigger
Animation triggers for station.
Callbacks that NewGRFs could implement.
CallbackID
List of implemented NewGRF callbacks.
@ CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
Header file for classes to be used by e.g.
This file simplyfies and embeds a common mechanism of loading/saving and mapping of grf entities.
@ VSG_SCOPE_SELF
Resolved object itself.
@ VSG_SCOPE_PARENT
Related object of the resolved one.
int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exec)
Allocate a StationSpec to a Station.
uint32_t GetPlatformInfo(Axis axis, uint8_t tile, int platforms, int length, int x, int y, bool centred)
Evaluate a tile's position within a station, and return the result in a bit-stuffed format.
SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32_t var10=0)
Resolve sprites for drawing a station tile.
StationSpecFlags
Allow incrementing of StationClassID variables.
@ SSF_SEPARATE_GROUND
Use different sprite set for ground sprites.
@ SSF_CB141_RANDOM_BITS
Callback 141 needs random bits.
@ SSF_CUSTOM_FOUNDATIONS
Draw custom foundations.
@ SSF_EXTENDED_FOUNDATIONS
Extended foundation block instead of simple.
@ SSF_DIV_BY_STATION_SIZE
Divide cargo amount by station size.
SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint layout, uint edge_info)
Resolve the sprites for custom station foundations.
uint16_t GetStationLayoutKey(uint8_t platforms, uint8_t length)
Get the station layout key for a given station layout size.
void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigger trigger, CargoID cargo_type=INVALID_CARGO)
Trigger station randomisation.
void StationUpdateCachedTriggers(BaseStation *st)
Update the cached animation trigger bitmask for a station.
bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station)
Draw representation of a station tile for GUI purposes.
void DeallocateSpecFromStation(BaseStation *st, uint8_t specindex)
Deallocate a StationSpec from a Station.
CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_tile, const StationSpec *statspec, Axis axis, uint8_t plat_len, uint8_t numtracks)
Check the slope of a tile of a new station.
StationRandomTrigger
Randomisation triggers for stations.
@ SRT_TRAIN_LOADS
Trigger platform when train loads/unloads.
@ SRT_TRAIN_ARRIVES
Trigger platform when train arrives.
@ SRT_CARGO_TAKEN
Trigger station when cargo is completely taken.
@ SRT_TRAIN_DEPARTS
Trigger platform when train leaves.
@ SRT_PATH_RESERVATION
Trigger platform when train reserves path.
@ SRT_NEW_CARGO
Trigger station on new cargo arrival.
bool IsWaypointClass(const StationClass &cls)
Test if a StationClass is the waypoint class.
@ STAT_CLASS_MAX
Maximum number of classes.
@ STAT_CLASS_BEGIN
the lowest valid value
@ STAT_CLASS_DFLT
Default station class.
@ STAT_CLASS_WAYP
Waypoint class.
Functions to handle the town part of NewGRF towns.
The different types of rail.
RailType
Enumeration for all possible railtypes.
Types related to stations.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Information about animation.
Base class for all station-ish types.
Interface for SpriteGroup-s to access the gamestate.
uint32_t callback_param2
Second parameter (var 18) of the callback.
CallbackID callback
Callback being resolved.
uint32_t callback_param1
First parameter (var 10) of the callback.
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, uint8_t relative=0)
Get a resolver for the scope.
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope).
ResolverObject & ro
Surrounding resolver object.
StationScopeResolver station_scope
The station scope resolver.
uint32_t GetDebugID() const override
Get an identifier for the item being resolved.
TownScopeResolver * GetTown()
Get the town scope associated with a station, if it exists.
std::optional< TownScopeResolver > town_scope
The town scope resolver (created on the first call).
StationResolverObject(const StationSpec *statspec, BaseStation *st, TileIndex tile, CallbackID callback=CBID_NO_CALLBACK, uint32_t callback_param1=0, uint32_t callback_param2=0)
Resolver for stations.
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, uint8_t relative=0) override
Get a resolver for the scope.
const SpriteGroup * ResolveReal(const RealSpriteGroup *group) const override
Get the real sprites of the grf.
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
Scope resolver for stations.
uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override
Get a variable value.
struct BaseStation * st
Instance of the station.
uint32_t GetTriggers() const override
Get the triggers.
uint32_t GetRandomBits() const override
Get a few random bits.
StationScopeResolver(ResolverObject &ro, const StationSpec *statspec, BaseStation *st, TileIndex tile)
Constructor for station scopes.
const struct StationSpec * statspec
Station (type) specification.
Axis axis
Station axis, used only for the slope check callback.
TileIndex tile
Tile of the station.
CargoID cargo_type
Type of cargo of the station.
uint8_t callback_mask
Bitmask of station callbacks that have to be called.
uint8_t disallowed_lengths
Bitmask of platform lengths available for the station.
StringID name
Name of this station.
uint8_t disallowed_platforms
Bitmask of number of platforms available for the station.
uint8_t flags
Bitmask of flags, bit 0: use different sprite set; bit 1: divide cargo about by station size.
uint16_t cargo_threshold
Cargo threshold for choosing between little and lots of cargo.
std::unordered_map< uint16_t, std::vector< uint8_t > > layouts
Custom platform layouts, keyed by platform and length combined.
@ NoWires
Tile should NOT contain catenary wires.
@ Pylons
Tile should contain catenary pylons.
@ Blocked
Tile is blocked to vehicles.
std::vector< TileFlags > tileflags
List of tile flags.
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
CargoTypes cargo_triggers
Bitmask of cargo types which cause trigger re-randomizing.
std::vector< NewGRFSpriteLayout > renderdata
Number of tile layouts.
Scope resolver for a town.