OpenTTD
newgrf_house.h
Go to the documentation of this file.
1 /* $Id: newgrf_house.h 26085 2013-11-24 14:41:19Z frosch $ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8  */
9 
12 #ifndef NEWGRF_HOUSE_H
13 #define NEWGRF_HOUSE_H
14 
15 #include "newgrf_callbacks.h"
16 #include "tile_cmd.h"
17 #include "house_type.h"
18 #include "newgrf_spritegroup.h"
19 #include "newgrf_town.h"
20 
29 
32 
33  /* virtual */ uint32 GetRandomBits() const;
34  /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
35  /* virtual */ uint32 GetTriggers() const;
36  /* virtual */ void SetTriggers(int triggers) const;
37 };
38 
41  HouseScopeResolver house_scope;
42  TownScopeResolver town_scope;
43 
44  HouseResolverObject(HouseID house_id, TileIndex tile, Town *town,
45  CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0,
46  bool not_yet_constructed = false, uint8 initial_random_bits = 0, uint32 watched_cargo_triggers = 0);
47 
48  /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
49  {
50  switch (scope) {
51  case VSG_SCOPE_SELF: return &this->house_scope;
52  case VSG_SCOPE_PARENT: return &this->town_scope;
53  default: return ResolverObject::GetScope(scope, relative);
54  }
55  }
56 };
57 
72  uint32 grfid;
73  uint8 class_id;
74 };
75 
76 HouseClassID AllocateHouseClassID(byte grf_class_id, uint32 grfid);
77 
78 void InitializeBuildingCounts();
79 void IncreaseBuildingCount(Town *t, HouseID house_id);
80 void DecreaseBuildingCount(Town *t, HouseID house_id);
81 
82 void DrawNewHouseTile(TileInfo *ti, HouseID house_id);
83 void AnimateNewHouseTile(TileIndex tile);
84 void AnimateNewHouseConstruction(TileIndex tile);
85 
86 uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile,
87  bool not_yet_constructed = false, uint8 initial_random_bits = 0, uint32 watched_cargo_triggers = 0);
88 void WatchedCargoCallback(TileIndex tile, uint32 trigger_cargoes);
89 
90 bool CanDeleteHouse(TileIndex tile);
91 
92 bool NewHouseTileLoop(TileIndex tile);
93 
94 enum HouseTrigger {
95  /* The tile of the house has been triggered during the tileloop. */
96  HOUSE_TRIGGER_TILE_LOOP = 0x01,
97  /*
98  * The top tile of a (multitile) building has been triggered during and all
99  * the tileloop other tiles of the same building get the same random value.
100  */
101  HOUSE_TRIGGER_TILE_LOOP_TOP = 0x02,
102 };
103 void TriggerHouse(TileIndex t, HouseTrigger trigger);
104 
105 #endif /* NEWGRF_HOUSE_H */