|
@@ -21,70 +21,70 @@
|
|
|
#include "safeguards.h"
|
|
|
|
|
|
/** Scope resolver for generic objects and properties. */
|
|
|
struct GenericScopeResolver : public ScopeResolver {
|
|
|
CargoID cargo_type;
|
|
|
uint8 default_selection;
|
|
|
uint8 src_industry; ///< Source industry substitute type. 0xFF for "town", 0xFE for "unknown".
|
|
|
uint8 dst_industry; ///< Destination industry substitute type. 0xFF for "town", 0xFE for "unknown".
|
|
|
uint8 distance;
|
|
|
AIConstructionEvent event;
|
|
|
uint8 count;
|
|
|
uint8 station_size;
|
|
|
|
|
|
/**
|
|
|
* Generic scope resolver.
|
|
|
* @param ro Surrounding resolver.
|
|
|
* @param ai_callback Callback comes from the AI.
|
|
|
*/
|
|
|
GenericScopeResolver(ResolverObject &ro, bool ai_callback)
|
|
|
: ScopeResolver(ro), cargo_type(0), default_selection(0), src_industry(0), dst_industry(0), distance(0),
|
|
|
event(), count(0), station_size(0), ai_callback(ai_callback)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
|
|
|
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
|
|
|
|
|
|
private:
|
|
|
bool ai_callback; ///< Callback comes from the AI.
|
|
|
};
|
|
|
|
|
|
|
|
|
/** Resolver object for generic objects/properties. */
|
|
|
struct GenericResolverObject : public ResolverObject {
|
|
|
GenericScopeResolver generic_scope;
|
|
|
|
|
|
GenericResolverObject(bool ai_callback, CallbackID callback = CBID_NO_CALLBACK);
|
|
|
|
|
|
/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
|
|
|
ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
|
|
|
{
|
|
|
switch (scope) {
|
|
|
case VSG_SCOPE_SELF: return &this->generic_scope;
|
|
|
default: return ResolverObject::GetScope(scope, relative);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
|
|
|
const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
|
|
|
};
|
|
|
|
|
|
struct GenericCallback {
|
|
|
const GRFFile *file;
|
|
|
const SpriteGroup *group;
|
|
|
|
|
|
GenericCallback(const GRFFile *file, const SpriteGroup *group) :
|
|
|
file(file),
|
|
|
group(group)
|
|
|
{ }
|
|
|
};
|
|
|
|
|
|
typedef std::list<GenericCallback> GenericCallbackList;
|
|
|
|
|
|
static GenericCallbackList _gcl[GSF_END];
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Reset all generic feature callback sprite groups.
|
|
|
*/
|
|
|
void ResetGenericCallbacks()
|
|
|
{
|
|
|
for (uint8 feature = 0; feature < lengthof(_gcl); feature++) {
|
|
|
_gcl[feature].clear();
|