OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
41 uint32
GetVariable(
byte variable, uint32 parameter,
bool *available)
const override;
42 void StorePSA(uint pos, int32 value)
override;
71 template <
typename Tspec,
typename T
id, T
id Tmax>
80 template <
typename Tspec,
typename T
id, T
id Tmax>
104 if (_airport_mngr.
GetGRFID(type) == 0)
return as;
128 if (!this->
enabled)
return false;
129 if (_cur_year < this->
min_year)
return false;
171 if (as->
enabled) AirportClass::Assign(as);
176 void AirportOverrideManager::SetEntitySpec(
AirportSpec *as)
181 grfmsg(1,
"Airport.SetEntitySpec: Too many airports allocated. Ignoring.");
194 overridden_as->
enabled =
false;
196 grfid_overrides[i] = 0;
203 case 0x40:
return this->
layout;
206 if (this->
st ==
nullptr) {
219 return this->
st->GetNewGRFVariable(this->
ro, variable, parameter, available);
254 if (this->
st ==
nullptr)
return;
258 if (value == 0)
return;
279 CallbackID callback, uint32 param1, uint32 param2)
280 :
ResolverObject(
AirportSpec::Get(airport_id)->grf_prop.grffile, callback, param1, param2), airport_scope(*this, tile, st, airport_id, layout)
291 return group->GetResult();
297 return object.ResolveCallback();
310 uint16 cb_res =
object.ResolveCallback();
311 if (cb_res ==
CALLBACK_FAILED || cb_res == 0x400)
return STR_UNDEFINED;
312 if (cb_res > 0x400) {
314 return STR_UNDEFINED;
Year min_year
first year the airport is available
StationFacility facilities
The facilities that this station has.
uint32 TileIndex
The index/ID of a Tile.
const SpriteGroup ** loaded
List of loaded groups (can be SpriteIDs or Callback results)
uint32 callback_param1
First parameter (var 10) of the callback.
uint16 override
id of the entity been replaced by
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.
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback)
Get a custom text for the airport.
void CDECL grfmsg(int severity, const char *str,...)
DEBUG() function dedicated to newGRF debugging messages Function is essentially the same as DEBUG(grf...
Year _cur_year
Current year, starting at 0.
byte size_y
size of airport in y direction
byte num_loaded
Number of loaded groups.
Year max_year
last year the airport is available
#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.
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.
static void ResetAirports()
This function initializes the airportspec array.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
CallbackID
List of implemented NewGRF callbacks.
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope).
Defines the data structure for an airport.
@ VSG_SCOPE_SELF
Resolved object itself.
static uint TileX(TileIndex tile)
Get the X component of a tile.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
static uint MapSizeX()
Get the size of the map along the X.
bool IsUIAvailable(uint index) const
Check whether the spec will be available to the user at some point in time.
const SpriteGroup ** loading
List of loading groups (can be SpriteIDs or Callback results)
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0) override
Get a resolver for the scope.
uint32 callback_param2
Second parameter (var 18) of the callback.
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.
AirportScopeResolver(ResolverObject &ro, TileIndex tile, Station *st, byte airport_id, byte layout)
Constructor of the scope resolver for an airport.
const SpriteGroup * ResolveReal(const RealSpriteGroup *group) const override
Get the real sprites of the grf.
byte num_table
number of elements in the table
uint16 random_bits
Random bits assigned to this station.
uint32 GetRandomBits() const override
Get a few random bits.
@ CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
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.
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.
void StoreValue(uint pos, int32 value)
Stores some value at a given position.
@ AT_INVALID
Invalid airport.
StringID GetGRFStringID(uint32 grfid, StringID stringid)
Returns the index for this stringid associated with its grfID.
@ NUM_AIRPORTS
Maximal number of airports in total.
Resolver object for airports.
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
static uint MapSizeY()
Get the size of the map along the Y.
static AirportSpec specs[NUM_AIRPORTS]
Specs of the airports.
static void InsertDefaults()
Initialise the defaults.
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override
Get a variable value.
bool IsAvailable() const
Check whether this airport is available to build.
byte size_x
size of airport in x direction
void StorePSA(uint pos, int32 value) override
Store a value into the object's persistent storage.
Resolver for the airport scope.
virtual const SpriteGroup * Resolve(ResolverObject &object) const
Base sprite group resolver.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
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.
AirportResolverObject(TileIndex tile, Station *st, byte airport_id, byte layout, CallbackID callback=CBID_NO_CALLBACK, uint32 callback_param1=0, uint32 callback_param2=0)
Constructor of the airport resolver.
uint16 GetSubstituteID(uint16 entity_id) const
Gives the substitute of the entity, as specified by the grf file.
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()
CallbackID callback
Callback being resolved.
StringID name
Name of this class.
static AirportSpec * GetWithoutOverride(byte type)
Retrieve airport spec for the given airport.
#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,.
byte num_loading
Number of loading groups.
uint16 max_offset
what is the length of the original entity's array of specs
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
virtual uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id)
Reserves a place in the mapping array for an entity to be installed.
uint32 GetGRFID(uint16 entity_id) const
Gives the GRFID of the file the entity belongs to.
uint16 local_id
id defined by the grf file for this entity
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
ResolverObject & ro
Surrounding resolver object.
const struct GRFFile * grffile
grf file that introduced this entity
static void Swap(T &a, T &b)
Type safe swap operation.
uint32 GetDebugID() const override
Get an identifier for the item being resolved.
PersistentStorage * psa
Persistent storage for NewGRF airports.
const AirportTileTable *const * table
list of the tiles composing the airport
Date build_date
Date of construction.
uint16 invalid_ID
ID used to detected invalid entities;.
#define DAYS_TILL_ORIGINAL_BASE_YEAR
The offset in days from the '_date == 0' till 'ConvertYMDToDate(ORIGINAL_BASE_YEAR,...
TileIndex tile
Tile for the callback, only valid for airporttile callbacks.