|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
23 uint8_t default_selection;
44 uint32_t
GetVariable(
byte variable, [[maybe_unused]] uint32_t parameter,
bool *available)
const override;
86 typedef std::list<GenericCallback> GenericCallbackList;
88 static GenericCallbackList _gcl[GSF_END];
96 for (uint8_t feature = 0; feature <
lengthof(_gcl); feature++) {
97 _gcl[feature].clear();
111 GrfMsg(5,
"AddGenericCallback: Unsupported feature 0x{:02X}", feature);
127 case 0x80:
return this->cargo_type;
129 case 0x82:
return this->default_selection;
132 case 0x85:
return this->distance;
133 case 0x86:
return this->event;
134 case 0x87:
return this->count;
135 case 0x88:
return this->station_size;
141 Debug(grf, 1,
"Unhandled generic feature variable 0x{:02X}", variable);
172 for (
const auto &it : _gcl[feature]) {
173 object.grffile = it.file;
174 object.root_spritegroup = it.group;
176 object.callback_param1 = it.file->grf_version >= 8 ? param1_grfv8 : param1_grfv7;
177 uint16_t result =
object.ResolveCallback();
181 if (file !=
nullptr) *file = it.file;
222 object.generic_scope.cargo_type = cargo_type;
223 object.generic_scope.default_selection = default_selection;
224 object.generic_scope.src_industry = src_industry;
225 object.generic_scope.dst_industry = dst_industry;
226 object.generic_scope.distance = distance;
227 object.generic_scope.event = event;
228 object.generic_scope.count = count;
229 object.generic_scope.station_size = station_size;
230 object.generic_scope.feature = feature;
252 object.generic_scope.feature = GSF_SOUNDFX;
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
static uint16_t GetGenericCallbackResult(uint8_t feature, ResolverObject &object, uint32_t param1_grfv7, uint32_t param1_grfv8, const GRFFile **file)
Follow a generic feature callback list and return the first successful answer.
WaterClass GetWaterClass(Tile t)
Get the water class at a tile.
uint32_t GetDebugID() const override
Get an identifier for the item being resolved.
@ CBID_SOUNDS_AMBIENT_EFFECT
Select an ambient sound to play for a given type of tile.
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
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.
uint32_t GetTerrainType(TileIndex tile, TileContext context)
Function used by houses (and soon industries) to get information on type of "terrain" the tile it is ...
@ 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).
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
@ VSG_SCOPE_SELF
Resolved object itself.
static debug_inline TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
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.
SoundSettings sound
sound effect settings
AIConstructionEvent
AI events for asking the NewGRF for information.
@ CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
uint8_t dst_industry
Destination industry substitute type. 0xFF for "town", 0xFE for "unknown".
uint8_t src_industry
Source industry substitute type. 0xFF for "town", 0xFE for "unknown".
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
uint16_t GetAiPurchaseCallbackResult(uint8_t feature, CargoID cargo_type, uint8_t default_selection, IndustryType src_industry, IndustryType dst_industry, uint8_t distance, AIConstructionEvent event, uint8_t count, uint8_t station_size, const GRFFile **file)
'Execute' an AI purchase selection callback
uint8_t bitnum
Cargo bit number, is INVALID_CARGO_BITNUM for a non-used spec.
Defines the data structure for constructing industry.
bool HasTileWaterClass(Tile t)
Checks whether the tile has an waterclass associated.
@ MP_TREES
Tile got trees.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
void AmbientSoundEffectCallback(TileIndex tile)
'Execute' the ambient sound effect callback.
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.
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.
static debug_inline uint TileHeight(Tile tile)
Returns the height of a tile.
byte CargoID
Cargo slots to indicate a cargo type within a game.
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
Resolver object for generic objects/properties.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
ResolverObject & ro
Surrounding resolver object.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
bool ai_callback
Callback comes from the AI.
bool Chance16R(const uint a, const uint b, uint32_t &r)
Flips a coin with a given probability and saves the randomize-number in a variable.
GenericResolverObject(bool ai_callback, CallbackID callback=CBID_NO_CALLBACK)
Generic resolver.
std::array< uint8_t, NUM_CARGO > cargo_map
Inverse cargo translation table (CargoID -> local ID)
uint32_t GetVariable(byte variable, [[maybe_unused]] uint32_t parameter, bool *available) const override
Get a variable value.
void ResetGenericCallbacks()
Reset all generic feature callback sprite groups.
Dynamic data of a loaded NewGRF.
Scope resolver for generic objects and properties.
void AddGenericCallback(uint8_t feature, const GRFFile *file, const SpriteGroup *group)
Add a generic feature callback sprite group to the appropriate feature list.