author | rubidium |
Sun, 22 Jun 2008 21:41:03 +0000 | |
branch | noai |
changeset 11053 | d8d48e076a3f |
parent 11044 | 097ea3e7ec56 |
child 11126 | 72d4c9314c72 |
permissions | -rw-r--r-- |
9476 | 1 |
/* $Id$ */ |
2 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
3 |
/** @file newgrf_house.cpp Implementation of NewGRF houses. */ |
9476 | 4 |
|
5 |
#include "stdafx.h" |
|
6 |
#include "openttd.h" |
|
7 |
#include "variables.h" |
|
8 |
#include "debug.h" |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
9 |
#include "viewport_func.h" |
9505 | 10 |
#include "landscape.h" |
9476 | 11 |
#include "town.h" |
12 |
#include "town_map.h" |
|
13 |
#include "sprite.h" |
|
14 |
#include "newgrf.h" |
|
15 |
#include "newgrf_house.h" |
|
16 |
#include "newgrf_spritegroup.h" |
|
17 |
#include "newgrf_callbacks.h" |
|
18 |
#include "newgrf_town.h" |
|
19 |
#include "newgrf_sound.h" |
|
9624 | 20 |
#include "newgrf_commons.h" |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
21 |
#include "transparency.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
22 |
#include "functions.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
23 |
#include "player_func.h" |
10294 | 24 |
#include "animated_tile_func.h" |
25 |
#include "date_func.h" |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
26 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
27 |
#include "table/strings.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
28 |
#include "table/sprites.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
29 |
#include "table/town_land.h" |
9476 | 30 |
|
31 |
static BuildingCounts _building_counts; |
|
32 |
static HouseClassMapping _class_mapping[HOUSE_CLASS_MAX]; |
|
33 |
||
9624 | 34 |
HouseOverrideManager _house_mngr(NEW_HOUSE_OFFSET, HOUSE_MAX, INVALID_HOUSE_ID); |
9476 | 35 |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
36 |
/** |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
37 |
* Check and update town and house values. |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
38 |
* |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
39 |
* Checked are the HouseIDs. Updated are the |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
40 |
* town population the number of houses per |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
41 |
* town, the town radius and the max passengers |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
42 |
* of the town. |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
43 |
*/ |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
44 |
void UpdateHousesAndTowns() |
9476 | 45 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
46 |
Town *town; |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
47 |
InitializeBuildingCounts(); |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
48 |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
49 |
/* Reset town population and num_houses */ |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
50 |
FOR_ALL_TOWNS(town) { |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
51 |
town->population = 0; |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
52 |
town->num_houses = 0; |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
53 |
} |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
54 |
|
9476 | 55 |
for (TileIndex t = 0; t < MapSize(); t++) { |
56 |
HouseID house_id; |
|
57 |
||
58 |
if (!IsTileType(t, MP_HOUSE)) continue; |
|
59 |
||
60 |
house_id = GetHouseType(t); |
|
61 |
if (!GetHouseSpecs(house_id)->enabled && house_id >= NEW_HOUSE_OFFSET) { |
|
62 |
/* The specs for this type of house are not available any more, so |
|
63 |
* replace it with the substitute original house type. */ |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
64 |
house_id = _house_mngr.GetSubstituteID(house_id); |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
65 |
SetHouseType(t, house_id); |
9476 | 66 |
} |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
67 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
68 |
town = GetTownByTile(t); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
69 |
IncreaseBuildingCount(town, house_id); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
70 |
if (IsHouseCompleted(t)) town->population += GetHouseSpecs(house_id)->population; |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
71 |
|
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
72 |
/* Increase the number of houses for every house tile which |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
73 |
* has a size bit set. Multi tile buildings have got only |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
74 |
* one tile with such a bit set, so there is no problem. */ |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
75 |
if (GetHouseSpecs(GetHouseType(t))->building_flags & BUILDING_HAS_1_TILE) { |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
76 |
town->num_houses++; |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
77 |
} |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
78 |
} |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
79 |
|
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
80 |
/* Update the population and num_house dependant values */ |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
81 |
FOR_ALL_TOWNS(town) { |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
82 |
UpdateTownRadius(town); |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
83 |
UpdateTownMaxPass(town); |
9476 | 84 |
} |
85 |
} |
|
86 |
||
87 |
HouseClassID AllocateHouseClassID(byte grf_class_id, uint32 grfid) |
|
88 |
{ |
|
89 |
/* Start from 1 because 0 means that no class has been assigned. */ |
|
90 |
for (int i = 1; i != lengthof(_class_mapping); i++) { |
|
91 |
HouseClassMapping *map = &_class_mapping[i]; |
|
92 |
||
93 |
if (map->class_id == grf_class_id && map->grfid == grfid) return (HouseClassID)i; |
|
94 |
||
95 |
if (map->class_id == 0 && map->grfid == 0) { |
|
96 |
map->class_id = grf_class_id; |
|
97 |
map->grfid = grfid; |
|
98 |
return (HouseClassID)i; |
|
99 |
} |
|
100 |
} |
|
101 |
return HOUSE_NO_CLASS; |
|
102 |
} |
|
103 |
||
104 |
void InitializeBuildingCounts() |
|
105 |
{ |
|
106 |
memset(&_building_counts, 0, sizeof(_building_counts)); |
|
107 |
} |
|
108 |
||
109 |
/** |
|
110 |
* IncreaseBuildingCount() |
|
111 |
* Increase the count of a building when it has been added by a town. |
|
112 |
* @param t The town that the building is being built in |
|
113 |
* @param house_id The id of the house being added |
|
114 |
*/ |
|
115 |
void IncreaseBuildingCount(Town *t, HouseID house_id) |
|
116 |
{ |
|
117 |
HouseClassID class_id = GetHouseSpecs(house_id)->class_id; |
|
118 |
||
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9626
diff
changeset
|
119 |
if (!_loaded_newgrf_features.has_newhouses) return; |
9476 | 120 |
|
121 |
/* If there are 255 buildings of this type in this town, there are also |
|
122 |
* at least that many houses of the same class in the town, and |
|
123 |
* therefore on the map as well. */ |
|
124 |
if (t->building_counts.id_count[house_id] == 255) return; |
|
125 |
||
126 |
t->building_counts.id_count[house_id]++; |
|
127 |
if (_building_counts.id_count[house_id] < 255) _building_counts.id_count[house_id]++; |
|
128 |
||
129 |
/* Similarly, if there are 255 houses of this class in this town, there |
|
130 |
* must be at least that number on the map too. */ |
|
131 |
if (class_id == HOUSE_NO_CLASS || t->building_counts.class_count[class_id] == 255) return; |
|
132 |
||
133 |
t->building_counts.class_count[class_id]++; |
|
134 |
if (_building_counts.class_count[class_id] < 255) _building_counts.class_count[class_id]++; |
|
135 |
} |
|
136 |
||
137 |
/** |
|
138 |
* DecreaseBuildingCount() |
|
139 |
* Decrease the number of a building when it is deleted. |
|
140 |
* @param t The town that the building was built in |
|
141 |
* @param house_id The id of the house being removed |
|
142 |
*/ |
|
143 |
void DecreaseBuildingCount(Town *t, HouseID house_id) |
|
144 |
{ |
|
145 |
HouseClassID class_id = GetHouseSpecs(house_id)->class_id; |
|
146 |
||
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9626
diff
changeset
|
147 |
if (!_loaded_newgrf_features.has_newhouses) return; |
9476 | 148 |
|
149 |
if (t->building_counts.id_count[house_id] > 0) t->building_counts.id_count[house_id]--; |
|
150 |
if (_building_counts.id_count[house_id] > 0) _building_counts.id_count[house_id]--; |
|
151 |
||
152 |
if (class_id == HOUSE_NO_CLASS) return; |
|
153 |
||
154 |
if (t->building_counts.class_count[class_id] > 0) t->building_counts.class_count[class_id]--; |
|
155 |
if (_building_counts.class_count[class_id] > 0) _building_counts.class_count[class_id]--; |
|
156 |
} |
|
157 |
||
158 |
static uint32 HouseGetRandomBits(const ResolverObject *object) |
|
159 |
{ |
|
160 |
const TileIndex tile = object->u.house.tile; |
|
161 |
return (tile == INVALID_TILE || !IsTileType(tile, MP_HOUSE)) ? 0 : GetHouseRandomBits(tile); |
|
162 |
} |
|
163 |
||
164 |
static uint32 HouseGetTriggers(const ResolverObject *object) |
|
165 |
{ |
|
166 |
const TileIndex tile = object->u.house.tile; |
|
167 |
return (tile == INVALID_TILE || !IsTileType(tile, MP_HOUSE)) ? 0 : GetHouseTriggers(tile); |
|
168 |
} |
|
169 |
||
170 |
static void HouseSetTriggers(const ResolverObject *object, int triggers) |
|
171 |
{ |
|
172 |
const TileIndex tile = object->u.house.tile; |
|
173 |
if (IsTileType(tile, MP_HOUSE)) SetHouseTriggers(tile, triggers); |
|
174 |
} |
|
175 |
||
176 |
static uint32 GetNumHouses(HouseID house_id, const Town *town) |
|
177 |
{ |
|
178 |
uint8 map_id_count, town_id_count, map_class_count, town_class_count; |
|
179 |
HouseClassID class_id = GetHouseSpecs(house_id)->class_id; |
|
180 |
||
181 |
map_id_count = _building_counts.id_count[house_id]; |
|
182 |
map_class_count = _building_counts.class_count[class_id]; |
|
183 |
town_id_count = town->building_counts.id_count[house_id]; |
|
184 |
town_class_count = town->building_counts.class_count[class_id]; |
|
185 |
||
186 |
return map_class_count << 24 | town_class_count << 16 | map_id_count << 8 | town_id_count; |
|
187 |
} |
|
188 |
||
189 |
static uint32 GetGRFParameter(HouseID house_id, byte parameter) |
|
190 |
{ |
|
191 |
const HouseSpec *hs = GetHouseSpecs(house_id); |
|
192 |
const GRFFile *file = hs->grffile; |
|
193 |
||
194 |
if (parameter >= file->param_end) return 0; |
|
195 |
return file->param[parameter]; |
|
196 |
} |
|
197 |
||
9626 | 198 |
uint32 GetNearbyTileInformation(byte parameter, TileIndex tile) |
199 |
{ |
|
200 |
tile = GetNearbyTile(parameter, tile); |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
201 |
return GetNearbyTileInformation(tile); |
9626 | 202 |
} |
203 |
||
9476 | 204 |
/** |
205 |
* HouseGetVariable(): |
|
206 |
* |
|
207 |
* Used by the resolver to get values for feature 07 deterministic spritegroups. |
|
208 |
*/ |
|
209 |
static uint32 HouseGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) |
|
210 |
{ |
|
211 |
const Town *town = object->u.house.town; |
|
212 |
TileIndex tile = object->u.house.tile; |
|
213 |
HouseID house_id = object->u.house.house_id; |
|
214 |
||
215 |
if (object->scope == VSG_SCOPE_PARENT) { |
|
216 |
return TownGetVariable(variable, parameter, available, town); |
|
217 |
} |
|
218 |
||
219 |
switch (variable) { |
|
220 |
/* Construction stage. */ |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
221 |
case 0x40: return (IsTileType(tile, MP_HOUSE) ? GetHouseBuildingStage(tile) : 0) | TileHash2Bit(TileX(tile), TileY(tile)) << 2; |
9476 | 222 |
|
223 |
/* Building age. */ |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
224 |
case 0x41: return Clamp(_cur_year - GetHouseConstructionYear(tile), 0, 0xFF); |
9476 | 225 |
|
226 |
/* Town zone */ |
|
227 |
case 0x42: return GetTownRadiusGroup(town, tile); |
|
228 |
||
229 |
/* Terrain type */ |
|
230 |
case 0x43: return GetTerrainType(tile); |
|
231 |
||
232 |
/* Number of this type of building on the map. */ |
|
233 |
case 0x44: return GetNumHouses(house_id, town); |
|
234 |
||
235 |
/* Whether the town is being created or just expanded. */ |
|
236 |
case 0x45: return _generating_world ? 1 : 0; |
|
237 |
||
238 |
/* Current animation frame. */ |
|
239 |
case 0x46: return IsTileType(tile, MP_HOUSE) ? GetHouseAnimationFrame(tile) : 0; |
|
240 |
||
241 |
||
242 |
/* Building counts for old houses with id = parameter. */ |
|
243 |
case 0x60: return GetNumHouses(parameter, town); |
|
244 |
||
245 |
/* Building counts for new houses with id = parameter. */ |
|
246 |
case 0x61: { |
|
247 |
const HouseSpec *hs = GetHouseSpecs(house_id); |
|
248 |
if (hs->grffile == NULL) return 0; |
|
249 |
||
9624 | 250 |
HouseID new_house = _house_mngr.GetID(parameter, hs->grffile->grfid); |
9476 | 251 |
return new_house == INVALID_HOUSE_ID ? 0 : GetNumHouses(new_house, town); |
252 |
} |
|
253 |
||
254 |
/* Land info for nearby tiles. */ |
|
9626 | 255 |
case 0x62: return GetNearbyTileInformation(parameter, tile); |
9476 | 256 |
|
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10455
diff
changeset
|
257 |
/* Current animation frame of nearby house tiles */ |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10455
diff
changeset
|
258 |
case 0x63: { |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10455
diff
changeset
|
259 |
TileIndex testtile = GetNearbyTile(parameter, tile); |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10455
diff
changeset
|
260 |
return IsTileType(testtile, MP_HOUSE) ? GetHouseAnimationFrame(testtile) : 0; |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10455
diff
changeset
|
261 |
} |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10455
diff
changeset
|
262 |
|
9476 | 263 |
/* Read GRF parameter */ |
264 |
case 0x7F: return GetGRFParameter(object->u.house.house_id, parameter); |
|
265 |
} |
|
266 |
||
267 |
DEBUG(grf, 1, "Unhandled house property 0x%X", variable); |
|
268 |
||
269 |
*available = false; |
|
270 |
return UINT_MAX; |
|
271 |
} |
|
272 |
||
273 |
static const SpriteGroup *HouseResolveReal(const ResolverObject *object, const SpriteGroup *group) |
|
274 |
{ |
|
275 |
/* Houses do not have 'real' groups */ |
|
276 |
return NULL; |
|
277 |
} |
|
278 |
||
279 |
/** |
|
280 |
* NewHouseResolver(): |
|
281 |
* |
|
282 |
* Returns a resolver object to be used with feature 07 spritegroups. |
|
283 |
*/ |
|
284 |
static void NewHouseResolver(ResolverObject *res, HouseID house_id, TileIndex tile, Town *town) |
|
285 |
{ |
|
286 |
res->GetRandomBits = HouseGetRandomBits; |
|
287 |
res->GetTriggers = HouseGetTriggers; |
|
288 |
res->SetTriggers = HouseSetTriggers; |
|
289 |
res->GetVariable = HouseGetVariable; |
|
290 |
res->ResolveReal = HouseResolveReal; |
|
291 |
||
292 |
res->u.house.tile = tile; |
|
293 |
res->u.house.town = town; |
|
294 |
res->u.house.house_id = house_id; |
|
295 |
||
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9628
diff
changeset
|
296 |
res->callback = CBID_NO_CALLBACK; |
9476 | 297 |
res->callback_param1 = 0; |
298 |
res->callback_param2 = 0; |
|
299 |
res->last_value = 0; |
|
300 |
res->trigger = 0; |
|
301 |
res->reseed = 0; |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
302 |
res->count = 0; |
9476 | 303 |
} |
304 |
||
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9628
diff
changeset
|
305 |
uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile) |
9476 | 306 |
{ |
307 |
ResolverObject object; |
|
308 |
const SpriteGroup *group; |
|
309 |
||
310 |
NewHouseResolver(&object, house_id, tile, town); |
|
311 |
object.callback = callback; |
|
312 |
object.callback_param1 = param1; |
|
9624 | 313 |
object.callback_param2 = param2; |
9476 | 314 |
|
315 |
group = Resolve(GetHouseSpecs(house_id)->spritegroup, &object); |
|
316 |
if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED; |
|
317 |
||
318 |
return group->g.callback.result; |
|
319 |
} |
|
320 |
||
321 |
void DrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte stage, HouseID house_id) |
|
322 |
{ |
|
323 |
const DrawTileSprites *dts = group->g.layout.dts; |
|
324 |
const DrawTileSeqStruct *dtss; |
|
325 |
||
9732 | 326 |
SpriteID image = dts->ground.sprite; |
327 |
SpriteID pal = dts->ground.pal; |
|
9476 | 328 |
|
9704 | 329 |
if (IS_CUSTOM_SPRITE(image)) image += stage; |
330 |
||
9476 | 331 |
if (GB(image, 0, SPRITE_WIDTH) != 0) DrawGroundSprite(image, pal); |
332 |
||
333 |
foreach_draw_tile_seq(dtss, dts->seq) { |
|
9732 | 334 |
if (GB(dtss->image.sprite, 0, SPRITE_WIDTH) == 0) continue; |
9476 | 335 |
|
9732 | 336 |
image = dtss->image.sprite; |
337 |
pal = dtss->image.pal; |
|
9476 | 338 |
|
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10455
diff
changeset
|
339 |
/* Stop drawing sprite sequence once we meet a sprite that doesn't have to be opaque */ |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10455
diff
changeset
|
340 |
if (IsInvisibilitySet(TO_HOUSES) && !HasBit(image, SPRITE_MODIFIER_OPAQUE)) return; |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10455
diff
changeset
|
341 |
|
9704 | 342 |
if (IS_CUSTOM_SPRITE(image)) image += stage; |
343 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
344 |
if ((HasBit(image, SPRITE_MODIFIER_OPAQUE) || !IsTransparencySet(TO_HOUSES)) && HasBit(image, PALETTE_MODIFIER_COLOR)) { |
9476 | 345 |
if (pal == 0) { |
346 |
const HouseSpec *hs = GetHouseSpecs(house_id); |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
347 |
if (HasBit(hs->callback_mask, CBM_HOUSE_COLOUR)) { |
9704 | 348 |
uint16 callback = GetHouseCallback(CBID_HOUSE_COLOUR, 0, 0, house_id, GetTownByTile(ti->tile), ti->tile); |
9476 | 349 |
if (callback != CALLBACK_FAILED) { |
350 |
/* If bit 14 is set, we should use a 2cc colour map, else use the callback value. */ |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
351 |
pal = HasBit(callback, 14) ? GB(callback, 0, 8) + SPR_2CCMAP_BASE : callback; |
9476 | 352 |
} |
353 |
} else { |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
354 |
pal = hs->random_colour[TileHash2Bit(ti->x, ti->y)] + PALETTE_RECOLOR_START; |
9476 | 355 |
} |
356 |
} |
|
357 |
} else { |
|
358 |
pal = PAL_NONE; |
|
359 |
} |
|
360 |
||
361 |
if ((byte)dtss->delta_z != 0x80) { |
|
362 |
AddSortableSpriteToDraw( |
|
363 |
image, pal, |
|
364 |
ti->x + dtss->delta_x, ti->y + dtss->delta_y, |
|
365 |
dtss->size_x, dtss->size_y, |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9628
diff
changeset
|
366 |
dtss->size_z, ti->z + dtss->delta_z, |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
367 |
IsTransparencySet(TO_HOUSES) |
9476 | 368 |
); |
369 |
} else { |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
370 |
AddChildSpriteScreen(image, pal, (byte)dtss->delta_x, (byte)dtss->delta_y, IsTransparencySet(TO_HOUSES)); |
9476 | 371 |
} |
372 |
} |
|
373 |
} |
|
374 |
||
375 |
void DrawNewHouseTile(TileInfo *ti, HouseID house_id) |
|
376 |
{ |
|
377 |
const HouseSpec *hs = GetHouseSpecs(house_id); |
|
378 |
const SpriteGroup *group; |
|
379 |
ResolverObject object; |
|
380 |
||
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9628
diff
changeset
|
381 |
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED); |
9476 | 382 |
|
383 |
NewHouseResolver(&object, house_id, ti->tile, GetTownByTile(ti->tile)); |
|
384 |
||
385 |
group = Resolve(hs->spritegroup, &object); |
|
386 |
if (group == NULL || group->type != SGT_TILELAYOUT) { |
|
387 |
/* XXX: This is for debugging purposes really, and shouldn't stay. */ |
|
388 |
DrawGroundSprite(SPR_SHADOW_CELL, PAL_NONE); |
|
389 |
} else { |
|
390 |
/* Limit the building stage to the number of stages supplied. */ |
|
391 |
byte stage = GetHouseBuildingStage(ti->tile); |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
392 |
stage = Clamp(stage - 4 + group->g.layout.num_sprites, 0, group->g.layout.num_sprites - 1); |
9476 | 393 |
DrawTileLayout(ti, group, stage, house_id); |
394 |
} |
|
395 |
} |
|
396 |
||
397 |
void AnimateNewHouseTile(TileIndex tile) |
|
398 |
{ |
|
399 |
const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile)); |
|
400 |
byte animation_speed = hs->animation_speed; |
|
401 |
bool frame_set_by_callback = false; |
|
402 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
403 |
if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_SPEED)) { |
9624 | 404 |
uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_SPEED, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
405 |
if (callback_res != CALLBACK_FAILED) animation_speed = Clamp(callback_res & 0xFF, 2, 16); |
9476 | 406 |
} |
407 |
||
408 |
/* An animation speed of 2 means the animation frame changes 4 ticks, and |
|
409 |
* increasing this value by one doubles the wait. 2 is the minimum value |
|
410 |
* allowed for animation_speed, which corresponds to 120ms, and 16 is the |
|
411 |
* maximum, corresponding to around 33 minutes. */ |
|
412 |
if (_tick_counter % (1 << animation_speed) != 0) return; |
|
413 |
||
414 |
byte frame = GetHouseAnimationFrame(tile); |
|
415 |
byte num_frames = GB(hs->animation_frames, 0, 7); |
|
416 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
417 |
if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_NEXT_FRAME)) { |
9476 | 418 |
uint32 param = (hs->extra_flags & CALLBACK_1A_RANDOM_BITS) ? Random() : 0; |
9624 | 419 |
uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_NEXT_FRAME, param, 0, GetHouseType(tile), GetTownByTile(tile), tile); |
9476 | 420 |
|
421 |
if (callback_res != CALLBACK_FAILED) { |
|
422 |
frame_set_by_callback = true; |
|
423 |
||
424 |
switch (callback_res & 0xFF) { |
|
425 |
case 0xFF: |
|
426 |
DeleteAnimatedTile(tile); |
|
427 |
break; |
|
428 |
case 0xFE: |
|
429 |
/* Carry on as normal. */ |
|
430 |
frame_set_by_callback = false; |
|
431 |
break; |
|
432 |
default: |
|
433 |
frame = callback_res & 0xFF; |
|
434 |
break; |
|
435 |
} |
|
436 |
||
437 |
/* If the lower 7 bits of the upper byte of the callback |
|
438 |
* result are not empty, it is a sound effect. */ |
|
10294 | 439 |
if (GB(callback_res, 8, 7) != 0) PlayTileSound(hs->grffile, GB(callback_res, 8, 7), tile); |
9476 | 440 |
} |
441 |
} |
|
442 |
||
443 |
if (!frame_set_by_callback) { |
|
444 |
if (frame < num_frames) { |
|
445 |
frame++; |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
446 |
} else if (frame == num_frames && HasBit(hs->animation_frames, 7)) { |
9476 | 447 |
/* This animation loops, so start again from the beginning */ |
448 |
frame = 0; |
|
449 |
} else { |
|
450 |
/* This animation doesn't loop, so stay here */ |
|
451 |
DeleteAnimatedTile(tile); |
|
452 |
} |
|
453 |
} |
|
454 |
||
455 |
SetHouseAnimationFrame(tile, frame); |
|
456 |
MarkTileDirtyByTile(tile); |
|
457 |
} |
|
458 |
||
10294 | 459 |
void ChangeHouseAnimationFrame(const GRFFile *file, TileIndex tile, uint16 callback_result) |
9476 | 460 |
{ |
461 |
switch (callback_result & 0xFF) { |
|
462 |
case 0xFD: /* Do nothing. */ break; |
|
463 |
case 0xFE: AddAnimatedTile(tile); break; |
|
464 |
case 0xFF: DeleteAnimatedTile(tile); break; |
|
465 |
default: |
|
466 |
SetHouseAnimationFrame(tile, callback_result & 0xFF); |
|
467 |
AddAnimatedTile(tile); |
|
468 |
break; |
|
469 |
} |
|
470 |
/* If the lower 7 bits of the upper byte of the callback |
|
471 |
* result are not empty, it is a sound effect. */ |
|
10294 | 472 |
if (GB(callback_result, 8, 7) != 0) PlayTileSound(file, GB(callback_result, 8, 7), tile); |
9476 | 473 |
} |
474 |
||
475 |
bool CanDeleteHouse(TileIndex tile) |
|
476 |
{ |
|
477 |
const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile)); |
|
478 |
||
479 |
/* Human players are always allowed to remove buildings, as is water and |
|
480 |
* anyone using the scenario editor. */ |
|
481 |
if ((IsValidPlayer(_current_player) && IsHumanPlayer(_current_player)) |
|
482 |
|| _current_player == OWNER_WATER || _current_player == OWNER_NONE) return true; |
|
483 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
484 |
if (HasBit(hs->callback_mask, CBM_HOUSE_DENY_DESTRUCTION)) { |
9624 | 485 |
uint16 callback_res = GetHouseCallback(CBID_HOUSE_DENY_DESTRUCTION, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile); |
9476 | 486 |
return (callback_res == CALLBACK_FAILED || callback_res == 0); |
487 |
} else { |
|
488 |
return !(hs->extra_flags & BUILDING_IS_PROTECTED); |
|
489 |
} |
|
490 |
} |
|
491 |
||
492 |
static void AnimationControl(TileIndex tile, uint16 random_bits) |
|
493 |
{ |
|
494 |
const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile)); |
|
495 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
496 |
if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_START_STOP)) { |
9476 | 497 |
uint32 param = (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) ? (GB(Random(), 0, 16) | random_bits << 16) : Random(); |
9624 | 498 |
uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_START_STOP, param, 0, GetHouseType(tile), GetTownByTile(tile), tile); |
9476 | 499 |
|
10294 | 500 |
if (callback_res != CALLBACK_FAILED) ChangeHouseAnimationFrame(hs->grffile, tile, callback_res); |
9476 | 501 |
} |
502 |
} |
|
503 |
||
504 |
bool NewHouseTileLoop(TileIndex tile) |
|
505 |
{ |
|
506 |
const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile)); |
|
507 |
||
508 |
if (GetHouseProcessingTime(tile) > 0) { |
|
509 |
DecHouseProcessingTime(tile); |
|
510 |
return true; |
|
511 |
} |
|
512 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
513 |
TriggerHouse(tile, HOUSE_TRIGGER_TILE_LOOP); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
514 |
TriggerHouse(tile, HOUSE_TRIGGER_TILE_LOOP_TOP); |
9476 | 515 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
516 |
if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_START_STOP)) { |
9476 | 517 |
/* If this house is marked as having a synchronised callback, all the |
518 |
* tiles will have the callback called at once, rather than when the |
|
519 |
* tile loop reaches them. This should only be enabled for the northern |
|
520 |
* tile, or strange things will happen (here, and in TTDPatch). */ |
|
521 |
if (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) { |
|
522 |
uint16 random = GB(Random(), 0, 16); |
|
523 |
||
524 |
if (hs->building_flags & BUILDING_HAS_1_TILE) AnimationControl(tile, random); |
|
525 |
if (hs->building_flags & BUILDING_2_TILES_Y) AnimationControl(TILE_ADDXY(tile, 0, 1), random); |
|
526 |
if (hs->building_flags & BUILDING_2_TILES_X) AnimationControl(TILE_ADDXY(tile, 1, 0), random); |
|
527 |
if (hs->building_flags & BUILDING_HAS_4_TILES) AnimationControl(TILE_ADDXY(tile, 1, 1), random); |
|
528 |
} else { |
|
529 |
AnimationControl(tile, 0); |
|
530 |
} |
|
531 |
} |
|
532 |
||
533 |
/* Check callback 21, which determines if a house should be destroyed. */ |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
534 |
if (HasBit(hs->callback_mask, CBM_HOUSE_DESTRUCTION)) { |
9624 | 535 |
uint16 callback_res = GetHouseCallback(CBID_HOUSE_DESTRUCTION, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile); |
10294 | 536 |
if (callback_res != CALLBACK_FAILED && GB(callback_res, 0, 8) > 0) { |
9476 | 537 |
ClearTownHouse(GetTownByTile(tile), tile); |
538 |
return false; |
|
539 |
} |
|
540 |
} |
|
541 |
||
542 |
SetHouseProcessingTime(tile, hs->processing_time); |
|
543 |
return true; |
|
544 |
} |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
545 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
546 |
static void DoTriggerHouse(TileIndex tile, HouseTrigger trigger, byte base_random, bool first) |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
547 |
{ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
548 |
ResolverObject object; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
549 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
550 |
/* We can't trigger a non-existent building... */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
551 |
assert(IsTileType(tile, MP_HOUSE)); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
552 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
553 |
HouseID hid = GetHouseType(tile); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
554 |
HouseSpec *hs = GetHouseSpecs(hid); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
555 |
|
10355
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10294
diff
changeset
|
556 |
if (hs->spritegroup == NULL) return; |
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10294
diff
changeset
|
557 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
558 |
NewHouseResolver(&object, hid, tile, GetTownByTile(tile)); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
559 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
560 |
object.callback = CBID_RANDOM_TRIGGER; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
561 |
object.trigger = trigger; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
562 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
563 |
const SpriteGroup *group = Resolve(hs->spritegroup, &object); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
564 |
if (group == NULL) return; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
565 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
566 |
byte new_random_bits = Random(); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
567 |
byte random_bits = GetHouseRandomBits(tile); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
568 |
random_bits &= ~object.reseed; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
569 |
random_bits |= (first ? new_random_bits : base_random) & object.reseed; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
570 |
SetHouseRandomBits(tile, random_bits); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
571 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
572 |
switch (trigger) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
573 |
case HOUSE_TRIGGER_TILE_LOOP: |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
574 |
/* Random value already set. */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
575 |
break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
576 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
577 |
case HOUSE_TRIGGER_TILE_LOOP_TOP: |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
578 |
if (!first) break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
579 |
/* Random value of first tile already set. */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
580 |
if (hs->building_flags & BUILDING_2_TILES_Y) DoTriggerHouse(TILE_ADDXY(tile, 0, 1), trigger, random_bits, false); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
581 |
if (hs->building_flags & BUILDING_2_TILES_X) DoTriggerHouse(TILE_ADDXY(tile, 1, 0), trigger, random_bits, false); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
582 |
if (hs->building_flags & BUILDING_HAS_4_TILES) DoTriggerHouse(TILE_ADDXY(tile, 1, 1), trigger, random_bits, false); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
583 |
break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
584 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
585 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
586 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
587 |
void TriggerHouse(TileIndex t, HouseTrigger trigger) |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
588 |
{ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
589 |
DoTriggerHouse(t, trigger, 0, true); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
590 |
} |