From 2f09eff40434ad48d3110faf95182f0525f4093f Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 26 May 2022 00:12:54 +0100 Subject: [PATCH] VarAction2: Convert boolean, invert sequence to ternary --- src/newgrf.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 3f55c8be4d..253d1dc0cc 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -5800,6 +5800,14 @@ static void NewSpriteGroup(ByteReader *buf) inference = VA2AIF_SIGNED_NON_NEGATIVE | VA2AIF_ONE_OR_ZERO; break; } + if (prev.operation == DSGA_OP_UMIN && prev.type == DSGA_TYPE_NONE && prev.variable == 0x1A && prev.shift_num == 0 && prev.and_mask == 1) { + prev.operation = DSGA_OP_TERNARY; + prev.and_mask = 0; + prev.add_val = 1; + group->adjusts.pop_back(); + inference = VA2AIF_PREV_TERNARY; + break; + } } if (adjust.and_mask <= 1) inference = prev_inference & (VA2AIF_SIGNED_NON_NEGATIVE | VA2AIF_ONE_OR_ZERO); break;