29#include "table/strings.h"
81 default: NOT_REACHED();
126 platform -= platforms / 2;
127 position -= length / 2;
128 platform =
Clamp(platform, -8, 7);
129 position =
Clamp(position, -8, 7);
130 SB(retval, 0, 4, position & 0xF);
131 SB(retval, 4, 4, platform & 0xF);
133 SB(retval, 0, 4, std::min(15, position));
134 SB(retval, 4, 4, std::min(15, length - position - 1));
135 SB(retval, 8, 4, std::min(15, platform));
136 SB(retval, 12, 4, std::min(15, platforms - platform - 1));
138 SB(retval, 16, 4, std::min(15, length));
139 SB(retval, 20, 4, std::min(15, platforms));
140 SB(retval, 24, 8, gfx);
156 uint8_t orig_type = 0;
177static uint32_t GetPlatformInfoHelper(
TileIndex tile,
bool check_type,
bool check_axis,
bool centred)
179 int tx =
TileX(tile);
180 int ty =
TileY(tile);
198static uint32_t GetRailContinuationInfo(
TileIndex tile)
217 for (i = 0; i <
lengthof(x_dir); i++, dir++, diagdir++) {
220 if (trackbits.
Any()) {
248 if (this->
st ==
nullptr)
return 0;
252 auto it = this->
st->tile_waiting_random_triggers.find(this->tile);
253 if (it != std::end(this->
st->tile_waiting_random_triggers)) triggers.
Set(it->second);
255 return triggers.
base();
273 if (t ==
nullptr)
return nullptr;
281 if (this->
st ==
nullptr) {
288 case 0x49:
return 0x2110000;
316 if (!this->cache.v40.has_value()) this->cache.v40 = GetPlatformInfoHelper(this->tile,
false,
false,
false);
317 return *this->cache.v40;
320 if (!this->cache.v41.has_value()) this->cache.v41 = GetPlatformInfoHelper(this->tile,
true,
false,
false);
321 return *this->cache.v41;
327 if (!this->cache.v45.has_value()) this->cache.v45 = GetRailContinuationInfo(this->tile);
328 return *this->cache.v45;
331 if (!this->cache.v46.has_value()) this->cache.v46 = GetPlatformInfoHelper(this->tile,
false,
false,
true);
332 return *this->cache.v46;
335 if (!this->cache.v47.has_value()) this->cache.v47 = GetPlatformInfoHelper(this->tile,
true,
false,
true);
336 return *this->cache.v47;
339 if (!this->cache.v49.has_value()) this->cache.v49 = GetPlatformInfoHelper(this->tile,
false,
true,
false);
340 return *this->cache.v49;
371 bool same_station = this->
st->TileBelongsToRailStation(nearby_tile);
372 uint32_t res =
GB(
GetStationGfx(nearby_tile), 1, 2) << 12 | !!perpendicular << 11 | !!same_station << 10;
400 if (sm.grfid == grfid) {
410 case 0x82:
return 50;
411 case 0x84:
return this->
st->string_id.base();
413 case 0xF0:
return this->
st->facilities.base();
417 return this->
st->GetNewGRFVariable(this->
ro, variable, parameter, available);
420uint32_t Station::GetNewGRFVariable(
const ResolverObject &
object, uint8_t variable, uint8_t parameter,
bool &available)
const
428 case 0x8A:
return this->had_vehicle_of_type.base();
432 case 0xF6:
return this->
airport.blocks.base();
433 case 0xF7:
return GB(this->
airport.blocks.base(), 8, 8);
437 if ((variable >= 0x60 && variable <= 0x65) || variable == 0x69) {
442 case 0x62:
return 0xFFFFFFFF;
443 case 0x64:
return 0xFF00;
447 const GoodsEntry *ge = &this->
goods[cargo];
450 case 0x60:
return std::min(ge->
TotalCount(), 4095u);
461 if (variable >= 0x8C && variable <= 0xEC) {
462 const GoodsEntry *g = &this->
goods[
GB(variable - 0x8C, 3, 4)];
463 switch (
GB(variable - 0x8C, 0, 3)) {
475 object.UnhandledVariable(variable);
494 if ((variable >= 0x60 && variable <= 0x65) || variable == 0x69) {
499 if (variable >= 0x8C && variable <= 0xEC) {
500 switch (
GB(variable - 0x8C, 0, 3)) {
501 case 3:
return INITIAL_STATION_RATING;
502 case 4:
return StationID::Invalid().base();
552 cargo = std::min(0xfffu, cargo);
556 uint set = ((cargo - this->
station_scope.statspec->cargo_threshold) *
static_cast<uint
>(group.
loading.size())) / (4096 - this->
station_scope.statspec->cargo_threshold);
560 if (!group.
loaded.empty()) {
561 uint set = (cargo *
static_cast<uint
>(group.
loaded.size())) / (this->
station_scope.statspec->cargo_threshold + 1);
598 ctype = CargoGRFFileProps::SG_PURCHASE;
600 const Station *st = Station::From(this->station_scope.st);
602 for (const auto &[cargo, spritegroup] : statspec->grf_prop.spritegroups) {
603 if (cargo < NUM_CARGO && st->goods[cargo].TotalCount() > 0) {
604 ctype = static_cast<CargoType>(cargo);
610 this->root_spritegroup = this->station_scope.statspec->grf_prop.GetSpriteGroup(ctype);
611 if (this->root_spritegroup ==
nullptr) {
613 this->root_spritegroup = this->station_scope.statspec->grf_prop.GetSpriteGroup(ctype);
617 this->station_scope.cargo_type = ctype;
634 if (group ==
nullptr)
return 0;
642 object.callback_param1 = var10;
669 uint32_t offset =
static_cast<uint32_t
>(
object.GetRegister(0x100));
670 if (group ==
nullptr || group->num_sprites <= offset)
return 0;
672 return group->sprite + offset;
679 return object.ResolveCallback(regs100);
700 object.station_scope.axis = axis;
702 std::array<int32_t, 16> regs100;
703 uint16_t cb_res =
object.ResolveCallback(regs100);
724 if (spec ==
nullptr)
return 0;
727 if (st ==
nullptr)
return 1;
730 if (st->
speclist[i].spec ==
nullptr && st->
speclist[i].grfid.Empty())
break;
740 if (st->
speclist[i].spec == spec)
return i;
757 if (specindex == 0)
return;
760 st->
speclist[specindex].spec = spec;
775 if (specindex == 0)
return;
785 st->
speclist[specindex].spec =
nullptr;
787 st->
speclist[specindex].localidx = 0;
790 if (specindex == st->
speclist.size() - 1) {
792 for (num_specs = st->
speclist.size() - 1; num_specs > 0; num_specs--) {
793 if (!st->
speclist[num_specs].grfid.Empty())
break;
827 if (statspec ==
nullptr)
return false;
835 uint32_t relocation = 0;
836 uint32_t ground_relocation = 0;
851 if (layout !=
nullptr) {
857 sprites = &tmp_rail_layout;
874 DrawSprite(ground + overlay_offset, PAL_NONE, x, y);
893 return specindex < st->
speclist.size() ? st->
speclist[specindex].spec :
nullptr;
908 return GetStationCallback(callback, param1, param2, statspec, st, tile);
923 if (ss ==
nullptr)
return;
943 assert(st !=
nullptr);
949 uint16_t random_bits = Random();
955 if (ss !=
nullptr && ss->animation.triggers.Test(trigger)) {
956 uint8_t var18_extra = 0;
980 assert(st !=
nullptr);
988 uint32_t whole_reseed = 0;
1004 st->tile_waiting_random_triggers[tile].Set(trigger);
1007 if (ss ==
nullptr)
continue;
1019 object.ResolveRerandomisation();
1021 st->tile_waiting_random_triggers[tile].Reset(
object.GetUsedRandomTriggers());
1022 used_random_triggers.
Set(
object.GetUsedRandomTriggers());
1024 uint32_t reseed =
object.GetReseedSum();
1026 whole_reseed |= reseed;
1031 random_bits &= ~reseed;
1032 random_bits |= Random() & reseed;
1043 if ((whole_reseed & 0xFFFF) != 0) {
1061 if (sm.spec ==
nullptr)
continue;
std::vector< SpecMapping< T > > & GetStationSpecList(BaseStation *bst)
Get spec mapping list for each supported custom spec type.
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
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.
constexpr T ToggleBit(T &x, const uint8_t y)
Toggles a bit in a variable.
static constexpr CargoType INVALID_CARGO
Invalid marker for cargoes.
bool IsValidCargoType(CargoType cargo)
Test whether cargo type is not INVALID_CARGO.
EnumBitSet< CargoType, uint64_t > CargoTypes
Bitset of CargoType elements.
CargoType
Cargo slots to indicate a cargo type within a game.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr Tstorage base() const noexcept
Retrieve the raw value behind this bit set.
constexpr bool None() const
Test if none of the values are set.
constexpr Timpl & Reset()
Reset all bits.
constexpr Timpl & Set()
Set all bits.
constexpr bool Any(const Timpl &other) const
Test if any of the given values are set.
uint PeriodsInTransit() const
Returns average number of cargo aging periods in transit for a cargo entity.
Common return value for all commands.
Struct containing information relating to NewGRF classes for stations and airports.
const Tspec * GetSpec(uint index) const
Get a spec from the class at a given index.
bool IsUIAvailable(uint index) const
static void InsertDefaults()
void Insert(Tspec *spec)
Insert a spec into the class, and update its index.
static NewGRFClass * Get(StationClassID class_index)
StringID name
Name of this class.
static StationClassID Allocate(GlobalID global_id)
uint16_t w
The width of the area.
uint16_t h
The height of the area.
This struct contains all the info that is needed to draw and construct tracks.
uint8_t fallback_railtype
Original railtype number to use when drawing non-newgrf railtypes, or when drawing stations.
uint GetRailtypeSpriteOffset() const
Offset between the current railtype and normal rail.
Add dynamic register values to a sprite layout.
DrawTileSpriteSpan GetLayout() const
Returns the result spritelayout after preprocessing.
void ProcessRegisters(const struct ResolverObject &object, uint8_t resolved_var10, uint32_t resolved_sprite)
Evaluates the register modifiers and integrates them into the preprocessed sprite layout.
SetBitIterator< uint8_t, uint32_t > Var10Values() const
Get values for variable 10 to resolve sprites for.
StationID GetFirstStation() const
Returns first station of the first cargo packet in this list.
static Date date
Current date in days (day counter).
static constexpr TimerGame< struct Calendar >::Date DAYS_TILL_ORIGINAL_BASE_YEAR
PaletteID GetCompanyPalette(CompanyID company)
Get the palette for recolouring with a company colour.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
CompanyID _current_company
Company currently doing an action.
Functions related to companies.
Functions related to debugging.
Direction
Defines the 8 directions on the map.
Axis
Enumeration for the two axis X and Y.
@ Invalid
Flag for an invalid Axis.
DiagDirection
Enumeration for diagonal directions.
@ NE
Northeast, upper right on your monitor.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23).
EnumClassIndexContainer< std::array< T, to_underlying(N)>, Index > EnumIndexArray
A typedef for EnumClassIndexContainer using std::array as the backing container type.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
uint32_t PaletteID
The number of the palette.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
static const SpriteID SPR_RAIL_PLATFORM_Y_FRONT
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, RoadTramType sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
TileIndexDiff TileOffsByAxis(Axis axis)
Convert an Axis to a TileIndexDiff.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
static uint TileX(TileIndex tile)
Get the X component of a tile.
constexpr TileIndex TileAdd(TileIndex tile, TileIndexDiff offset)
Adds a given offset to a tile.
TileIndexDiff TileOffsByDir(Direction dir)
Convert a Direction to a TileIndexDiff.
int32_t TileIndexDiff
An offset value between two tiles.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
constexpr To ClampTo(From value)
Clamp the given value down to lie within the requested type.
constexpr uint32_t FlattenNewGRFLabel(T label)
Flatten a NewGRF related label to a 32 bits integer.
@ Stations
Stations feature.
@ ATP_TTDP_LARGE
Same as AT_LARGE.
Function implementations related to NewGRF animation.
uint32_t GetBadgeVariableResult(const GRFFile &grffile, std::span< const BadgeID > badges, uint32_t parameter)
Test for a matching badge in a list of badges, returning the number of matching bits.
Functions related to NewGRF badges.
StationCallbackMask
Callback masks for stations.
@ DrawTileLayout
Use callback to select a tile layout to use when drawing.
@ AnimationNextFrame
Use a custom next frame callback.
@ AnimationSpeed
Customize the animation speed of the station.
CallbackID
List of implemented NewGRF callbacks.
@ CBID_STATION_ANIMATION_TRIGGER
Called for periodically starting or stopping the animation.
@ CBID_STATION_DRAW_TILE_LAYOUT
Choose a tile layout to draw, instead of the standard range.
@ CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
@ CBID_STATION_ANIMATION_NEXT_FRAME
Called to determine station tile next animation frame.
@ CBID_STATION_ANIMATION_SPEED
Called to indicate how long the current animation frame should last.
@ CBID_RANDOM_TRIGGER
Set when calling a randomizing trigger (almost undocumented).
@ CBID_STATION_LAND_SLOPE_CHECK
Callback done for each tile of a station to check the slope.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
CargoType GetCargoTranslation(uint8_t cargo, const GRFFile *grffile, bool usebit)
Translate a GRF-local cargo slot/bitnum into a CargoType.
Cargo support for NewGRFs.
Implementation of the NewGRF class' functions.
CommandCost GetErrorMessageFromLocationCallbackResult(uint16_t cb_res, std::span< const int32_t > textstack, const GRFFile *grffile, StringID default_error)
Get the error message from a shape/location/slope check callback result.
uint32_t GetCompanyInfo(CompanyID owner, const Livery *l)
Returns company information like in vehicle var 43 or station var 43.
uint32_t GetNearbyTileInformation(TileIndex tile, bool grf_version8)
Common part of station var 0x67, house var 0x62, indtile var 0x60, industry var 0x62,...
uint32_t GetTerrainType(TileIndex tile, TileContext context)
Function used by houses (and soon industries) to get information on type of "terrain" the tile it is ...
TileIndex GetNearbyTile(uint8_t parameter, TileIndex tile, bool signed_offsets, Axis axis)
Get the tile at the given offset.
uint8_t GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile)
Perform a reverse railtype lookup to get the GRF internal ID.
SpriteID GetCustomRailSprite(const RailTypeInfo *rti, TileIndex tile, RailSpriteType rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
NewGRF handling of rail types.
static TileIndex FindRailStationEnd(TileIndex tile, TileIndexDiff delta, bool check_type, bool check_axis)
Find the end of a railway station, from the tile, in the direction of delta.
SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32_t var10)
Resolve sprites for drawing a station tile.
static TileArea GetRailTileArea(const BaseStation *st, TileIndex tile, TriggerArea ta)
Get the tile area of a rail station with trigger area type.
SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint layout, uint edge_info)
Resolve the sprites for custom station foundations.
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 AssignSpecToStation(const StationSpec *spec, BaseStation *st, uint8_t specindex)
Assign a previously allocated StationSpec specindex to a Station.
void DeallocateSpecFromStation(BaseStation *st, uint8_t specindex)
Deallocate a StationSpec from a Station.
void TriggerStationRandomisation(BaseStation *st, TileIndex trigger_tile, StationRandomTrigger trigger, CargoType cargo_type)
Trigger station randomisation.
static const uint NUM_STATIONSSPECS_PER_STATION
Maximum number of parts per 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.
uint32_t GetPlatformInfo(StationGfx gfx, int platforms, int length, int platform, int position, bool centred)
Evaluate a tile's position within a station, and return the result in a bit-stuffed format.
uint16_t GetAnimStationCallback(CallbackID callback, uint32_t param1, uint32_t param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, int)
Perform the station callback in the context of the AnimationBase callback.
std::optional< uint8_t > AllocateSpecToStation(const StationSpec *spec, BaseStation *st)
Allocate a StationSpec to a Station.
Header file for NewGRF stations.
@ Cb141RandomBits
Callback 141 needs random bits.
@ DivByStationArea
Divide cargo amount by station area.
@ SeparateGround
Use different sprite set for ground sprites.
@ DivByStationSize
Divide cargo amount by station size (perimeter).
PoolID< uint16_t, struct StationClassIDTag, UINT16_MAX, UINT16_MAX > StationClassID
Class IDs for stations.
static const StationClass::GlobalID STATION_CLASS_LABEL_DEFAULT
Class label for default rail station.
static const StationClass::GlobalID STATION_CLASS_LABEL_WAYPOINT
Class label for default rail waypoints.
Functions to handle the town part of NewGRF towns.
Label< struct GrfIDTag > GrfID
The unique identifier of a NewGRF.
@ Ground
Main group of ground images.
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
RailTrackOffset
Offsets for sprites within an overlay/underlay set.
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
RailType
Enumeration for all possible railtypes.
Base class for roadstops.
A number of safeguards to prevent using unsafe methods.
Slope
Enumeration for the slope-type.
@ SLOPE_EW
east and west corner are raised
void DrawRailTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32_t total_offset, uint32_t newgrf_offset, PaletteID default_palette)
Draw tile sprite sequence in GUI with railroad specifics.
PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
static constexpr uint8_t SPRITE_MODIFIER_CUSTOM_SPRITE
these masks change the colours of the palette for a sprite.
Base classes/functions for stations.
const DrawTileSprites * GetStationTileLayout(StationType st, uint8_t gfx)
Get station tile layout for a station type and its station gfx.
CargoTypes GetAcceptanceMask(const Station *st)
Get a mask of the cargo types that the station accepts.
CargoTypes GetCargoWaitingMask(const Station *st)
Get a mask of the cargo types that have cargo waiting at the station.
bool SplitGroundSpriteForOverlay(const TileInfo *ti, SpriteID *ground, RailTrackOffset *overlay_offset)
Check whether a sprite is a track sprite, which can be replaced by a non-track ground sprite and a ra...
Functions related to stations.
StationGfx GetStationGfx(Tile t)
Get the station graphics of this tile.
bool IsCompatibleTrainStationTile(Tile test_tile, Tile station_tile)
Check if a tile is a valid continuation to a railstation tile.
uint8_t GetStationTileRandomBits(Tile t)
Get the random bits of a station tile.
bool IsRailStationTile(Tile t)
Is this tile a station tile and a rail station?
StationID GetStationIndex(Tile t)
Get StationID from a tile.
bool HasStationTileRail(Tile t)
Has this station tile a rail?
uint GetCustomStationSpecIndex(Tile t)
Get the custom station spec for this tile.
void SetStationTileRandomBits(Tile t, uint8_t random_bits)
Set the random bits for a station tile.
Axis GetRailStationAxis(Tile t)
Get the rail direction of a rail station.
uint8_t StationGfx
Index of station graphics.
bool IsCustomStationSpecIndex(Tile t)
Is there a custom rail station spec on this tile?
bool HasStationRail(Tile t)
Has this station tile a rail?
bool HasStationReservation(Tile t)
Get the reservation state of the rail station.
TriggerArea
Scope of station/roadstop animation or randomisation trigger.
@ Platform
Trigger a single platform.
@ Tile
Trigger an individual tile.
@ Whole
Trigger the entire station.
EnumBitSet< StationRandomTrigger, uint8_t > StationRandomTriggers
Bitset of StationRandomTrigger elements.
@ Rail
Railways/train station.
@ RailWaypoint
Waypoint for trains.
StationRandomTrigger
Randomisation triggers for stations and roadstops.
@ CargoTaken
Trigger station when cargo is completely taken.
StationAnimationTrigger
Animation triggers for stations and roadstops.
EnumBitSet< StationVehicleType, uint8_t > StationVehicleTypes
Bitset of StationVehicleType elements.
@ Waypoint
Station is a waypoint (Save load conversion and NewGRF only!).
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
Helper class for a unified approach to NewGRF animation.
static void ChangeAnimationFrame(CallbackID cb, const StationSpec *spec, BaseStation *obj, TileIndex tile, uint32_t random_bits, uint32_t trigger, int extra_data={})
static void AnimateTile(const StationSpec *spec, BaseStation *obj, TileIndex tile, bool random_animation, int extra_data={})
Base class for all station-ish types.
std::vector< SpecMapping< StationSpec > > speclist
List of rail station specs of this station.
virtual TileArea GetTileArea(StationType type) const =0
Get the tile area for a given station type.
TileArea train_station
Tile area the train 'station' part covers.
StationAnimationTriggers cached_anim_triggers
NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen.
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.
uint16_t random_bits
Random bits assigned to this station.
StationRandomTriggers waiting_random_triggers
Waiting triggers (NewGRF), shared by all station parts/tiles, road stops, ... essentially useless and...
CargoTypes cached_cargo_triggers
NOSAVE: Combined cargo trigger bitmask.
static constexpr CargoType SG_PURCHASE
Used in purchase lists before an item exists.
static constexpr CargoType SG_DEFAULT
Default type used when no more-specific cargo matches.
static constexpr CargoType SG_DEFAULT_NA
Used only by stations and roads when no more-specific cargo matches.
Ground palette sprite of a tile, together with its sprite layout.
Ground palette sprite of a tile, together with its sprite layout.
PalSpriteID ground
Palette and sprite for the ground.
GrfID grfid
grfid that introduced this entity.
const struct GRFFile * grffile
grf file that introduced this entity
uint16_t local_id
id defined by the grf file for this entity
std::array< uint8_t, NUM_CARGO > cargo_map
Inverse cargo translation table (CargoType -> local ID).
uint8_t grf_version
GRF version (See https://newgrf-specs.tt-wiki.net/wiki/Version_numbers#GRF_version).
StationCargoList cargo
The cargo packets of cargo waiting in this station.
Stores station stats for a single cargo.
bool HasRating() const
Does this cargo have a rating at this station?
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.
States status
Status of this cargo, see State.
@ 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.
@ 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.
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.
uint8_t ConvertState() const
Convert GoodsEntry status to the form required for NewGRF variables.
NewGRF supplied spritelayout.
bool NeedsPreprocessing() const
Tests whether this spritelayout needs preprocessing by SpriteLayoutProcessor, or whether it can be us...
SpriteID sprite
The 'real' sprite.
PaletteID pal
The palette (use PAL_NONE) if not needed).
'Real' sprite groups contain a list of other result or callback sprite groups.
std::vector< const SpriteGroup * > loaded
List of loaded groups (can be SpriteIDs or Callback results).
std::vector< const SpriteGroup * > loading
List of loading groups (can be SpriteIDs or Callback results).
Interface for SpriteGroup-s to access the gamestate.
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
uint32_t callback_param2
Second parameter (var 18) of the callback.
void UnhandledVariable(uint8_t variable) const
Log a message for an unhandled NewGRF variable.
CallbackID callback
Callback being resolved.
uint32_t callback_param1
First parameter (var 10) of the callback.
A result sprite group returns the first SpriteID and the number of sprites in the set.
ResolverObject & ro
Surrounding resolver object.
Specialization of ResolverObject with type-safe access to RandomTriggers.
static bool IsExpected(const BaseStation *st)
static Station * From(BaseStation *st)
Common wrapper for all the different sprite group types.
Helper class for animation control.
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.
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.
struct BaseStation * st
Instance of the station.
uint32_t GetRandomTriggers() const override
Get the triggers.
uint32_t GetVariable(uint8_t variable, uint32_t parameter, bool &available) const override
Get a variable value.
uint32_t GetRandomBits() const override
Get a few random bits.
const struct StationSpec * statspec
Station (type) specification.
Axis axis
Station axis, used only for the slope check callback.
TileIndex tile
Tile of the station.
CargoGRFFileProps grf_prop
Link to NewGRF.
CargoTypes cargo_triggers
Bitmask of cargo types which cause trigger re-randomizing.
std::vector< NewGRFSpriteLayout > renderdata
Number of tile layouts.
StationCallbackMasks callback_mask
Bitmask of station callbacks that have to be called.
StationSpecFlags flags
Bitmask of flags, bit 0: use different sprite set; bit 1: divide cargo about by station size.
RoadStop * bus_stops
All the road stops.
std::array< GoodsEntry, NUM_CARGO > goods
Goods at this station.
bool TileBelongsToRailStation(TileIndex tile) const override
Check whether a specific tile belongs to this station.
Airport airport
Tile area the airport covers.
RoadStop * truck_stops
All the truck stops.
Scope resolver for a town.
uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint8_t variable, uint8_t parameter, bool &available) const override
Helper function to get a NewGRF variable that isn't implemented by the base class.
Generic 'commands' that can be performed on all tiles.
static bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
uint8_t GetAnimationFrame(Tile t)
Get the current animation frame.
Slope GetTileSlope(TileIndex tile)
Return the slope of a given tile inside the map.
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.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
@ TunnelBridge
Tunnel entry/exit and bridge heads.
@ Station
A tile of a station or airport.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Definition of the game-calendar-timer.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
TrackBits DiagdirReachesTracks(DiagDirection diagdir)
Returns all tracks that can be reached when entering a tile from a given (diagonal) direction.
TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
Discards all directional information from a TrackdirBits value.
EnumBitSet< Track, uint8_t > TrackBits
Bitset of Track elements.
@ Rail
Transport by train.
Functions that have tunnels and bridges in common.
DiagDirection GetTunnelBridgeDirection(Tile t)
Get the direction pointing to the other end.