OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
60 if (_airport_mngr.
GetGRFID(type) == 0)
return as;
84 if (!this->
enabled)
return false;
85 if (TimerGameCalendar::year < this->
min_year)
return false;
98 if (table >= this->
layouts.size())
return false;
115 auto insert = std::copy(std::begin(_origin_airport_specs), std::end(_origin_airport_specs), std::begin(
AirportSpec::specs));
133 void AirportOverrideManager::SetEntitySpec(
AirportSpec *as)
138 GrfMsg(1,
"Airport.SetEntitySpec: Too many airports allocated. Ignoring.");
151 overridden_as->
enabled =
false;
153 this->grfid_overrides[i] = 0;
160 case 0x40:
return this->
layout;
163 if (this->
st ==
nullptr) {
176 return this->
st->GetNewGRFVariable(this->
ro, variable, parameter, available);
201 if (this->
st ==
nullptr)
return;
205 if (value == 0)
return;
224 if (this->airport_scope.
st !=
nullptr) {
225 t = this->airport_scope.
st->
town;
229 if (t ==
nullptr)
return nullptr;
230 this->
town_scope.emplace(*
this, t, this->airport_scope.
st ==
nullptr);
246 CallbackID callback, uint32_t param1, uint32_t param2)
247 :
ResolverObject(spec->grf_prop.grffile, callback, param1, param2), airport_scope(*this, tile, st, spec, layout)
258 return group->GetResult();
264 return object.ResolveCallback();
277 uint16_t cb_res =
object.ResolveCallback();
278 if (cb_res ==
CALLBACK_FAILED || cb_res == 0x400)
return STR_UNDEFINED;
279 if (cb_res > 0x400) {
281 return STR_UNDEFINED;
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
StationFacility facilities
The facilities that this station has.
uint32_t GetGRFID(uint16_t entity_id) const
Gives the GRFID of the file the entity belongs to.
StationSettings station
settings related to station management
static constexpr TimerGame< struct Calendar >::Date DAYS_TILL_ORIGINAL_BASE_YEAR
The date of the first day of the original base year.
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
constexpr void Swap(T &a, T &b)
Type safe swap operation.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override
Get a variable value.
Town * town
The town this station is associated with.
std::vector< AirportTileLayout > layouts
List of layouts composing the airport.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
static void Assign(Tspec *spec)
Assign a spec to one of the classes.
Interface for SpriteGroup-s to access the gamestate.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
struct Station * st
Station of the airport for which the callback is run, or nullptr for build gui.
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
TimerGameCalendar::Year min_year
first year the airport is available
TimerGameCalendar::Year max_year
last year the airport is available
static void ResetAirports()
This function initializes the airportspec array.
CallbackID
List of implemented NewGRF callbacks.
static void InsertDefaults()
Initialise the defaults.
bool IsUIAvailable(uint index) const
Check whether the spec will be available to the user at some point in time.
Defines the data structure for an airport.
StringID name
Name of this class.
uint8_t layout
Layout of the airport to build.
uint16_t invalid_id
ID used to detected invalid entities.
uint16_t override
id of the entity been replaced by
AirportResolverObject(TileIndex tile, Station *st, const AirportSpec *spec, uint8_t layout, CallbackID callback=CBID_NO_CALLBACK, uint32_t callback_param1=0, uint32_t callback_param2=0)
Constructor of the airport resolver.
void BindAirportSpecs()
Tie all airportspecs to their class.
TYPE GetValue(uint pos) const
Gets the value from a given position.
const SpriteGroup * root_spritegroup
Root SpriteGroup to use for resolving.
Class for pooled persistent storage of data.
Airport airport
Tile area the airport covers.
bool never_expire_airports
never expire airports
GameSettings _settings_game
Game settings of a running game or the scenario editor.
@ AT_INVALID
Invalid airport.
#define lengthof(array)
Return the length of an fixed size array.
@ NUM_AIRPORTS
Maximal number of airports in total.
uint16_t GetSubstituteID(uint16_t entity_id) const
Gives the substitute of the entity, as specified by the grf file.
Resolver object for airports.
Scope resolver for a town.
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.
StringID GetGRFStringID(uint32_t grfid, StringID stringid)
Returns the index for this stringid associated with its grfID.
StringID GetAirportTextCallback(const AirportSpec *as, uint8_t layout, uint16_t callback)
Get a custom text for the airport.
static AirportSpec specs[NUM_AIRPORTS]
Specs of the airports.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
bool IsAvailable() const
Check whether this airport is available to build.
uint16_t local_id
id defined by the grf file for this entity
uint8_t size_x
size of airport in x direction
std::optional< TownScopeResolver > town_scope
The town scope resolver (created on the first call).
static debug_inline uint SizeX()
Get the size of the map along the X.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
const AirportSpec * spec
AirportSpec for which the callback is run.
bool enabled
Entity still available (by default true). Newgrf can disable it, though.
SpriteID preview_sprite
preview sprite for this airport
@ NEW_AIRPORT_OFFSET
Number of the first newgrf airport.
uint8_t size_y
size of airport in y direction
TileIndex tile
The base tile of the area.
static Tindex Allocate(uint32_t global_id)
Allocate a class with a given global class ID.
struct GRFFileProps grf_prop
Properties related to the grf file.
void ResetOverride()
Resets the override, which is used while initializing game.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
uint32_t GetDebugID() const override
Get an identifier for the item being resolved.
Struct containing information relating to NewGRF classes for stations and airports.
uint16_t random_bits
Random bits assigned to this station.
void ErrorUnknownCallbackResult(uint32_t grfid, uint16_t cbid, uint16_t cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
virtual const SpriteGroup * Resolve([[maybe_unused]] ResolverObject &object) const
Base sprite group resolver.
static AirportSpec * GetWithoutOverride(uint8_t type)
Retrieve airport spec for the given airport.
bool IsWithinMapBounds(uint8_t table, TileIndex index) const
Check if the airport would be within the map bounds at the given tile.
uint16_t max_offset
what is the length of the original entity's array of specs
ResolverObject & ro
Surrounding resolver object.
const struct GRFFile * grffile
grf file that introduced this entity
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
PersistentStorage * psa
Persistent storage for NewGRF airports.
static NewGRFClass * Get(Tindex class_index)
Get a particular class.
TownScopeResolver * GetTown()
Get the town scope associated with a station, if it exists.
uint8_t type
Type of this airport,.
uint8_t layout
Airport layout number.
void StorePSA(uint pos, int32_t value) override
Store a value into the object's persistent storage.
uint32_t GetRandomBits() const override
Get a few random bits.
void StoreValue(uint pos, int32_t value)
Stores some value at a given position.
std::array< const struct SpriteGroup *, Tcnt > spritegroup
pointers to the different sprites of the entity
static const AirportSpec * Get(uint8_t type)
Retrieve airport spec for the given airport.
static uint SizeY()
Get the size of the map along the Y.
TileIndex tile
Tile for the callback, only valid for airporttile callbacks.
static Year year
Current year, starting at 0.
TimerGameCalendar::Date build_date
Date of construction.