File diff r23496:661d21df67d7 → r23497:a0ab44ebd2fa
src/newgrf_object.h
Show inline comments
 
@@ -95,62 +95,62 @@ struct ObjectSpec {
 
	uint Index() const;
 

	
 
	static const ObjectSpec *Get(ObjectType index);
 
	static const ObjectSpec *GetByTile(TileIndex tile);
 
};
 

	
 
/** Object scope resolver. */
 
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.
 

	
 
	/**
 
	 * Constructor of an object scope resolver.
 
	 * @param ro Surrounding resolver.
 
	 * @param obj Object being resolved.
 
	 * @param tile %Tile of the object.
 
	 * @param view View of the object.
 
	 */
 
	ObjectScopeResolver(ResolverObject &ro, Object *obj, TileIndex tile, uint8 view = 0)
 
		: ScopeResolver(ro), obj(obj), tile(tile), view(view)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 
	uint32 GetRandomBits() const override;
 
	uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
 
};
 

	
 
/** A resolver object to be used with feature 0F spritegroups. */
 
struct ObjectResolverObject : public ResolverObject {
 
	ObjectScopeResolver object_scope; ///< The object scope resolver.
 
	TownScopeResolver *town_scope;    ///< The town scope resolver (created on the first call).
 

	
 
	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)
 
	ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
 
	{
 
		switch (scope) {
 
			case VSG_SCOPE_SELF:
 
				return &this->object_scope;
 

	
 
			case VSG_SCOPE_PARENT: {
 
				TownScopeResolver *tsr = this->GetTown();
 
				if (tsr != NULL) return tsr;
 
				FALLTHROUGH;
 
			}
 

	
 
			default:
 
				return ResolverObject::GetScope(scope, relative);
 
		}
 
	}
 

	
 
private:
 
	TownScopeResolver *GetTown();
 
};
 

	
 
/** Struct containing information relating to object classes. */
 
typedef NewGRFClass<ObjectSpec, ObjectClassID, OBJECT_CLASS_MAX> ObjectClass;
 

	
 
/** Mapping of purchase for objects. */