00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #include "stdafx.h"
00013 #include "variables.h"
00014 #include "debug.h"
00015 #include "viewport_func.h"
00016 #include "landscape.h"
00017 #include "newgrf.h"
00018 #include "newgrf_house.h"
00019 #include "newgrf_spritegroup.h"
00020 #include "newgrf_town.h"
00021 #include "newgrf_sound.h"
00022 #include "newgrf_commons.h"
00023 #include "functions.h"
00024 #include "company_func.h"
00025 #include "animated_tile_func.h"
00026 #include "company_base.h"
00027 #include "town.h"
00028 #include "core/random_func.hpp"
00029 #include "sprite.h"
00030
00031 static BuildingCounts<uint32> _building_counts;
00032 static HouseClassMapping _class_mapping[HOUSE_CLASS_MAX];
00033
00034 HouseOverrideManager _house_mngr(NEW_HOUSE_OFFSET, HOUSE_MAX, INVALID_HOUSE_ID);
00035
00036 HouseClassID AllocateHouseClassID(byte grf_class_id, uint32 grfid)
00037 {
00038
00039 for (int i = 1; i != lengthof(_class_mapping); i++) {
00040 HouseClassMapping *map = &_class_mapping[i];
00041
00042 if (map->class_id == grf_class_id && map->grfid == grfid) return (HouseClassID)i;
00043
00044 if (map->class_id == 0 && map->grfid == 0) {
00045 map->class_id = grf_class_id;
00046 map->grfid = grfid;
00047 return (HouseClassID)i;
00048 }
00049 }
00050 return HOUSE_NO_CLASS;
00051 }
00052
00053 void InitializeBuildingCounts()
00054 {
00055 memset(&_building_counts, 0, sizeof(_building_counts));
00056 }
00057
00064 void IncreaseBuildingCount(Town *t, HouseID house_id)
00065 {
00066 HouseClassID class_id = HouseSpec::Get(house_id)->class_id;
00067
00068 if (!_loaded_newgrf_features.has_newhouses) return;
00069
00070 t->building_counts.id_count[house_id]++;
00071 _building_counts.id_count[house_id]++;
00072
00073 if (class_id == HOUSE_NO_CLASS) return;
00074
00075 t->building_counts.class_count[class_id]++;
00076 _building_counts.class_count[class_id]++;
00077 }
00078
00085 void DecreaseBuildingCount(Town *t, HouseID house_id)
00086 {
00087 HouseClassID class_id = HouseSpec::Get(house_id)->class_id;
00088
00089 if (!_loaded_newgrf_features.has_newhouses) return;
00090
00091 if (t->building_counts.id_count[house_id] > 0) t->building_counts.id_count[house_id]--;
00092 if (_building_counts.id_count[house_id] > 0) _building_counts.id_count[house_id]--;
00093
00094 if (class_id == HOUSE_NO_CLASS) return;
00095
00096 if (t->building_counts.class_count[class_id] > 0) t->building_counts.class_count[class_id]--;
00097 if (_building_counts.class_count[class_id] > 0) _building_counts.class_count[class_id]--;
00098 }
00099
00100 static uint32 HouseGetRandomBits(const ResolverObject *object)
00101 {
00102 const TileIndex tile = object->u.house.tile;
00103 return (tile == INVALID_TILE || !IsTileType(tile, MP_HOUSE)) ? 0 : GetHouseRandomBits(tile);
00104 }
00105
00106 static uint32 HouseGetTriggers(const ResolverObject *object)
00107 {
00108 const TileIndex tile = object->u.house.tile;
00109 return (tile == INVALID_TILE || !IsTileType(tile, MP_HOUSE)) ? 0 : GetHouseTriggers(tile);
00110 }
00111
00112 static void HouseSetTriggers(const ResolverObject *object, int triggers)
00113 {
00114 const TileIndex tile = object->u.house.tile;
00115 if (IsTileType(tile, MP_HOUSE)) SetHouseTriggers(tile, triggers);
00116 }
00117
00118 static uint32 GetNumHouses(HouseID house_id, const Town *town)
00119 {
00120 uint8 map_id_count, town_id_count, map_class_count, town_class_count;
00121 HouseClassID class_id = HouseSpec::Get(house_id)->class_id;
00122
00123 map_id_count = ClampU(_building_counts.id_count[house_id], 0, 255);
00124 map_class_count = ClampU(_building_counts.class_count[class_id], 0, 255);
00125 town_id_count = ClampU(town->building_counts.id_count[house_id], 0, 255);
00126 town_class_count = ClampU(town->building_counts.class_count[class_id], 0, 255);
00127
00128 return map_class_count << 24 | town_class_count << 16 | map_id_count << 8 | town_id_count;
00129 }
00130
00131 uint32 GetNearbyTileInformation(byte parameter, TileIndex tile)
00132 {
00133 tile = GetNearbyTile(parameter, tile);
00134 return GetNearbyTileInformation(tile);
00135 }
00136
00138 typedef struct {
00139 const HouseSpec *hs;
00140 TileIndex north_tile;
00141 } SearchNearbyHouseData;
00142
00148 static bool SearchNearbyHouseID(TileIndex tile, void *user_data)
00149 {
00150 if (IsTileType(tile, MP_HOUSE)) {
00151 HouseID house = GetHouseType(tile);
00152 const HouseSpec *hs = HouseSpec::Get(house);
00153 if (hs->grffile != NULL) {
00154 SearchNearbyHouseData *nbhd = (SearchNearbyHouseData *)user_data;
00155
00156 TileIndex north_tile = tile + GetHouseNorthPart(house);
00157 if (north_tile == nbhd->north_tile) return false;
00158
00159 return hs->local_id == nbhd->hs->local_id &&
00160 hs->grffile->grfid == nbhd->hs->grffile->grfid;
00161 }
00162 }
00163 return false;
00164 }
00165
00171 static bool SearchNearbyHouseClass(TileIndex tile, void *user_data)
00172 {
00173 if (IsTileType(tile, MP_HOUSE)) {
00174 HouseID house = GetHouseType(tile);
00175 const HouseSpec *hs = HouseSpec::Get(house);
00176 if (hs->grffile != NULL) {
00177 SearchNearbyHouseData *nbhd = (SearchNearbyHouseData *)user_data;
00178
00179 TileIndex north_tile = tile + GetHouseNorthPart(house);
00180 if (north_tile == nbhd->north_tile) return false;
00181
00182 return hs->class_id == nbhd->hs->class_id &&
00183 hs->grffile->grfid == nbhd->hs->grffile->grfid;
00184 }
00185 }
00186 return false;
00187 }
00188
00194 static bool SearchNearbyHouseGRFID(TileIndex tile, void *user_data)
00195 {
00196 if (IsTileType(tile, MP_HOUSE)) {
00197 HouseID house = GetHouseType(tile);
00198 const HouseSpec *hs = HouseSpec::Get(house);
00199 if (hs->grffile != NULL) {
00200 SearchNearbyHouseData *nbhd = (SearchNearbyHouseData *)user_data;
00201
00202 TileIndex north_tile = tile + GetHouseNorthPart(house);
00203 if (north_tile == nbhd->north_tile) return false;
00204
00205 return hs->grffile->grfid == nbhd->hs->grffile->grfid;
00206 }
00207 }
00208 return false;
00209 }
00210
00220 static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseID house)
00221 {
00222 static TestTileOnSearchProc * const search_procs[3] = {
00223 SearchNearbyHouseID,
00224 SearchNearbyHouseClass,
00225 SearchNearbyHouseGRFID,
00226 };
00227 TileIndex found_tile = tile;
00228 uint8 searchtype = GB(parameter, 6, 2);
00229 uint8 searchradius = GB(parameter, 0, 6);
00230 if (searchtype >= lengthof(search_procs)) return 0;
00231 if (searchradius < 1) return 0;
00232
00233 SearchNearbyHouseData nbhd;
00234 nbhd.hs = HouseSpec::Get(house);
00235 nbhd.north_tile = tile + GetHouseNorthPart(house);
00236
00237
00238 if (CircularTileSearch(&found_tile, 2 * searchradius + 1, search_procs[searchtype], &nbhd)) {
00239 return DistanceManhattan(found_tile, tile);
00240 }
00241 return 0;
00242 }
00243
00249 static uint32 HouseGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
00250 {
00251 const Town *town = object->u.house.town;
00252 TileIndex tile = object->u.house.tile;
00253 HouseID house_id = object->u.house.house_id;
00254
00255 if (object->scope == VSG_SCOPE_PARENT) {
00256 return TownGetVariable(variable, parameter, available, town);
00257 }
00258
00259 switch (variable) {
00260
00261 case 0x40: return (IsTileType(tile, MP_HOUSE) ? GetHouseBuildingStage(tile) : 0) | TileHash2Bit(TileX(tile), TileY(tile)) << 2;
00262
00263
00264 case 0x41: return IsTileType(tile, MP_HOUSE) ? GetHouseAge(tile) : 0;
00265
00266
00267 case 0x42: return GetTownRadiusGroup(town, tile);
00268
00269
00270 case 0x43: return GetTerrainType(tile);
00271
00272
00273 case 0x44: return GetNumHouses(house_id, town);
00274
00275
00276 case 0x45: return _generating_world ? 1 : 0;
00277
00278
00279 case 0x46: return IsTileType(tile, MP_HOUSE) ? GetHouseAnimationFrame(tile) : 0;
00280
00281
00282 case 0x47: return TileY(tile) << 16 | TileX(tile);
00283
00284
00285 case 0x60: return GetNumHouses(parameter, town);
00286
00287
00288 case 0x61: {
00289 const HouseSpec *hs = HouseSpec::Get(house_id);
00290 if (hs->grffile == NULL) return 0;
00291
00292 HouseID new_house = _house_mngr.GetID(parameter, hs->grffile->grfid);
00293 return new_house == INVALID_HOUSE_ID ? 0 : GetNumHouses(new_house, town);
00294 }
00295
00296
00297 case 0x62: return GetNearbyTileInformation(parameter, tile);
00298
00299
00300 case 0x63: {
00301 TileIndex testtile = GetNearbyTile(parameter, tile);
00302 return IsTileType(testtile, MP_HOUSE) ? GetHouseAnimationFrame(testtile) : 0;
00303 }
00304
00305
00306
00307
00308
00309 case 0x65: return GetDistanceFromNearbyHouse(parameter, tile, object->u.house.house_id);
00310
00311
00312 case 0x66: {
00313 TileIndex testtile = GetNearbyTile(parameter, tile);
00314 if (!IsTileType(testtile, MP_HOUSE)) return 0xFFFFFFFF;
00315 HouseSpec *hs = HouseSpec::Get(GetHouseType(testtile));
00316
00317 uint houseclass = 0;
00318 if (hs->class_id != HOUSE_NO_CLASS) {
00319 houseclass = (hs->grffile == object->grffile ? 1 : 2) << 8;
00320 houseclass |= _class_mapping[hs->class_id].class_id;
00321 }
00322
00323 uint local_houseid = 0;
00324 if (house_id < NEW_HOUSE_OFFSET) {
00325 local_houseid = house_id;
00326 } else {
00327 local_houseid = (hs->grffile == object->grffile ? 1 : 2) << 8;
00328 local_houseid |= hs->local_id;
00329 }
00330 return houseclass << 16 | local_houseid;
00331 }
00332
00333
00334 case 0x67: {
00335 TileIndex testtile = GetNearbyTile(parameter, tile);
00336 if (!IsTileType(testtile, MP_HOUSE)) return 0xFFFFFFFF;
00337 HouseID house_id = GetHouseType(testtile);
00338 if (house_id < NEW_HOUSE_OFFSET) return 0;
00339
00340
00341 return _house_mngr.mapping_ID[house_id].grfid;
00342 }
00343 }
00344
00345 DEBUG(grf, 1, "Unhandled house property 0x%X", variable);
00346
00347 *available = false;
00348 return UINT_MAX;
00349 }
00350
00351 static const SpriteGroup *HouseResolveReal(const ResolverObject *object, const RealSpriteGroup *group)
00352 {
00353
00354 return NULL;
00355 }
00356
00362 static void NewHouseResolver(ResolverObject *res, HouseID house_id, TileIndex tile, Town *town)
00363 {
00364 res->GetRandomBits = HouseGetRandomBits;
00365 res->GetTriggers = HouseGetTriggers;
00366 res->SetTriggers = HouseSetTriggers;
00367 res->GetVariable = HouseGetVariable;
00368 res->ResolveReal = HouseResolveReal;
00369
00370 res->u.house.tile = tile;
00371 res->u.house.town = town;
00372 res->u.house.house_id = house_id;
00373
00374 res->callback = CBID_NO_CALLBACK;
00375 res->callback_param1 = 0;
00376 res->callback_param2 = 0;
00377 res->last_value = 0;
00378 res->trigger = 0;
00379 res->reseed = 0;
00380 res->count = 0;
00381
00382 const HouseSpec *hs = HouseSpec::Get(house_id);
00383 res->grffile = (hs != NULL ? hs->grffile : NULL);
00384 }
00385
00386 uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile)
00387 {
00388 ResolverObject object;
00389 const SpriteGroup *group;
00390
00391 NewHouseResolver(&object, house_id, tile, town);
00392 object.callback = callback;
00393 object.callback_param1 = param1;
00394 object.callback_param2 = param2;
00395
00396 group = SpriteGroup::Resolve(HouseSpec::Get(house_id)->spritegroup, &object);
00397 if (group == NULL) return CALLBACK_FAILED;
00398
00399 return group->GetCallbackResult();
00400 }
00401
00402 static void DrawTileLayout(const TileInfo *ti, const TileLayoutSpriteGroup *group, byte stage, HouseID house_id)
00403 {
00404 const DrawTileSprites *dts = group->dts;
00405
00406 const HouseSpec *hs = HouseSpec::Get(house_id);
00407 SpriteID palette = hs->random_colour[TileHash2Bit(ti->x, ti->y)] + PALETTE_RECOLOUR_START;
00408 if (HasBit(hs->callback_mask, CBM_HOUSE_COLOUR)) {
00409 uint16 callback = GetHouseCallback(CBID_HOUSE_COLOUR, 0, 0, house_id, Town::GetByTile(ti->tile), ti->tile);
00410 if (callback != CALLBACK_FAILED) {
00411
00412 palette = HasBit(callback, 14) ? GB(callback, 0, 8) + SPR_2CCMAP_BASE : callback;
00413 }
00414 }
00415
00416 SpriteID image = dts->ground.sprite;
00417 SpriteID pal = dts->ground.pal;
00418
00419 if (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) image += stage;
00420
00421 if (GB(image, 0, SPRITE_WIDTH) != 0) {
00422 DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, palette));
00423 }
00424
00425 DrawNewGRFTileSeq(ti, dts, TO_HOUSES, stage, palette);
00426 }
00427
00428 void DrawNewHouseTile(TileInfo *ti, HouseID house_id)
00429 {
00430 const HouseSpec *hs = HouseSpec::Get(house_id);
00431 const SpriteGroup *group;
00432 ResolverObject object;
00433
00434 if (ti->tileh != SLOPE_FLAT) {
00435 bool draw_old_one = true;
00436 if (HasBit(hs->callback_mask, CBM_HOUSE_DRAW_FOUNDATIONS)) {
00437
00438 uint32 callback_res = GetHouseCallback(CBID_HOUSE_DRAW_FOUNDATIONS, 0, 0, house_id, Town::GetByTile(ti->tile), ti->tile);
00439 draw_old_one = (callback_res != 0);
00440 }
00441
00442 if (draw_old_one) DrawFoundation(ti, FOUNDATION_LEVELED);
00443 }
00444
00445 NewHouseResolver(&object, house_id, ti->tile, Town::GetByTile(ti->tile));
00446
00447 group = SpriteGroup::Resolve(hs->spritegroup, &object);
00448 if (group == NULL || group->type != SGT_TILELAYOUT) {
00449 return;
00450 } else {
00451
00452 const TileLayoutSpriteGroup *tlgroup = (const TileLayoutSpriteGroup *)group;
00453 byte stage = GetHouseBuildingStage(ti->tile);
00454 stage = Clamp(stage - 4 + tlgroup->num_building_stages, 0, tlgroup->num_building_stages - 1);
00455 DrawTileLayout(ti, tlgroup, stage, house_id);
00456 }
00457 }
00458
00459 void AnimateNewHouseTile(TileIndex tile)
00460 {
00461 const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile));
00462 byte animation_speed = hs->animation_speed;
00463 bool frame_set_by_callback = false;
00464
00465 if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_SPEED)) {
00466 uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_SPEED, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
00467 if (callback_res != CALLBACK_FAILED) animation_speed = Clamp(callback_res & 0xFF, 2, 16);
00468 }
00469
00470
00471
00472
00473
00474 if (_tick_counter % (1 << animation_speed) != 0) return;
00475
00476 byte frame = GetHouseAnimationFrame(tile);
00477 byte num_frames = GB(hs->animation_frames, 0, 7);
00478
00479 if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_NEXT_FRAME)) {
00480 uint32 param = (hs->extra_flags & CALLBACK_1A_RANDOM_BITS) ? Random() : 0;
00481 uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_NEXT_FRAME, param, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
00482
00483 if (callback_res != CALLBACK_FAILED) {
00484 frame_set_by_callback = true;
00485
00486 switch (callback_res & 0xFF) {
00487 case 0xFF:
00488 DeleteAnimatedTile(tile);
00489 break;
00490 case 0xFE:
00491
00492 frame_set_by_callback = false;
00493 break;
00494 default:
00495 frame = callback_res & 0xFF;
00496 break;
00497 }
00498
00499
00500
00501 if (GB(callback_res, 8, 7) != 0) PlayTileSound(hs->grffile, GB(callback_res, 8, 7), tile);
00502 }
00503 }
00504
00505 if (!frame_set_by_callback) {
00506 if (frame < num_frames) {
00507 frame++;
00508 } else if (frame == num_frames && HasBit(hs->animation_frames, 7)) {
00509
00510 frame = 0;
00511 } else {
00512
00513 DeleteAnimatedTile(tile);
00514 }
00515 }
00516
00517 SetHouseAnimationFrame(tile, frame);
00518 MarkTileDirtyByTile(tile);
00519 }
00520
00521 void ChangeHouseAnimationFrame(const GRFFile *file, TileIndex tile, uint16 callback_result)
00522 {
00523 switch (callback_result & 0xFF) {
00524 case 0xFD: break;
00525 case 0xFE: AddAnimatedTile(tile); break;
00526 case 0xFF: DeleteAnimatedTile(tile); break;
00527 default:
00528 SetHouseAnimationFrame(tile, callback_result & 0xFF);
00529 AddAnimatedTile(tile);
00530 break;
00531 }
00532
00533
00534 if (GB(callback_result, 8, 7) != 0) PlayTileSound(file, GB(callback_result, 8, 7), tile);
00535 }
00536
00537 bool CanDeleteHouse(TileIndex tile)
00538 {
00539 const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile));
00540
00541
00542
00543 if (Company::IsValidHumanID(_current_company) || _current_company == OWNER_WATER || _current_company == OWNER_NONE) {
00544 return true;
00545 }
00546
00547 if (HasBit(hs->callback_mask, CBM_HOUSE_DENY_DESTRUCTION)) {
00548 uint16 callback_res = GetHouseCallback(CBID_HOUSE_DENY_DESTRUCTION, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
00549 return (callback_res == CALLBACK_FAILED || callback_res == 0);
00550 } else {
00551 return !(hs->extra_flags & BUILDING_IS_PROTECTED);
00552 }
00553 }
00554
00555 static void AnimationControl(TileIndex tile, uint16 random_bits)
00556 {
00557 const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile));
00558
00559 if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_START_STOP)) {
00560 uint32 param = (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) ? (GB(Random(), 0, 16) | random_bits << 16) : Random();
00561 uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_START_STOP, param, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
00562
00563 if (callback_res != CALLBACK_FAILED) ChangeHouseAnimationFrame(hs->grffile, tile, callback_res);
00564 }
00565 }
00566
00567 bool NewHouseTileLoop(TileIndex tile)
00568 {
00569 const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile));
00570
00571 if (GetHouseProcessingTime(tile) > 0) {
00572 DecHouseProcessingTime(tile);
00573 return true;
00574 }
00575
00576 TriggerHouse(tile, HOUSE_TRIGGER_TILE_LOOP);
00577 if (hs->building_flags & BUILDING_HAS_1_TILE) TriggerHouse(tile, HOUSE_TRIGGER_TILE_LOOP_TOP);
00578
00579 if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_START_STOP)) {
00580
00581
00582
00583
00584 if (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) {
00585 uint16 random = GB(Random(), 0, 16);
00586
00587 if (hs->building_flags & BUILDING_HAS_1_TILE) AnimationControl(tile, random);
00588 if (hs->building_flags & BUILDING_2_TILES_Y) AnimationControl(TILE_ADDXY(tile, 0, 1), random);
00589 if (hs->building_flags & BUILDING_2_TILES_X) AnimationControl(TILE_ADDXY(tile, 1, 0), random);
00590 if (hs->building_flags & BUILDING_HAS_4_TILES) AnimationControl(TILE_ADDXY(tile, 1, 1), random);
00591 } else {
00592 AnimationControl(tile, 0);
00593 }
00594 }
00595
00596
00597 if (HasBit(hs->callback_mask, CBM_HOUSE_DESTRUCTION)) {
00598 uint16 callback_res = GetHouseCallback(CBID_HOUSE_DESTRUCTION, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
00599 if (callback_res != CALLBACK_FAILED && GB(callback_res, 0, 8) > 0) {
00600 ClearTownHouse(Town::GetByTile(tile), tile);
00601 return false;
00602 }
00603 }
00604
00605 SetHouseProcessingTime(tile, hs->processing_time);
00606 MarkTileDirtyByTile(tile);
00607 return true;
00608 }
00609
00610 static void DoTriggerHouse(TileIndex tile, HouseTrigger trigger, byte base_random, bool first)
00611 {
00612 ResolverObject object;
00613
00614
00615 assert(IsTileType(tile, MP_HOUSE));
00616
00617 HouseID hid = GetHouseType(tile);
00618 HouseSpec *hs = HouseSpec::Get(hid);
00619
00620 if (hs->spritegroup == NULL) return;
00621
00622 NewHouseResolver(&object, hid, tile, Town::GetByTile(tile));
00623
00624 object.callback = CBID_RANDOM_TRIGGER;
00625 object.trigger = trigger;
00626
00627 const SpriteGroup *group = SpriteGroup::Resolve(hs->spritegroup, &object);
00628 if (group == NULL) return;
00629
00630 byte new_random_bits = Random();
00631 byte random_bits = GetHouseRandomBits(tile);
00632 random_bits &= ~object.reseed;
00633 random_bits |= (first ? new_random_bits : base_random) & object.reseed;
00634 SetHouseRandomBits(tile, random_bits);
00635
00636 switch (trigger) {
00637 case HOUSE_TRIGGER_TILE_LOOP:
00638
00639 break;
00640
00641 case HOUSE_TRIGGER_TILE_LOOP_TOP:
00642 if (!first) {
00643
00644 MarkTileDirtyByTile(tile);
00645 break;
00646 }
00647
00648 if (hs->building_flags & BUILDING_2_TILES_Y) DoTriggerHouse(TILE_ADDXY(tile, 0, 1), trigger, random_bits, false);
00649 if (hs->building_flags & BUILDING_2_TILES_X) DoTriggerHouse(TILE_ADDXY(tile, 1, 0), trigger, random_bits, false);
00650 if (hs->building_flags & BUILDING_HAS_4_TILES) DoTriggerHouse(TILE_ADDXY(tile, 1, 1), trigger, random_bits, false);
00651 break;
00652 }
00653 }
00654
00655 void TriggerHouse(TileIndex t, HouseTrigger trigger)
00656 {
00657 DoTriggerHouse(t, trigger, 0, true);
00658 }