diff --git a/src/newgrf_analysis.cpp b/src/newgrf_analysis.cpp index f64cc95907..8e2a72c3d5 100644 --- a/src/newgrf_analysis.cpp +++ b/src/newgrf_analysis.cpp @@ -183,6 +183,16 @@ void DeterministicSpriteGroup::AnalyseCallbacks(AnalyseCallbackOperation &op) co } if (op.mode == ACOM_INDUSTRY_TILE && adjust.variable == 0xC) { if (adjust.shift_num == 0 && (adjust.and_mask & 0xFF) == 0xFF && adjust.type == DSGA_TYPE_NONE) { + /* Check for CBID_INDTILE_ANIM_NEXT_FRAME, mark layout subset as animated if found */ + if (op.data.indtile->check_anim_next_frame_cb) { + for (const auto &range : this->ranges) { + if (range.low <= CBID_INDTILE_ANIM_NEXT_FRAME && CBID_INDTILE_ANIM_NEXT_FRAME <= range.high) { + /* Found a CBID_INDTILE_ANIM_NEXT_FRAME */ + *(op.data.indtile->result_mask) &= ~op.data.indtile->check_mask; + } + } + } + /* Callback switch, skip to the default/graphics chain */ for (const auto &range : this->ranges) { if (range.low == 0) { @@ -279,7 +289,6 @@ void DeterministicSpriteGroup::AnalyseCallbacks(AnalyseCallbackOperation &op) co } if (op.mode == ACOM_INDUSTRY_TILE && this->var_scope == VSG_SCOPE_SELF && (adjust.variable == 0x44 || (adjust.variable == 0x61 && adjust.parameter == 0))) { *(op.data.indtile->result_mask) &= ~op.data.indtile->check_mask; - return; } if (op.mode == ACOM_INDUSTRY_TILE && ((this->var_scope == VSG_SCOPE_SELF && adjust.variable == 0x61) || (this->var_scope == VSG_SCOPE_PARENT && adjust.variable == 0x63))) { op.data.indtile->anim_state_at_offset = true; diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp index 60cbfe2d3d..a54c1554c4 100644 --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -430,11 +430,6 @@ void AnalyseIndustryTileSpriteGroups() const IndustryTileSpec &tilespec = _industry_tile_specs[gfx]; if (tilespec.grf_prop.spritegroup[0] == nullptr) continue; - if (HasBit(tilespec.callback_mask, CBM_INDT_ANIM_NEXT_FRAME)) { - /* There may be sound effects, or custom animation start/stop behaviour, don't inhibit */ - continue; - } - anim_mask |= current; AnalyseCallbackOperationIndustryTileData data; @@ -443,6 +438,7 @@ void AnalyseIndustryTileSpriteGroups() data.result_mask = &anim_mask; data.layout_index = idx + 1; data.anim_state_at_offset = false; + data.check_anim_next_frame_cb = HasBit(tilespec.callback_mask, CBM_INDT_ANIM_NEXT_FRAME); AnalyseCallbackOperation op(ACOM_INDUSTRY_TILE); op.data.indtile = &data; diff --git a/src/newgrf_industrytiles_analysis.h b/src/newgrf_industrytiles_analysis.h index a0d2695e76..519c2f2ba2 100644 --- a/src/newgrf_industrytiles_analysis.h +++ b/src/newgrf_industrytiles_analysis.h @@ -18,6 +18,7 @@ struct AnalyseCallbackOperationIndustryTileData { uint64 *result_mask; uint8 layout_index; bool anim_state_at_offset; + bool check_anim_next_frame_cb; }; #endif /* NEWGRF_INDUSTRYTILES_ANALYSIS_H */