From 4b7aa368b55fa2c49fd6f9b5c85955c37f3cedbb Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 8 Apr 2023 00:05:18 +0100 Subject: [PATCH] P_GetNextEmerald: Accomodate map reuse in GP - In GP, use struct's cup pointer to get Emerald so the active cup ID is in control - Outside of GP, get cup pointer from map so Emerald is always the "canon" one --- src/p_user.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 71d8eb630..46829d0b7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -313,15 +313,29 @@ boolean P_PlayerMoving(INT32 pnum) // UINT8 P_GetNextEmerald(void) { - INT16 mapnum = gamemap-1; + cupheader_t *cup = NULL; - if (mapnum > nummapheaders || !mapheaderinfo[mapnum]) + if (grandprixinfo.gp == true) + { + cup = grandprixinfo.cup; + } + + if (cup == NULL) + { + INT16 mapnum = gamemap-1; + + if (mapnum < nummapheaders && mapheaderinfo[mapnum]) + { + cup = mapheaderinfo[mapnum]->cup; + } + } + + if (cup == NULL) + { return 0; + } - if (!mapheaderinfo[mapnum]->cup || mapheaderinfo[mapnum]->cup->cachedlevels[CUPCACHE_SPECIAL] != mapnum) - return 0; - - return mapheaderinfo[mapnum]->cup->emeraldnum; + return cup->emeraldnum; } //