summaryrefslogtreecommitdiff
path: root/src/newgrf_object.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/newgrf_object.h')
-rw-r--r--src/newgrf_object.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/newgrf_object.h b/src/newgrf_object.h
index bc2f64f3c..c1b79959d 100644
--- a/src/newgrf_object.h
+++ b/src/newgrf_object.h
@@ -13,6 +13,8 @@
#define NEWGRF_OBJECT_H
#include "newgrf_callbacks.h"
+#include "newgrf_spritegroup.h"
+#include "newgrf_town.h"
#include "economy_func.h"
#include "date_type.h"
#include "object_type.h"
@@ -90,6 +92,48 @@ struct ObjectSpec {
static const ObjectSpec *GetByTile(TileIndex tile);
};
+struct ObjectScopeResolver : public ScopeResolver {
+ struct Object *obj; ///< The object the callback is ran for.
+ TileIndex tile; ///< The tile related to the object.
+ uint8 view; ///< The view of the object.
+
+ ObjectScopeResolver(ResolverObject *ro, Object *obj, TileIndex tile, uint8 view = 0);
+
+ /* virtual */ uint32 GetRandomBits() const;
+ /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
+};
+
+/** A resolver object to be used with feature 0F spritegroups. */
+struct ObjectResolverObject : public ResolverObject {
+ ObjectScopeResolver object_scope;
+ TownScopeResolver *town_scope;
+
+ ObjectResolverObject(const ObjectSpec *spec, Object *o, TileIndex tile, uint8 view = 0,
+ CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0);
+ ~ObjectResolverObject();
+
+ /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
+ {
+ switch (scope) {
+ case VSG_SCOPE_SELF:
+ return &this->object_scope;
+
+ case VSG_SCOPE_PARENT: {
+ TownScopeResolver *tsr = this->GetTown();
+ if (tsr != NULL) return tsr;
+ /* FALL-THROUGH */
+ }
+
+ default: return &this->default_scope; // XXX return &ResolverObject::GetScope(scope, relative);
+ }
+ }
+
+ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
+
+private:
+ TownScopeResolver *GetTown();
+};
+
/** Struct containing information relating to station classes. */
typedef NewGRFClass<ObjectSpec, ObjectClassID, OBJECT_CLASS_MAX> ObjectClass;