summaryrefslogtreecommitdiff
path: root/src/newgrf_industries.h
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2012-11-10 20:44:10 +0000
committeralberth <alberth@openttd.org>2012-11-10 20:44:10 +0000
commitf7352871fab18f1517df2c1e08abe13d3caacb96 (patch)
treeaf8636b2b93e614cbd130d11292cdb87d0a659de /src/newgrf_industries.h
parent348ef7f12c4ed2cfa7dd6bcbbf34a920e79dafc1 (diff)
downloadopenttd-f7352871fab18f1517df2c1e08abe13d3caacb96.tar.xz
(svn r24689) -Codechange: Add resolver classes for industries.
Diffstat (limited to 'src/newgrf_industries.h')
-rw-r--r--src/newgrf_industries.h43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/newgrf_industries.h b/src/newgrf_industries.h
index 370dd97e2..acc74ee8e 100644
--- a/src/newgrf_industries.h
+++ b/src/newgrf_industries.h
@@ -12,7 +12,48 @@
#ifndef NEWGRF_INDUSTRIES_H
#define NEWGRF_INDUSTRIES_H
-#include "newgrf_spritegroup.h"
+#include "newgrf_town.h"
+
+struct IndustriesScopeResolver : public ScopeResolver {
+ TileIndex tile;
+ Industry *industry;
+ IndustryType type;
+ uint32 random_bits; ///< Random bits of the new industry.
+
+ IndustriesScopeResolver(ResolverObject *ro, TileIndex tile, Industry *industry, IndustryType type, uint32 random_bits = 0);
+
+ /* virtual */ uint32 GetRandomBits() const;
+ /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
+ /* virtual */ uint32 GetTriggers() const;
+ /* virtual */ void SetTriggers(int triggers) const;
+ /* virtual */ void StorePSA(uint pos, int32 value);
+};
+
+struct IndustriesResolverObject : public ResolverObject {
+ IndustriesScopeResolver industries_scope;
+ TownScopeResolver *town_scope;
+
+ IndustriesResolverObject(TileIndex tile, Industry *indus, IndustryType type, uint32 random_bits = 0,
+ CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
+ ~IndustriesResolverObject();
+
+ TownScopeResolver *GetTown();
+
+ /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
+ {
+ switch (scope) {
+ case VSG_SCOPE_SELF: return &industries_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;
+};
/** When should the industry(tile) be triggered for random bits? */
enum IndustryTrigger {