P_InitThinkers: Handle several important mobj cleaning tasks in one place, rather than scattered

- titlecam.mobj cannot have P_SetTarget applied when initially setting to NULL, as its previous occupant is some unknown region in memory, and modifying the reference count could in fact change some random number or address ANYWHERE IN THE ENTIRE PROGRAM.
- So we straight up wipe it rather than referenced-unset it in one place, always, for general tidiness.
- Also move skyboxcenterpnts, skyboxviewpnts, and iquetail/iquehead so it's all centralised.
This commit is contained in:
toaster 2023-05-31 12:49:51 +01:00
parent ff23501e74
commit 1821b4f52d
7 changed files with 17 additions and 19 deletions

View file

@ -435,6 +435,8 @@ struct altview_t
INT32 tics;
};
extern altview_t titlemapcam;
// ========================================================================
// PLAYER STRUCTURE
// ========================================================================

View file

@ -1848,7 +1848,6 @@ void F_StartTitleScreen(void)
gamestate_t prevwipegamestate = wipegamestate;
titlemapinaction = true;
P_SetTarget(&titlemapcam.mobj, NULL);
gamemap = titleMapNum+1;
maptol = mapheaderinfo[titleMapNum]->typeoflevel;

View file

@ -105,9 +105,6 @@ extern UINT16 tttics;
extern boolean ttavailable[6];
// Current menu parameters
extern altview_t titlemapcam;
extern char curbgname[9];
extern SINT8 curfadevalue;
extern INT32 curbgcolor;

View file

@ -247,8 +247,6 @@ boolean K_StartCeremony(void)
&& mapheaderinfo[podiumMapNum]
&& mapheaderinfo[podiumMapNum]->lumpnum != LUMPERROR)
{
P_SetTarget(&titlemapcam.mobj, NULL);
gamemap = podiumMapNum+1;
maptol = mapheaderinfo[gamemap-1]->typeoflevel;

View file

@ -4526,16 +4526,8 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save)
}
// we don't want the removed mobjs to come back
iquetail = iquehead = 0;
P_InitThinkers();
// Oh my god don't blast random memory with our reference counts.
waypointcap = trackercap = NULL;
for (i = 0; i <= 15; i++)
{
skyboxcenterpnts[i] = skyboxviewpnts[i] = NULL;
}
// clear sector thinker pointers so they don't point to non-existant thinkers for all of eternity
for (i = 0; i < numsectors; i++)
{

View file

@ -8291,9 +8291,6 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
K_InitDirector();
}
// clear special respawning que
iquehead = iquetail = 0;
// Initialize ACS scripts
if (!fromnetsave)
{

View file

@ -213,10 +213,23 @@ void Command_CountMobjs_f(void)
void P_InitThinkers(void)
{
UINT8 i;
for (i = 0; i < NUM_THINKERLISTS; i++)
{
thlist[i].prev = thlist[i].next = &thlist[i];
}
iquehead = iquetail = 0;
waypointcap = NULL;
trackercap = NULL;
for (i = 0; i < NUM_THINKERLISTS; i++)
thlist[i].prev = thlist[i].next = &thlist[i];
titlemapcam.mobj = NULL;
for (i = 0; i <= 15; i++)
{
skyboxcenterpnts[i] = skyboxviewpnts[i] = NULL;
}
}
// Adds a new thinker at the end of the list.