| 622 | } |
| 623 | |
| 624 | bool NewHouseTileLoop(TileIndex tile) |
| 625 | { |
| 626 | const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile)); |
| 627 | |
| 628 | if (GetHouseProcessingTime(tile) > 0) { |
| 629 | DecHouseProcessingTime(tile); |
| 630 | return true; |
| 631 | } |
| 632 | |
| 633 | TriggerHouseRandomisation(tile, HouseRandomTrigger::TileLoop); |
| 634 | if (hs->building_flags.Any(BUILDING_HAS_1_TILE)) TriggerHouseRandomisation(tile, HouseRandomTrigger::TileLoopNorth); |
| 635 | |
| 636 | /* Call the unsynchronized tile loop trigger */ |
| 637 | TriggerHouseAnimation_TileLoop(tile, false, 0); |
| 638 | |
| 639 | /* Call the synchronized tile loop trigger, if this is the north tile */ |
| 640 | if (hs->building_flags.Any(BUILDING_HAS_1_TILE)) { |
| 641 | uint16_t random = GB(Random(), 0, 16); |
| 642 | TriggerHouseAnimation_TileLoop(tile, true, random); |
| 643 | if (hs->building_flags.Any(BUILDING_2_TILES_Y)) TriggerHouseAnimation_TileLoop(TileAddXY(tile, 0, 1), true, random); |
| 644 | if (hs->building_flags.Any(BUILDING_2_TILES_X)) TriggerHouseAnimation_TileLoop(TileAddXY(tile, 1, 0), true, random); |
| 645 | if (hs->building_flags.Any(BUILDING_HAS_4_TILES)) TriggerHouseAnimation_TileLoop(TileAddXY(tile, 1, 1), true, random); |
| 646 | } |
| 647 | |
| 648 | /* Check callback 21, which determines if a house should be destroyed. */ |
| 649 | if (hs->callback_mask.Test(HouseCallbackMask::Destruction)) { |
| 650 | uint16_t callback_res = GetHouseCallback(CBID_HOUSE_DESTRUCTION, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile); |
| 651 | if (callback_res != CALLBACK_FAILED && Convert8bitBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_DESTRUCTION, callback_res)) { |
| 652 | ClearTownHouse(Town::GetByTile(tile), tile); |
| 653 | return false; |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | SetHouseProcessingTime(tile, hs->processing_time); |
| 658 | MarkTileDirtyByTile(tile); |
| 659 | return true; |
| 660 | } |
| 661 | |
| 662 | static void DoTriggerHouseRandomisation(TileIndex tile, HouseRandomTrigger trigger, uint8_t base_random, bool first) |
| 663 | { |
no test coverage detected