mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-26 12:01:47 +00:00
M_UpdateNextPrisonEggPickup: Stop trying to be so pre-optimised and just do the job plainly
Should resolve the crash which for some reason doesn't have an issue to reference here
Also, for `debugprisoncd On`:
- Extensive debug logging
- Disable the "if all achieved, still force a pre-existing CD" behaviour
- The list is empty if you've achieved every Prison CD and then restart the game, so it wasn't consistent at always making something. Without that kind of reliability I think it's more important for it to just be a fastforward
This commit is contained in:
parent
9e549d5607
commit
d2ddeb65f2
2 changed files with 46 additions and 30 deletions
75
src/m_cond.c
75
src/m_cond.c
|
|
@ -689,7 +689,6 @@ void M_ClearSecrets(void)
|
||||||
Z_Free(gamedata->prisoneggpickups);
|
Z_Free(gamedata->prisoneggpickups);
|
||||||
gamedata->prisoneggpickups = NULL;
|
gamedata->prisoneggpickups = NULL;
|
||||||
gamedata->numprisoneggpickups = 0;
|
gamedata->numprisoneggpickups = 0;
|
||||||
gamedata->gettableprisoneggpickups = 0;
|
|
||||||
gamedata->thisprisoneggpickup = MAXCONDITIONSETS;
|
gamedata->thisprisoneggpickup = MAXCONDITIONSETS;
|
||||||
gamedata->thisprisoneggpickup_cached = NULL;
|
gamedata->thisprisoneggpickup_cached = NULL;
|
||||||
gamedata->thisprisoneggpickupgrabbed = false;
|
gamedata->thisprisoneggpickupgrabbed = false;
|
||||||
|
|
@ -915,12 +914,14 @@ static void M_InitPrisonEggPickups(void)
|
||||||
|
|
||||||
void M_UpdateNextPrisonEggPickup(void)
|
void M_UpdateNextPrisonEggPickup(void)
|
||||||
{
|
{
|
||||||
UINT16 i = gamedata->gettableprisoneggpickups, j, swap;
|
UINT16 i, j, swap;
|
||||||
|
|
||||||
conditionset_t *c;
|
conditionset_t *c;
|
||||||
condition_t *cn;
|
condition_t *cn;
|
||||||
|
|
||||||
boolean firstrun = true;
|
#ifdef DEVELOP
|
||||||
|
extern consvar_t cv_debugprisoncd;
|
||||||
|
#endif
|
||||||
|
|
||||||
cacheprisoneggpickup:
|
cacheprisoneggpickup:
|
||||||
|
|
||||||
|
|
@ -928,7 +929,11 @@ cacheprisoneggpickup:
|
||||||
gamedata->thisprisoneggpickup_cached = NULL;
|
gamedata->thisprisoneggpickup_cached = NULL;
|
||||||
if (gamedata->thisprisoneggpickup < MAXCONDITIONSETS)
|
if (gamedata->thisprisoneggpickup < MAXCONDITIONSETS)
|
||||||
{
|
{
|
||||||
//CONS_Printf("CACHE TEST: thisprisoneggpickup is set to %u\n", gamedata->thisprisoneggpickup);
|
#ifdef DEVELOP
|
||||||
|
if (cv_debugprisoncd.value)
|
||||||
|
CONS_Printf("CACHE TEST: thisprisoneggpickup is set to %u\n", gamedata->thisprisoneggpickup);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (gamedata->achieved[gamedata->thisprisoneggpickup] == false)
|
if (gamedata->achieved[gamedata->thisprisoneggpickup] == false)
|
||||||
{
|
{
|
||||||
c = &conditionSets[gamedata->thisprisoneggpickup];
|
c = &conditionSets[gamedata->thisprisoneggpickup];
|
||||||
|
|
@ -945,7 +950,12 @@ cacheprisoneggpickup:
|
||||||
|
|
||||||
// Good! Attach the cache.
|
// Good! Attach the cache.
|
||||||
gamedata->thisprisoneggpickup_cached = cn;
|
gamedata->thisprisoneggpickup_cached = cn;
|
||||||
//CONS_Printf(" successfully set to cn!\n");
|
|
||||||
|
#ifdef DEVELOP
|
||||||
|
if (cv_debugprisoncd.value)
|
||||||
|
CONS_Printf(" successfully set to cn!\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -958,9 +968,16 @@ cacheprisoneggpickup:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstrun && gamedata->numprisoneggpickups && gamedata->thisprisoneggpickup == MAXCONDITIONSETS)
|
if (gamedata->numprisoneggpickups && gamedata->thisprisoneggpickup >= MAXCONDITIONSETS)
|
||||||
{
|
{
|
||||||
for (; i < gamedata->numprisoneggpickups; i++)
|
#ifdef DEVELOP
|
||||||
|
if (cv_debugprisoncd.value)
|
||||||
|
CONS_Printf(" Invalid thisprisoneggpickup, rolling a random one...\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UINT16 gettableprisoneggpickups = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < gamedata->numprisoneggpickups; i++)
|
||||||
{
|
{
|
||||||
if (gamedata->achieved[gamedata->prisoneggpickups[i]] == false)
|
if (gamedata->achieved[gamedata->prisoneggpickups[i]] == false)
|
||||||
{
|
{
|
||||||
|
|
@ -979,12 +996,15 @@ cacheprisoneggpickup:
|
||||||
|
|
||||||
// Okay, this should be available.
|
// Okay, this should be available.
|
||||||
// Bring to the front!
|
// Bring to the front!
|
||||||
swap = gamedata->prisoneggpickups[gamedata->gettableprisoneggpickups];
|
if (i != gettableprisoneggpickups)
|
||||||
gamedata->prisoneggpickups[gamedata->gettableprisoneggpickups] =
|
{
|
||||||
gamedata->prisoneggpickups[i];
|
swap = gamedata->prisoneggpickups[gettableprisoneggpickups];
|
||||||
gamedata->prisoneggpickups[i] = swap;
|
gamedata->prisoneggpickups[gettableprisoneggpickups] =
|
||||||
|
gamedata->prisoneggpickups[i];
|
||||||
|
gamedata->prisoneggpickups[i] = swap;
|
||||||
|
}
|
||||||
|
|
||||||
gamedata->gettableprisoneggpickups++;
|
gettableprisoneggpickups++;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -993,36 +1013,31 @@ cacheprisoneggpickup:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fell all the way through?
|
|
||||||
// Push this all the way to the back, and lop it off!
|
|
||||||
|
|
||||||
swap = gamedata->prisoneggpickups[gamedata->numprisoneggpickups];
|
|
||||||
gamedata->prisoneggpickups[gamedata->numprisoneggpickups] =
|
|
||||||
gamedata->prisoneggpickups[i];
|
|
||||||
gamedata->prisoneggpickups[i] = swap;
|
|
||||||
|
|
||||||
gamedata->numprisoneggpickups--;
|
|
||||||
i--; // We run the loop again for this entry
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gamedata->gettableprisoneggpickups)
|
if (gettableprisoneggpickups != 0)
|
||||||
{
|
{
|
||||||
gamedata->thisprisoneggpickup =
|
gamedata->thisprisoneggpickup =
|
||||||
gamedata->prisoneggpickups[
|
gamedata->prisoneggpickups[
|
||||||
M_RandomKey(gamedata->gettableprisoneggpickups)
|
M_RandomKey(gettableprisoneggpickups)
|
||||||
];
|
];
|
||||||
|
|
||||||
firstrun = false;
|
#ifdef DEVELOP
|
||||||
|
if (cv_debugprisoncd.value)
|
||||||
|
CONS_Printf(" Selected %u, trying again...\n", gamedata->thisprisoneggpickup);
|
||||||
|
#endif
|
||||||
|
|
||||||
goto cacheprisoneggpickup;
|
goto cacheprisoneggpickup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//CONS_Printf("thisprisoneggpickup = %u (MAXCONDITIONSETS is %u)\n", gamedata->thisprisoneggpickup, MAXCONDITIONSETS);
|
|
||||||
|
|
||||||
#ifdef DEVELOP
|
#ifdef DEVELOP
|
||||||
extern consvar_t cv_debugprisoncd;
|
if (cv_debugprisoncd.value)
|
||||||
|
CONS_Printf("thisprisoneggpickup = %u (MAXCONDITIONSETS is %u)\n", gamedata->thisprisoneggpickup, MAXCONDITIONSETS);
|
||||||
|
|
||||||
|
#if 0
|
||||||
// If all drops are collected, just force the first valid one.
|
// If all drops are collected, just force the first valid one.
|
||||||
|
// THIS DOESN'T ACTUALLY WORK IF ALL PRISON PRIZES HAVE BEEN REDEEMED AND THE GAME IS RELAUNCHED, so it is not reliable enough to expose as a debugging tool
|
||||||
if (cv_debugprisoncd.value && gamedata->thisprisoneggpickup_cached == NULL)
|
if (cv_debugprisoncd.value && gamedata->thisprisoneggpickup_cached == NULL)
|
||||||
{
|
{
|
||||||
for (i = 0; gamedata->thisprisoneggpickup_cached == NULL &&
|
for (i = 0; gamedata->thisprisoneggpickup_cached == NULL &&
|
||||||
|
|
@ -1045,6 +1060,8 @@ cacheprisoneggpickup:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // DEVELOP
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M_PrecacheLevelLocks(void)
|
static void M_PrecacheLevelLocks(void)
|
||||||
|
|
|
||||||
|
|
@ -352,7 +352,6 @@ struct gamedata_t
|
||||||
|
|
||||||
// PRISON EGG PICKUPS
|
// PRISON EGG PICKUPS
|
||||||
UINT16 numprisoneggpickups;
|
UINT16 numprisoneggpickups;
|
||||||
UINT16 gettableprisoneggpickups;
|
|
||||||
UINT16 thisprisoneggpickup;
|
UINT16 thisprisoneggpickup;
|
||||||
condition_t *thisprisoneggpickup_cached;
|
condition_t *thisprisoneggpickup_cached;
|
||||||
boolean thisprisoneggpickupgrabbed;
|
boolean thisprisoneggpickupgrabbed;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue