38 :
ScopeResolver(ro), st(st), airport_id(airport_id), layout(layout), tile(tile)
43 uint32
GetVariable(byte variable, uint32 parameter,
bool *available)
const;
44 void StorePSA(uint pos, int32 value);
70 template <
typename Tspec,
typename T
id, T
id Tmax>
79 template <
typename Tspec,
typename T
id, T
id Tmax>
100 assert(type <
lengthof(AirportSpec::specs));
105 as = &AirportSpec::specs[subst_id];
119 assert(type <
lengthof(AirportSpec::specs));
120 return &AirportSpec::specs[type];
126 if (!this->enabled)
return false;
127 if (_cur_year < this->min_year)
return false;
138 memset(&AirportSpec::specs, 0,
sizeof(AirportSpec::specs));
151 if (as->
enabled) AirportClass::Assign(as);
156 void AirportOverrideManager::SetEntitySpec(
AirportSpec *as)
160 if (airport_id == invalid_ID) {
161 grfmsg(1,
"Airport.SetEntitySpec: Too many airports allocated. Ignoring.");
168 for (
int i = 0; i < max_offset; i++) {
174 overridden_as->
enabled =
false;
175 entity_overrides[i] = invalid_ID;
176 grfid_overrides[i] = 0;
183 case 0x40:
return this->
layout;
186 if (this->
st == NULL) {
199 return this->
st->GetNewGRFVariable(this->
ro, variable, parameter, available);
225 if (this->
st == NULL)
return;
229 if (value == 0)
return;
250 CallbackID callback, uint32 param1, uint32 param2)
251 :
ResolverObject(
AirportSpec::Get(airport_id)->grf_prop.grffile, callback, param1, param2), airport_scope(*this, tile, st, airport_id, layout)
262 return group->GetResult();
268 return object.ResolveCallback();
281 uint16 cb_res =
object.ResolveCallback();
282 if (cb_res ==
CALLBACK_FAILED || cb_res == 0x400)
return STR_UNDEFINED;
283 if (cb_res > 0x400) {
285 return STR_UNDEFINED;
Implementation of the NewGRF class' functions.
byte type
Type of this airport,.
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope)...
TileIndex tile
Tile for the callback, only valid for airporttile callbacks.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
bool IsAvailable() const
Check whether this airport is available to build.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
AirportClassID
List of default airport classes.
static AirportSpec * GetWithoutOverride(byte type)
Retrieve airport spec for the given airport.
ResolverObject & ro
Surrounding resolver object.
#define DAYS_TILL_ORIGINAL_BASE_YEAR
The offset in days from the '_date == 0' till 'ConvertYMDToDate(ORIGINAL_BASE_YEAR, 0, 1)'.
Functions related to dates.
Functions related to debugging.
Interface for SpriteGroup-s to access the gamestate.
byte GetIndex() const
Get the index of this spec.
bool never_expire_airports
never expire airports
Set when using the callback resolve system, but not to resolve a callback.
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.
#define INSTANTIATE_NEWGRF_CLASS_METHODS(name, Tspec, Tid, Tmax)
Force instantiation of the methods so we don't get linker errors.
AirportScopeResolver(ResolverObject &ro, TileIndex tile, Station *st, byte airport_id, byte layout)
Constructor of the scope resolver for an airport.
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
StringID GetGRFStringID(uint32 grfid, StringID stringid)
Returns the index for this stringid associated with its grfID.
byte num_loaded
Number of loaded groups.
const SpriteGroup * ResolveReal(const RealSpriteGroup *group) const
Get the real sprites of the grf.
bool IsUIAvailable(uint index) const
Check whether the spec will be available to the user at some point in time.
Year _cur_year
Current year, starting at 0.
uint32 GetRandomBits() const
Get a few random bits.
StationSettings station
settings related to station management
const SpriteGroup * root_spritegroup
Root SpriteGroup to use for resolving.
Header of Action 04 "universal holder" structure and functions.
Maximal number of airports in total.
Struct containing information relating to NewGRF classes for stations and airports.
virtual const SpriteGroup * Resolve(ResolverObject &object) const
Base sprite group resolver.
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const
Get a variable value.
TYPE GetValue(uint pos) const
Gets the value from a given position.
const SpriteGroup ** loaded
List of loaded groups (can be SpriteIDs or Callback results)
Number of the first newgrf airport.
void StoreValue(uint pos, int32 value)
Stores some value at a given position.
maximum number of airport classes
static void ResetAirports()
This function initializes the airportspec array.
byte layout
Airport layout number.
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
Class for pooled persistent storage of data.
static const AirportSpec * Get(byte type)
Retrieve airport spec for the given airport.
PersistentStorage * psa
Persistent storage for NewGRF airports.
const SpriteGroup ** loading
List of loading groups (can be SpriteIDs or Callback results)
StationFacilityByte facilities
The facilities that this station has.
Resolver for the airport scope.
#define lengthof(x)
Return the length of an fixed size array.
static AirportSpec specs[NUM_AIRPORTS]
Specs of the airports.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
const struct SpriteGroup * spritegroup[Tcnt]
pointer to the different sprites of the entity
struct Station * st
Station of the airport for which the callback is run, or NULL for build gui.
byte layout
Layout of the airport to build.
void StorePSA(uint pos, int32 value)
Store a value into the object's persistent storage.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
uint16 override
id of the entity been replaced by
TileIndex tile
The base tile of the area.
void BindAirportSpecs()
Tie all airportspecs to their class.
byte num_loading
Number of loading groups.
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
uint32 TileIndex
The index/ID of a Tile.
void CDECL grfmsg(int severity, const char *str,...)
DEBUG() function dedicated to newGRF debugging messages Function is essentially the same as DEBUG(grf...
CallbackID callback
Callback being resolved.
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() ...
byte airport_id
Type of airport for which the callback is run.
uint16 local_id
id defined by the grf file for this entity
Resolver object for airports.
static void InsertDefaults()
Initialise the defaults.
uint16 random_bits
Random bits assigned to this station.
Airport airport
Tile area the airport covers.
void ResetOverride()
Resets the override, which is used while initializing game.
const struct GRFFile * grffile
grf file that introduced this entity
bool enabled
Entity still available (by default true). Newgrf can disable it, though.
CallbackID
List of implemented NewGRF callbacks.
SpriteID preview_sprite
preview sprite for this airport
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
Defines the data structure for an airport.
Base classes/functions for stations.
StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback)
Get a custom text for the airport.
struct GRFFileProps grf_prop
Properties related to the grf file.
Date build_date
Date of construction.
uint16 GetSubstituteID(uint16 entity_id) const
Gives the substitute of the entity, as specified by the grf file.
StringID name
Name of this class.