MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / NewHouseTileLoop

Function NewHouseTileLoop

src/newgrf_house.cpp:624–660  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

622}
623
624bool 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
662static void DoTriggerHouseRandomisation(TileIndex tile, HouseRandomTrigger trigger, uint8_t base_random, bool first)
663{

Callers 1

TileLoop_TownFunction · 0.85

Calls 15

GetHouseTypeFunction · 0.85
GetHouseProcessingTimeFunction · 0.85
DecHouseProcessingTimeFunction · 0.85
GBFunction · 0.85
TileAddXYFunction · 0.85
GetHouseCallbackFunction · 0.85
ClearTownHouseFunction · 0.85
SetHouseProcessingTimeFunction · 0.85
AnyMethod · 0.80

Tested by

no test coverage detected