1
0
Fork 0

Change: [NewGRF] Animation-trigger 'construction stage changed' of houses and industries now also triggers at construction start. (#14089)

pull/14092/head
frosch 2025-04-26 14:42:49 +02:00 committed by GitHub
parent 365eed533d
commit 0d9074769d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 29 additions and 5 deletions

View File

@ -763,7 +763,7 @@ static void MakeIndustryTileBigger(TileIndex tile)
uint8_t stage = GetIndustryConstructionStage(tile) + 1;
SetIndustryConstructionCounter(tile, 0);
SetIndustryConstructionStage(tile, stage);
TriggerIndustryTileAnimation(tile, IndustryAnimationTrigger::ConstructionStageChanged);
TriggerIndustryTileAnimation_ConstructionStageChanged(tile, false);
if (stage == INDUSTRY_COMPLETED) SetIndustryCompleted(tile);
MarkTileDirtyByTile(tile);
@ -1946,6 +1946,15 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
}
}
/* Call callbacks after all tiles have been created. */
for (TileIndex cur_tile : i->location) {
if (i->TileBelongsToIndustry(cur_tile)) {
/* There are no shared random bits, consistent with "MakeIndustryTileBigger" in tile loop.
* So, trigger tiles individually */
TriggerIndustryTileAnimation_ConstructionStageChanged(cur_tile, true);
}
}
if (GetIndustrySpec(i->type)->behaviour.Test(IndustryBehaviour::PlantOnBuild)) {
for (uint j = 0; j != 50; j++) PlantRandomFarmField(i);
}

View File

@ -537,12 +537,12 @@ void AnimateNewHouseTile(TileIndex tile)
HouseAnimationBase::AnimateTile(hs, Town::GetByTile(tile), tile, hs->extra_flags.Test(HouseExtraFlag::Callback1ARandomBits));
}
void TriggerHouseAnimation_ConstructionStageChanged(TileIndex tile)
void TriggerHouseAnimation_ConstructionStageChanged(TileIndex tile, bool first_call)
{
const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile));
if (hs->callback_mask.Test(HouseCallbackMask::AnimationTriggerConstructionStageChanged)) {
HouseAnimationBase::ChangeAnimationFrame(CBID_HOUSE_ANIMATION_TRIGGER_CONSTRUCTION_STAGE_CHANGED, hs, Town::GetByTile(tile), tile, 0, 0);
HouseAnimationBase::ChangeAnimationFrame(CBID_HOUSE_ANIMATION_TRIGGER_CONSTRUCTION_STAGE_CHANGED, hs, Town::GetByTile(tile), tile, 0, first_call ? 1 : 0);
}
}

View File

@ -100,7 +100,7 @@ std::span<const uint> GetBuildingHouseIDCounts();
void DrawNewHouseTile(TileInfo *ti, HouseID house_id);
void AnimateNewHouseTile(TileIndex tile);
/* see also: void TriggerHouseAnimation_TileLoop(TileIndex tile, uint16_t random_bits) */
void TriggerHouseAnimation_ConstructionStageChanged(TileIndex tile);
void TriggerHouseAnimation_ConstructionStageChanged(TileIndex tile, bool first_call);
void TriggerHouseAnimation_WatchedCargoAccepted(TileIndex tile, CargoTypes trigger_cargoes);
uint16_t GetHouseCallback(CallbackID callback, uint32_t param1, uint32_t param2, HouseID house_id, Town *town, TileIndex tile,

View File

@ -285,8 +285,15 @@ static bool DoTriggerIndustryTileAnimation(TileIndex tile, IndustryAnimationTrig
return true;
}
bool TriggerIndustryTileAnimation_ConstructionStageChanged(TileIndex tile, bool first_call)
{
auto iat = IndustryAnimationTrigger::ConstructionStageChanged;
return DoTriggerIndustryTileAnimation(tile, iat, Random(), first_call ? 0x100 : 0);
}
bool TriggerIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat)
{
assert(iat != IndustryAnimationTrigger::ConstructionStageChanged);
return DoTriggerIndustryTileAnimation(tile, iat, Random());
}

View File

@ -63,6 +63,7 @@ CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind
void AnimateNewIndustryTile(TileIndex tile);
bool TriggerIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat);
bool TriggerIndustryTileAnimation_ConstructionStageChanged(TileIndex tile, bool first_call);
bool TriggerIndustryAnimation(const Industry *ind, IndustryAnimationTrigger iat);
void TriggerIndustryTileRandomisation(TileIndex t, IndustryRandomTrigger trigger);

View File

@ -503,7 +503,7 @@ static void AdvanceSingleHouseConstruction(TileIndex tile)
IncHouseConstructionTick(tile);
if (GetHouseConstructionTick(tile) != 0) return;
TriggerHouseAnimation_ConstructionStageChanged(tile);
TriggerHouseAnimation_ConstructionStageChanged(tile, false);
if (IsHouseCompleted(tile)) {
/* Now that construction is complete, we can add the population of the
@ -2705,6 +2705,13 @@ static void BuildTownHouse(Town *t, TileIndex tile, const HouseSpec *hs, HouseID
MakeTownHouse(tile, t, construction_counter, construction_stage, house, random_bits, is_protected);
UpdateTownRadius(t);
UpdateTownGrowthRate(t);
BuildingFlags size = hs->building_flags;
TriggerHouseAnimation_ConstructionStageChanged(tile, true);
if (size.Any(BUILDING_2_TILES_Y)) TriggerHouseAnimation_ConstructionStageChanged(tile + TileDiffXY(0, 1), true);
if (size.Any(BUILDING_2_TILES_X)) TriggerHouseAnimation_ConstructionStageChanged(tile + TileDiffXY(1, 0), true);
if (size.Any(BUILDING_HAS_4_TILES)) TriggerHouseAnimation_ConstructionStageChanged(tile + TileDiffXY(1, 1), true);
}
/**