23#include "table/strings.h"
43 static_assert(std::numeric_limits<StationGfx>::max() + 1 ==
lengthof(tiles));
44 return &AirportTileSpec::tiles[gfx];
71 StationGfx airpt_id = this->
AddEntityID(airpts.grf_prop.local_id, airpts.grf_prop.grfid, airpts.grf_prop.subst_id);
74 GrfMsg(1,
"AirportTile.SetEntitySpec: Too many airport tiles allocated. Ignoring.");
78 AirportTileSpec::tiles[airpt_id] = std::move(airpts);
84 if (this->entity_overrides[i] != AirportTileSpec::tiles[airpt_id].grf_prop.local_id || this->grfid_overrides[i] != AirportTileSpec::tiles[airpt_id].grf_prop.grfid)
continue;
87 overridden_airpts->
enabled =
false;
89 this->grfid_overrides[i] = 0;
131 if (!st->TileBelongsToAirport(tile)) {
141 return 0xFF << 8 | gfx;
161 return 0xFF << 8 | ats->
grf_prop.subst_id;
166 assert(this->
st !=
nullptr);
187 if (this->
st->TileBelongsToAirport(tile)) {
199 Debug(grf, 1,
"Unhandled airport tile variable 0x{:X}", variable);
220 CallbackID callback, uint32_t callback_param1, uint32_t callback_param2)
221 :
ResolverObject(ats->grf_prop.grffile, callback, callback_param1, callback_param2),
222 tiles_scope(*this, ats, tile, st),
223 airport_scope(*this, tile, st, st != nullptr ?
AirportSpec::Get(st->airport.type) : nullptr, st != nullptr ? st->airport.layout : 0)
230 return GSF_AIRPORTTILES;
241 return object.ResolveCallback(regs100);
251 DrawWaterClassGround(ti);
263 bool draw_old_one =
true;
275 if (group ==
nullptr) {
280 auto dts = processor.GetLayout();
288 return GetAirportTileCallback(callback, param1, param2, ats, st, tile);
303 if (ats ==
nullptr)
return;
311 if (!ats->
animation.triggers.Test(trigger))
return false;
319 return DoTriggerAirportTileAnimation(st, tile, trigger,
Random());
327 uint32_t random =
Random();
329 if (!st->TileBelongsToAirport(tile))
continue;
334 uint8_t var18_extra = 0;
339 if (DoTriggerAirportTileAnimation(st, tile, trigger, random, var18_extra)) {
static const uint INVALID_AIRPORTTILE
id for an invalid airport tile
static const uint NEW_AIRPORTTILE_OFFSET
offset of first newgrf airport tile
static const uint NUM_AIRPORTTILES
Total number of airport tiles.
Tables with airporttile defaults.
static const AirportTileSpec _origin_airporttile_specs[]
All default airport tiles.
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
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.
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
uint8_t CargoType
Cargo slots to indicate a cargo type within a game.
bool IsValidCargoType(CargoType cargo)
Test whether cargo type is not INVALID_CARGO.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
uint16_t invalid_id
ID used to detected invalid entities.
void ResetOverride()
Resets the override, which is used while initializing game.
uint16_t max_offset
what is the length of the original entity's array of specs
virtual uint16_t AddEntityID(uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id)
Reserves a place in the mapping array for an entity to be installed.
Definition of stuff that is very close to a company, like the company struct itself.
Functions related to debugging.
#define Debug(category, level, format_string,...)
Output a line of debugging information.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
void DrawFoundation(TileInfo *ti, Foundation f)
Draw foundation f at tile ti.
Functions related to OTTD's landscape.
@ Random
Randomise borders.
uint8_t StationGfx
Copy from station_map.h.
StationGfx GetTranslatedAirportTileID(StationGfx gfx)
Do airporttile gfx ID translation for NewGRFs.
uint32_t GetRelativePosition(TileIndex tile, TileIndex ind_tile)
This is the position of the tile relative to the northernmost tile of the industry.
static uint32_t GetAirportTileIDAtOffset(TileIndex tile, const Station *st, uint32_t cur_grfid)
Make an analysis of a tile and check whether it belongs to the same airport, and/or the same grf file...
static uint32_t GetNearbyAirportTileInformation(uint8_t parameter, TileIndex tile, StationID index, bool grf_version8)
Based on newhouses/newindustries equivalent, but adapted for airports.
NewGRF handling of airport tiles.
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.
AirportTileCallbackMask
Callback masks for airport tiles.
@ DrawFoundations
decides if default foundations need to be drawn
@ AnimationNextFrame
decides next animation frame
@ AnimationSpeed
decides animation speed
CallbackID
List of implemented NewGRF callbacks.
@ CBID_AIRPTILE_DRAW_FOUNDATIONS
Called to determine the type (if any) of foundation to draw for an airport tile.
@ CBID_AIRPTILE_ANIMATION_TRIGGER
Called for periodically starting or stopping the animation.
@ CBID_AIRPTILE_ANIMATION_SPEED
Called to indicate how long the current animation frame should last.
@ CBID_AIRPTILE_ANIMATION_NEXT_FRAME
Called to determine airport tile next animation frame.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
uint32_t GetNearbyTileInformation(TileIndex tile, bool grf_version8)
Common part of station var 0x67, house var 0x62, indtile var 0x60, industry var 0x62.
bool ConvertBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
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.
Functions related to NewGRF provided sounds.
A number of safeguards to prevent using unsafe methods.
@ FOUNDATION_LEVELED
The tile is leveled up to a flat slope.
static PaletteID GetColourPalette(Colours colour)
Get recolour palette for a colour.
void DrawNewGRFTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, uint32_t stage, PaletteID default_palette)
Draw NewGRF industrytile or house sprite layout.
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_WIDTH
number of bits for the sprite number
Base classes/functions for stations.
bool IsAirport(Tile t)
Is this station tile an airport?
uint8_t GetStationTileRandomBits(Tile t)
Get the random bits of a station tile.
StationID GetStationIndex(Tile t)
Get StationID from a tile.
StationGfx GetAirportGfx(Tile t)
Get the station graphics of this airport tile.
AirportAnimationTrigger
Animation triggers for airport tiles.
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
Defines the data structure for an airport.
Helper class for animation control.
Resolver for tiles of an airport.
AirportTileScopeResolver tiles_scope
Scope resolver for the tiles.
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
uint32_t GetDebugID() const override
Get an identifier for the item being resolved.
AirportTileResolverObject(const AirportTileSpec *ats, TileIndex tile, Station *st, CallbackID callback=CBID_NO_CALLBACK, uint32_t callback_param1=0, uint32_t callback_param2=0)
Constructor of the resolver for airport tiles.
struct Station * st
Station of the airport for which the callback is run, or nullptr for build gui.
uint32_t GetVariable(uint8_t variable, uint32_t parameter, bool &available) const override
Get a variable value.
TileIndex tile
Tile for the callback, only valid for airporttile callbacks.
uint32_t GetRandomBits() const override
Get a few random bits.
Defines the data structure of each individual tile of an airport.
bool enabled
entity still available (by default true). newgrf can disable it, though
static const AirportTileSpec * Get(StationGfx gfx)
Retrieve airport tile spec for the given airport tile.
SubstituteGRFFileProps grf_prop
properties related the the grf file
AnimationInfo< AirportAnimationTriggers > animation
Information about the animation.
static const AirportTileSpec * GetByTile(TileIndex tile)
Retrieve airport tile spec for the given airport tile.
static void ResetAirportTiles()
This function initializes the tile array of AirportTileSpec.
uint8_t animation_special_flags
Extra flags to influence the animation.
AirportTileCallbackMasks callback_mask
Bitmask telling which grf callback is set.
Helper class for a unified approach to NewGRF animation.
static void AnimateTile(const AirportTileSpec *spec, Station *obj, TileIndex tile, bool random_animation, int extra_data=0)
Animate a single tile.
static void ChangeAnimationFrame(CallbackID cb, const AirportTileSpec *spec, Station *obj, TileIndex tile, uint32_t random_bits, uint32_t trigger, int extra_data=0)
Check a callback to determine what the next animation step is and execute that step.
Owner owner
The owner of this station.
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
uint16_t random_bits
Random bits assigned to this station.
Ground palette sprite of a tile, together with its sprite layout.
PalSpriteID ground
Palette and sprite for the ground.
const struct GRFFile * grffile
grf file that introduced this entity
uint16_t local_id
id defined by the grf file for this entity
uint32_t grfid
grfid that introduced this entity.
std::array< uint8_t, NUM_CARGO > cargo_map
Inverse cargo translation table (CargoType -> local ID)
TileIndex tile
The base tile of the area.
SpriteID sprite
The 'real' sprite.
PaletteID pal
The palette (use PAL_NONE) if not needed)
static Titem * Get(auto index)
Returns Titem with given index.
Tindex index
Index of this pool item.
Interface for SpriteGroup-s to access the gamestate.
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
const SpriteGroup * root_spritegroup
Root SpriteGroup to use for resolving.
ResolverObject & ro
Surrounding resolver object.
const struct SpriteGroup * GetSpriteGroup(bool entity_exists) const
Get the standard sprite group.
bool HasSpriteGroups() const
Check whether the entity has sprite groups.
Airport airport
Tile area the airport covers.
uint16_t override_id
id of the entity been replaced by
Tile information, used while rendering the tile.
Slope tileh
Slope of the tile.
TileIndex tile
Tile index.
Action 2 sprite layout for houses, industry tiles, objects and airport tiles.
SpriteLayoutProcessor ProcessRegisters(const ResolverObject &object, uint8_t *stage) const
Process registers and the construction stage into the sprite layout.
uint8_t GetAnimationFrame(Tile t)
Get the current animation frame.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
@ MP_STATION
A tile of a station.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
HouseZone GetTownRadiusGroup(const Town *t, TileIndex tile)
Returns the bit corresponding to the town zone of the specified tile.
@ TO_BUILDINGS
company buildings - depots, stations, HQ, ...
void DrawGroundSprite(SpriteID image, PaletteID pal, const SubSprite *sub, int extra_offs_x, int extra_offs_y)
Draws a ground sprite for the current tile.
Functions related to water (management)
bool IsTileOnWater(Tile t)
Tests if the tile was built on water.