diff options
author | alberth <alberth@openttd.org> | 2012-11-10 20:40:05 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2012-11-10 20:40:05 +0000 |
commit | d7b62da87b5123907df008fffa8f21377c394358 (patch) | |
tree | 5fdf926ee465cfc99442f4a7c7313b2937eb1654 /src/newgrf_house.h | |
parent | 0885a2370a45982a01abf314fc035c5a41ba6cfe (diff) | |
download | openttd-d7b62da87b5123907df008fffa8f21377c394358.tar.xz |
(svn r24682) -Codechange: Add resolver classes for houses.
Diffstat (limited to 'src/newgrf_house.h')
-rw-r--r-- | src/newgrf_house.h | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/newgrf_house.h b/src/newgrf_house.h index cdb184b5c..7986f114e 100644 --- a/src/newgrf_house.h +++ b/src/newgrf_house.h @@ -15,6 +15,46 @@ #include "newgrf_callbacks.h" #include "tile_cmd.h" #include "house_type.h" +#include "newgrf_spritegroup.h" +#include "newgrf_town.h" + +struct HouseScopeResolver : public ScopeResolver { + HouseID house_id; + TileIndex tile; + Town *town; ///< Town of this house. + bool not_yet_constructed; ///< True for construction check. + uint16 initial_random_bits; ///< Random bits during construction checks. + uint32 watched_cargo_triggers; ///< Cargo types that triggered the watched cargo callback. + + HouseScopeResolver(ResolverObject *ro, HouseID house_id, TileIndex tile, Town *town, + bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers); + + /* virtual */ uint32 GetRandomBits() const; + /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const; + /* virtual */ uint32 GetTriggers() const; + /* virtual */ void SetTriggers(int triggers) const; +}; + +/** Resolver object to be used for houses (feature 07 spritegroups). */ +struct HouseResolverObject : public ResolverObject { + HouseScopeResolver house_scope; + TownScopeResolver town_scope; + + HouseResolverObject(HouseID house_id, TileIndex tile, Town *town, + CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0, + bool not_yet_constructed = false, uint8 initial_random_bits = 0, uint32 watched_cargo_triggers = 0); + + /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) + { + switch (scope) { + case VSG_SCOPE_SELF: return &this->house_scope; + case VSG_SCOPE_PARENT: return &this->town_scope; + default: return &this->default_scope; // XXX ResolverObject::GetScope(scope, relative); + } + } + + /* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const; +}; /** * Makes class IDs unique to each GRF file. @@ -44,7 +84,8 @@ void DrawNewHouseTile(TileInfo *ti, HouseID house_id); void AnimateNewHouseTile(TileIndex tile); void AnimateNewHouseConstruction(TileIndex tile); -uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile, bool not_yet_constructed = false, uint8 initial_random_bits = 0, uint32 watched_cargo_triggers = 0); +uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile, + bool not_yet_constructed = false, uint8 initial_random_bits = 0, uint32 watched_cargo_triggers = 0); void WatchedCargoCallback(TileIndex tile, uint32 trigger_cargoes); bool CanDeleteHouse(TileIndex tile); |