26 uint8 default_selection;
40 :
ScopeResolver(ro), cargo_type(0), default_selection(0), src_industry(0), dst_industry(0), distance(0),
41 event(), count(0), station_size(0), ai_callback(ai_callback)
45 uint32
GetVariable(byte variable, uint32 parameter,
bool *available)
const;
79 typedef std::list<GenericCallback> GenericCallbackList;
81 static GenericCallbackList _gcl[GSF_END];
89 for (uint8 feature = 0; feature <
lengthof(_gcl); feature++) {
90 _gcl[feature].clear();
104 grfmsg(5,
"AddGenericCallback: Unsupported feature 0x%02X", feature);
120 case 0x80:
return this->cargo_type;
122 case 0x82:
return this->default_selection;
125 case 0x85:
return this->distance;
126 case 0x86:
return this->event;
127 case 0x87:
return this->count;
128 case 0x88:
return this->station_size;
134 DEBUG(grf, 1,
"Unhandled generic feature variable 0x%02X", variable);
174 for (GenericCallbackList::const_iterator it = _gcl[feature].begin(); it != _gcl[feature].end(); ++it) {
175 object.grffile = it->file;
176 object.root_spritegroup = it->group;
178 object.callback_param1 = it->file->grf_version >= 8 ? param1_grfv8 : param1_grfv7;
179 uint16 result =
object.ResolveCallback();
183 if (file != NULL) *file = it->file;
225 object.generic_scope.cargo_type = cargo_type;
226 object.generic_scope.default_selection = default_selection;
227 object.generic_scope.src_industry = src_industry;
228 object.generic_scope.dst_industry = dst_industry;
229 object.generic_scope.distance = distance;
230 object.generic_scope.event = event;
231 object.generic_scope.count = count;
232 object.generic_scope.station_size = station_size;
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope)...
Scope resolver for generic objects and properties.
Resolver object for generic objects/properties.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
uint8 dst_industry
Destination industry substitute type. 0xFF for "town", 0xFE for "unknown".
ResolverObject & ro
Surrounding resolver object.
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
Functions related to debugging.
Interface for SpriteGroup-s to access the gamestate.
uint32 GetTerrainType(TileIndex tile, TileContext context)
Function used by houses (and soon industries) to get information on type of "terrain" the tile it is ...
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const
Get a variable value.
GenericResolverObject(bool ai_callback, CallbackID callback=CBID_NO_CALLBACK)
Generic resolver.
Set when using the callback resolve system, but not to resolve a callback.
bool ambient
Play ambient, industry and town sounds.
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
AI construction/purchase selection.
byte num_loaded
Number of loaded groups.
void AddGenericCallback(uint8 feature, const GRFFile *file, const SpriteGroup *group)
Add a generic feature callback sprite group to the appropriate feature list.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
Pseudo random number generator.
AIConstructionEvent
AI events for asking the NewGRF for information.
static const IndustryType IT_AI_UNKNOWN
The AI has no specific industry in mind.
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a give tiletype.
const SpriteGroup ** loaded
List of loaded groups (can be SpriteIDs or Callback results)
static const IndustryType IT_AI_TOWN
The AI actually wants to transport to/from a town, not an industry.
SoundSettings sound
sound effect settings
bool ai_callback
Callback comes from the AI.
void PlayTileSound(const GRFFile *file, SoundID sound_id, TileIndex tile)
Play a NewGRF sound effect at the location of a specific tile.
ClientSettings _settings_client
The current settings for this game.
Map accessors for water tiles.
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
Definition of base types and functions in a cross-platform compatible way.
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
A number of safeguards to prevent using unsafe methods.
Defines the data structure for constructing industry.
uint8 cargo_map[NUM_CARGO]
Inverse cargo translation table (CargoID -> local ID)
#define lengthof(x)
Return the length of an fixed size array.
GRFFileProps grf_prop
properties related to the grf file
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.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
#define DEBUG(name, level,...)
Output a line of debugging information.
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
void AmbientSoundEffectCallback(TileIndex tile)
'Execute' the ambient sound effect callback.
static const IndustryType INVALID_INDUSTRYTYPE
one above amount is considered invalid
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
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 uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
uint8 src_industry
Source industry substitute type. 0xFF for "town", 0xFE for "unknown".
void ResetGenericCallbacks()
Reset all generic feature callback sprite groups.
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.
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
uint8 bitnum
Cargo bit number, is INVALID_CARGO for a non-used spec.
CallbackID
List of implemented NewGRF callbacks.
Select an ambient sound to play for a given type of tile.
static bool HasTileWaterClass(TileIndex t)
Checks whether the tile has an waterclass associated.
Functions related to NewGRF provided sounds.
A tile without any structures, i.e. grass, rocks, farm fields etc.
byte CargoID
Cargo slots to indicate a cargo type within a game.
const SpriteGroup * ResolveReal(const RealSpriteGroup *group) const
Get the real sprites of the grf.
GenericScopeResolver(ResolverObject &ro, bool ai_callback)
Generic scope resolver.
Dynamic data of a loaded NewGRF.