summaryrefslogtreecommitdiff
path: root/src/newgrf_station.h
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2012-11-10 20:41:08 +0000
committeralberth <alberth@openttd.org>2012-11-10 20:41:08 +0000
commitc417efc962a2d452bf52842b615bf3e09ecef7d6 (patch)
tree0b852206cf2bd7dc51285746fe7b8241f458d032 /src/newgrf_station.h
parenta9b8b22daf38be899b5fd13e8028b7a9e5f5bcfc (diff)
downloadopenttd-c417efc962a2d452bf52842b615bf3e09ecef7d6.tar.xz
(svn r24684) -Codechange: Add resolver classes for stations.
Diffstat (limited to 'src/newgrf_station.h')
-rw-r--r--src/newgrf_station.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/newgrf_station.h b/src/newgrf_station.h
index 9f31431d2..c2934700a 100644
--- a/src/newgrf_station.h
+++ b/src/newgrf_station.h
@@ -19,6 +19,54 @@
#include "cargo_type.h"
#include "station_type.h"
#include "rail_type.h"
+#include "newgrf_spritegroup.h"
+#include "newgrf_town.h"
+
+struct StationScopeResolver : public ScopeResolver {
+ TileIndex tile;
+ struct BaseStation *st;
+ const struct StationSpec *statspec;
+ CargoID cargo_type;
+ Axis axis; ///< Station axis, used only for the slope check callback.
+
+ StationScopeResolver(ResolverObject *ro, const StationSpec *statspec, BaseStation *st, TileIndex tile);
+
+ /* virtual */ uint32 GetRandomBits() const;
+ /* virtual */ uint32 GetTriggers() const;
+ /* virtual */ void SetTriggers(int triggers) const;
+
+ /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
+};
+
+struct StationResolverObject : public ResolverObject {
+ StationScopeResolver station_scope;
+ TownScopeResolver *town_scope;
+
+ StationResolverObject(const StationSpec *statspec, BaseStation *st, TileIndex tile,
+ CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
+ ~StationResolverObject();
+
+ TownScopeResolver *GetTown();
+
+ /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
+ {
+ switch (scope) {
+ case VSG_SCOPE_SELF:
+ return &this->station_scope;
+
+ case VSG_SCOPE_PARENT: {
+ TownScopeResolver *tsr = this->GetTown();
+ if (tsr != NULL) return tsr;
+ /* FALL-THROUGH */
+ }
+
+ default:
+ return &this->default_scope; // XXX ResolverObject::GetScope(scope, relative);
+ }
+ }
+
+ /* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
+};
enum StationClassID {
STAT_CLASS_BEGIN = 0, ///< the lowest valid value