From e8de55adcb0d29bddab96699f2f94d5cb63ded97 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 24 Nov 2022 01:35:01 +0000 Subject: [PATCH] Don't start tile animation if it would be stopped immediately See: https://github.com/OpenTTD/OpenTTD/issues/10192 --- src/newgrf_animation_base.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/newgrf_animation_base.h b/src/newgrf_animation_base.h index 1bc69cef7c..c41b0639e1 100644 --- a/src/newgrf_animation_base.h +++ b/src/newgrf_animation_base.h @@ -142,6 +142,12 @@ struct AnimationBase { case 0xFF: DeleteAnimatedTile(tile); break; default: bool changed = Tframehelper::Set(obj, tile, callback); + if (callback >= spec->animation.frames && (spec->animation.status != ANIM_STATUS_LOOPING || spec->animation.frames == 0) && + !HasBit(spec->callback_mask, Tbase::cbm_animation_next_frame)) { + /* The animation would be stopped on this frame in the next AnimateTile call, don't bother animating it */ + if (changed) MarkTileDirtyByTile(tile, VMDF_NOT_MAP_MODE); + break; + } AddAnimatedTile(tile, changed); break; }