|
OpenTTD Source
14.0-beta3
|
Go to the documentation of this file.
26 template <
typename Tspec,
typename T
id, T
id Tmax>
35 template <
typename Tspec,
typename T
id, T
id Tmax>
59 if (_airport_mngr.
GetGRFID(type) == 0)
return as;
83 if (!this->
enabled)
return false;
84 if (TimerGameCalendar::year < this->
min_year)
return false;
114 auto insert = std::copy(std::begin(_origin_airport_specs), std::end(_origin_airport_specs), std::begin(
AirportSpec::specs));
127 if (as->
enabled) AirportClass::Assign(as);
132 void AirportOverrideManager::SetEntitySpec(
AirportSpec *as)
137 GrfMsg(1,
"Airport.SetEntitySpec: Too many airports allocated. Ignoring.");
150 overridden_as->
enabled =
false;
152 this->grfid_overrides[i] = 0;
159 case 0x40:
return this->
layout;
162 if (this->
st ==
nullptr) {
175 return this->
st->GetNewGRFVariable(this->
ro, variable, parameter, available);
200 if (this->
st ==
nullptr)
return;
204 if (value == 0)
return;
223 if (this->airport_scope.
st !=
nullptr) {
224 t = this->airport_scope.
st->
town;
228 if (t ==
nullptr)
return nullptr;
245 CallbackID callback, uint32_t param1, uint32_t param2)
246 :
ResolverObject(
AirportSpec::Get(airport_id)->grf_prop.grffile, callback, param1, param2), airport_scope(*this, tile, st, airport_id, layout)
257 return group->GetResult();
263 return object.ResolveCallback();
276 uint16_t cb_res =
object.ResolveCallback();
277 if (cb_res ==
CALLBACK_FAILED || cb_res == 0x400)
return STR_UNDEFINED;
278 if (cb_res > 0x400) {
280 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
bool IsWithinMapBounds(byte table, TileIndex index) const
Check if the airport would be within the map bounds at the given tile.
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.
Town * town
The town this station is associated with.
byte size_y
size of airport in y direction
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
#define INSTANTIATE_NEWGRF_CLASS_METHODS(name, Tspec, Tid, Tmax)
Force instantiation of the methods so we don't get linker errors.
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.
byte airport_id
Type of airport for which the callback is run.
byte layout
Layout of the airport to build.
byte layout
Airport layout number.
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.
Defines the data structure for an airport.
uint16_t invalid_id
ID used to detected invalid entities.
bool IsUIAvailable(uint index) const
Check whether the spec will be available to the user at some point in time.
uint16_t override
id of the entity been replaced by
const Direction * rotation
the rotation of each tiletable
void BindAirportSpecs()
Tie all airportspecs to their class.
static const AirportSpec * Get(byte type)
Retrieve airport spec for the given airport.
byte num_table
number of elements in the table
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.
byte GetIndex() const
Get the index of this spec.
AirportResolverObject(TileIndex tile, Station *st, byte airport_id, byte layout, CallbackID callback=CBID_NO_CALLBACK, uint32_t callback_param1=0, uint32_t callback_param2=0)
Constructor of the airport resolver.
Airport airport
Tile area the airport covers.
Struct containing information relating to NewGRF classes for stations and airports.
bool never_expire_airports
never expire airports
GameSettings _settings_game
Game settings of a running game or the scenario editor.
@ AT_INVALID
Invalid airport.
@ 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.
static AirportSpec specs[NUM_AIRPORTS]
Specs of the airports.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
static void InsertDefaults()
Initialise the defaults.
bool IsAvailable() const
Check whether this airport is available to build.
uint16_t local_id
id defined by the grf file for this entity
byte size_x
size of airport in x direction
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 struct SpriteGroup * spritegroup[Tcnt]
pointer to the different sprites of the entity
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.
AirportClassID
List of default airport classes.
TileIndex tile
The base tile of the area.
struct GRFFileProps grf_prop
Properties related to the grf file.
@ APC_MAX
maximum number of airport classes
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.
StringID name
Name of this class.
static AirportSpec * GetWithoutOverride(byte type)
Retrieve airport spec for the given airport.
uint32_t GetVariable(byte variable, [[maybe_unused]] uint32_t parameter, bool *available) const override
Get a variable value.
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.
#define lengthof(x)
Return the length of an fixed size array.
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
byte type
Type of this airport,.
std::unique_ptr< TownScopeResolver > town_scope
The town scope resolver (created on the first call).
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.
const AirportTileTable *const * table
list of the tiles composing the airport
TownScopeResolver * GetTown()
Get the town scope associated with a station, if it exists.
StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16_t callback)
Get a custom text for the airport.
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.
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.