From d9aa2d61380c843608d2588dd04be0d3b02f2862 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 22 Aug 2022 21:52:15 +0100 Subject: [PATCH] VarAction2: Extend group cast to bool range elision Handle opposite arrangement of range and default group --- src/newgrf_optimiser.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/newgrf_optimiser.cpp b/src/newgrf_optimiser.cpp index 819aa8ffb7..9cea921ac2 100644 --- a/src/newgrf_optimiser.cpp +++ b/src/newgrf_optimiser.cpp @@ -2250,6 +2250,10 @@ void OptimiseVarAction2DeterministicSpriteGroup(VarAction2OptimiseState &state, group->default_group != nullptr && group->default_group->type == SGT_CALLBACK && static_cast(group->default_group)->result == 1) { group->calculated_result = true; group->ranges.clear(); + } else if (r0.low == 1 && r0.high == 1 && r0.group != nullptr && r0.group->type == SGT_CALLBACK && static_cast(r0.group)->result == 1 && + group->default_group != nullptr && group->default_group->type == SGT_CALLBACK && static_cast(group->default_group)->result == 0) { + group->calculated_result = true; + group->ranges.clear(); } }