From 9d320872366821f40f90a8e8e5c78e65699207ce Mon Sep 17 00:00:00 2001 From: frosch Date: Mon, 28 Apr 2025 21:18:55 +0200 Subject: [PATCH] Add: [NewGRF] Special value 0x7FFF for Action2 references specifying explicit 'callback/sprite-resolving failed'. --- src/newgrf/newgrf_act2.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/newgrf/newgrf_act2.cpp b/src/newgrf/newgrf_act2.cpp index 721b2dc737..89625f4062 100644 --- a/src/newgrf/newgrf_act2.cpp +++ b/src/newgrf/newgrf_act2.cpp @@ -22,6 +22,8 @@ #include "../safeguards.h" +constexpr uint16_t GROUPID_CALLBACK_FAILED = 0x7FFF; ///< Explicit "failure" result. + /** * Map the colour modifiers of TTDPatch to those that Open is using. * @param grf_sprite Pointer to the structure been modified. @@ -293,6 +295,7 @@ static const SpriteGroup *GetCallbackResultGroup(uint16_t value) static const SpriteGroup *GetGroupFromGroupID(uint8_t setid, uint8_t type, uint16_t groupid) { if (HasBit(groupid, 15)) return GetCallbackResultGroup(groupid); + if (groupid == GROUPID_CALLBACK_FAILED) return nullptr; if (groupid > MAX_SPRITEGROUP || _cur_gps.spritegroups[groupid] == nullptr) { GrfMsg(1, "GetGroupFromGroupID(0x{:02X}:0x{:02X}): Groupid 0x{:04X} does not exist, leaving empty", setid, type, groupid);