OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
24 uint8 default_selection;
45 uint32
GetVariable(
byte variable, uint32 parameter,
bool *available)
const override;
89 typedef std::list<GenericCallback> GenericCallbackList;
91 static GenericCallbackList _gcl[GSF_END];
99 for (uint8 feature = 0; feature <
lengthof(_gcl); feature++) {
100 _gcl[feature].clear();
114 grfmsg(5,
"AddGenericCallback: Unsupported feature 0x%02X", feature);
130 case 0x80:
return this->cargo_type;
132 case 0x82:
return this->default_selection;
135 case 0x85:
return this->distance;
136 case 0x86:
return this->event;
137 case 0x87:
return this->count;
138 case 0x88:
return this->station_size;
144 DEBUG(grf, 1,
"Unhandled generic feature variable 0x%02X", variable);
183 for (GenericCallbackList::const_iterator it = _gcl[feature].begin(); it != _gcl[feature].end(); ++it) {
184 object.grffile = it->file;
185 object.root_spritegroup = it->group;
187 object.callback_param1 = it->file->grf_version >= 8 ? param1_grfv8 : param1_grfv7;
188 uint16 result =
object.ResolveCallback();
192 if (file !=
nullptr) *file = it->file;
233 object.generic_scope.cargo_type = cargo_type;
234 object.generic_scope.default_selection = default_selection;
235 object.generic_scope.src_industry = src_industry;
236 object.generic_scope.dst_industry = dst_industry;
237 object.generic_scope.distance = distance;
238 object.generic_scope.event = event;
239 object.generic_scope.count = count;
240 object.generic_scope.station_size = station_size;
241 object.generic_scope.feature = feature;
263 object.generic_scope.feature = GSF_SOUNDFX;
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
uint32 TileIndex
The index/ID of a Tile.
const SpriteGroup ** loaded
List of loaded groups (can be SpriteIDs or Callback results)
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
static bool HasTileWaterClass(TileIndex t)
Checks whether the tile has an waterclass associated.
void CDECL grfmsg(int severity, const char *str,...)
DEBUG() function dedicated to newGRF debugging messages Function is essentially the same as DEBUG(grf...
@ CBID_SOUNDS_AMBIENT_EFFECT
Select an ambient sound to play for a given type of tile.
byte num_loaded
Number of loaded groups.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
Interface for SpriteGroup-s to access the gamestate.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
ClientSettings _settings_client
The current settings for this game.
static const IndustryType IT_AI_UNKNOWN
The AI has no specific industry in mind.
uint16 GetAiPurchaseCallbackResult(uint8 feature, CargoID cargo_type, uint8 default_selection, IndustryType src_industry, IndustryType dst_industry, uint8 distance, AIConstructionEvent event, uint8 count, uint8 station_size, const GRFFile **file)
'Execute' an AI purchase selection callback
@ GSF_INVALID
An invalid spec feature.
CallbackID
List of implemented NewGRF callbacks.
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope).
uint32 GetDebugID() const override
Get an identifier for the item being resolved.
@ VSG_SCOPE_SELF
Resolved object itself.
uint8 bitnum
Cargo bit number, is INVALID_CARGO for a non-used spec.
uint8 dst_industry
Destination industry substitute type. 0xFF for "town", 0xFE for "unknown".
bool ambient
Play ambient, industry and town sounds.
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0) override
Get a resolver for the scope.
@ CBID_GENERIC_AI_PURCHASE_SELECTION
AI construction/purchase selection.
void PlayTileSound(const GRFFile *file, SoundID sound_id, TileIndex tile)
Play a NewGRF sound effect at the location of a specific tile.
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
SoundSettings sound
sound effect settings
AIConstructionEvent
AI events for asking the NewGRF for information.
#define DEBUG(name, level,...)
Output a line of debugging information.
@ CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
static uint16 GetGenericCallbackResult(uint8 feature, ResolverObject &object, uint32 param1_grfv7, uint32 param1_grfv8, const GRFFile **file)
Follow a generic feature callback list and return the first successful answer.
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
void AddGenericCallback(uint8 feature, const GRFFile *file, const SpriteGroup *group)
Add a generic feature callback sprite group to the appropriate feature list.
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override
Get a variable value.
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
const SpriteGroup * ResolveReal(const RealSpriteGroup *group) const override
Get the real sprites of the grf.
Defines the data structure for constructing industry.
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
@ MP_TREES
Tile got trees.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
void AmbientSoundEffectCallback(TileIndex tile)
'Execute' the ambient sound effect callback.
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
static const IndustryType INVALID_INDUSTRYTYPE
one above amount is considered invalid
GRFFileProps grf_prop
properties related to the grf file
GenericScopeResolver(ResolverObject &ro, bool ai_callback)
Generic scope resolver.
uint8 cargo_map[NUM_CARGO]
Inverse cargo translation table (CargoID -> local ID)
CallbackID callback
Callback being resolved.
static const IndustryType IT_AI_TOWN
The AI actually wants to transport to/from a town, not an industry.
#define lengthof(x)
Return the length of an fixed size array.
byte CargoID
Cargo slots to indicate a cargo type within a game.
static bool Chance16R(const uint a, const uint b, uint32 &r)
Flips a coin with a given probability and saves the randomize-number in a variable.
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
Resolver object for generic objects/properties.
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
ResolverObject & ro
Surrounding resolver object.
bool ai_callback
Callback comes from the AI.
GenericResolverObject(bool ai_callback, CallbackID callback=CBID_NO_CALLBACK)
Generic resolver.
uint8 src_industry
Source industry substitute type. 0xFF for "town", 0xFE for "unknown".
void ResetGenericCallbacks()
Reset all generic feature callback sprite groups.
uint32 GetTerrainType(TileIndex tile, TileContext context)
Function used by houses (and soon industries) to get information on type of "terrain" the tile it is ...
Dynamic data of a loaded NewGRF.
Scope resolver for generic objects and properties.