Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef NEWGRF_HOUSE_H
00013 #define NEWGRF_HOUSE_H
00014
00015 #include "newgrf_callbacks.h"
00016 #include "tile_cmd.h"
00017 #include "house_type.h"
00018 #include "newgrf_spritegroup.h"
00019 #include "newgrf_town.h"
00020
00022 struct HouseScopeResolver : public ScopeResolver {
00023 HouseID house_id;
00024 TileIndex tile;
00025 Town *town;
00026 bool not_yet_constructed;
00027 uint16 initial_random_bits;
00028 uint32 watched_cargo_triggers;
00029
00030 HouseScopeResolver(ResolverObject &ro, HouseID house_id, TileIndex tile, Town *town,
00031 bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers);
00032
00033 uint32 GetRandomBits() const;
00034 uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
00035 uint32 GetTriggers() const;
00036 void SetTriggers(int triggers) const;
00037 };
00038
00040 struct HouseResolverObject : public ResolverObject {
00041 HouseScopeResolver house_scope;
00042 TownScopeResolver town_scope;
00043
00044 HouseResolverObject(HouseID house_id, TileIndex tile, Town *town,
00045 CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0,
00046 bool not_yet_constructed = false, uint8 initial_random_bits = 0, uint32 watched_cargo_triggers = 0);
00047
00048 ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
00049 {
00050 switch (scope) {
00051 case VSG_SCOPE_SELF: return &this->house_scope;
00052 case VSG_SCOPE_PARENT: return &this->town_scope;
00053 default: return ResolverObject::GetScope(scope, relative);
00054 }
00055 }
00056 };
00057
00071 struct HouseClassMapping {
00072 uint32 grfid;
00073 uint8 class_id;
00074 };
00075
00076 HouseClassID AllocateHouseClassID(byte grf_class_id, uint32 grfid);
00077
00078 void InitializeBuildingCounts();
00079 void IncreaseBuildingCount(Town *t, HouseID house_id);
00080 void DecreaseBuildingCount(Town *t, HouseID house_id);
00081
00082 void DrawNewHouseTile(TileInfo *ti, HouseID house_id);
00083 void AnimateNewHouseTile(TileIndex tile);
00084 void AnimateNewHouseConstruction(TileIndex tile);
00085
00086 uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile,
00087 bool not_yet_constructed = false, uint8 initial_random_bits = 0, uint32 watched_cargo_triggers = 0);
00088 void WatchedCargoCallback(TileIndex tile, uint32 trigger_cargoes);
00089
00090 bool CanDeleteHouse(TileIndex tile);
00091
00092 bool NewHouseTileLoop(TileIndex tile);
00093
00094 enum HouseTrigger {
00095
00096 HOUSE_TRIGGER_TILE_LOOP = 0x01,
00097
00098
00099
00100
00101 HOUSE_TRIGGER_TILE_LOOP_TOP = 0x02,
00102 };
00103 void TriggerHouse(TileIndex t, HouseTrigger trigger);
00104
00105 #endif