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

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