From 15d744c4e345f6d6969f588dc32c8809699379d0 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 26 Jun 2023 13:33:28 +0100 Subject: [PATCH] M_CheckCupEmeralds: Only count the first instance of each Emerald in the cups This prevents custom cups from being counted as completing primary Sealed Star progression unless you wipe existing ones. --- src/m_cond.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/m_cond.c b/src/m_cond.c index 7229007dc..a152204eb 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -747,17 +747,29 @@ UINT16 M_CheckCupEmeralds(UINT8 difficulty) difficulty = KARTGP_MASTER; cupheader_t *cup; - UINT16 ret = 0; + UINT16 ret = 0, seen = 0; for (cup = kartcupheaders; cup; cup = cup->next) { - if (cup->emeraldnum == 0) + // Does it not *have* an emerald? + if (cup->emeraldnum == 0 || cup->emeraldnum > 14) continue; + UINT16 emerald = 1<<(cup->emeraldnum-1); + + // Only count the first reference. + if (seen & emerald) + continue; + + // We've seen it, prevent future repetitions. + seen |= emerald; + + // Did you actually get it? if (cup->windata[difficulty].got_emerald == false) continue; - ret |= 1<<(cup->emeraldnum-1); + // Wa hoo ! + ret |= emerald; } return ret;