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.
This commit is contained in:
toaster 2023-06-26 13:33:28 +01:00
parent 8cd3305a34
commit 15d744c4e3

View file

@ -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;