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
This commit is contained in:
toaster 2023-04-08 00:05:18 +01:00
parent 6ae455dbfc
commit 4b7aa368b5

View file

@ -312,16 +312,30 @@ boolean P_PlayerMoving(INT32 pnum)
// Gets the number (0 based) of the next emerald to obtain // Gets the number (0 based) of the next emerald to obtain
// //
UINT8 P_GetNextEmerald(void) UINT8 P_GetNextEmerald(void)
{
cupheader_t *cup = NULL;
if (grandprixinfo.gp == true)
{
cup = grandprixinfo.cup;
}
if (cup == NULL)
{ {
INT16 mapnum = gamemap-1; INT16 mapnum = gamemap-1;
if (mapnum > nummapheaders || !mapheaderinfo[mapnum]) if (mapnum < nummapheaders && mapheaderinfo[mapnum])
return 0; {
cup = mapheaderinfo[mapnum]->cup;
}
}
if (!mapheaderinfo[mapnum]->cup || mapheaderinfo[mapnum]->cup->cachedlevels[CUPCACHE_SPECIAL] != mapnum) if (cup == NULL)
{
return 0; return 0;
}
return mapheaderinfo[mapnum]->cup->emeraldnum; return cup->emeraldnum;
} }
// //