mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Fix mobjcache memory leak after reloading gamestate
Weird history splice from 711804be
This commit is contained in:
parent
b3086d011d
commit
7d584c1f79
3 changed files with 22 additions and 12 deletions
|
|
@ -258,6 +258,7 @@ mobjtype_t P_GetMobjtype(UINT16 mthingtype);
|
|||
void P_RespawnSpecials(void);
|
||||
|
||||
fixed_t P_GetMobjDefaultScale(mobj_t *mobj);
|
||||
mobj_t *P_AllocateMobj(void);
|
||||
mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type);
|
||||
|
||||
void P_CalculatePrecipFloor(precipmobj_t *mobj);
|
||||
|
|
|
|||
29
src/p_mobj.c
29
src/p_mobj.c
|
|
@ -10844,6 +10844,24 @@ static void P_DefaultMobjShadowScale(mobj_t *thing)
|
|||
}
|
||||
}
|
||||
|
||||
mobj_t *P_AllocateMobj(void)
|
||||
{
|
||||
mobj_t *mobj;
|
||||
|
||||
if (mobjcache != NULL)
|
||||
{
|
||||
mobj = mobjcache;
|
||||
mobjcache = mobjcache->hnext;
|
||||
memset(mobj, 0, sizeof(*mobj));
|
||||
}
|
||||
else
|
||||
{
|
||||
mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL);
|
||||
}
|
||||
|
||||
return mobj;
|
||||
}
|
||||
|
||||
//
|
||||
// P_SpawnMobj
|
||||
//
|
||||
|
|
@ -10870,16 +10888,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
|
|||
type = MT_RAY;
|
||||
}
|
||||
|
||||
if (mobjcache != NULL)
|
||||
{
|
||||
mobj = mobjcache;
|
||||
mobjcache = mobjcache->hnext;
|
||||
memset(mobj, 0, sizeof(*mobj));
|
||||
}
|
||||
else
|
||||
{
|
||||
mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL);
|
||||
}
|
||||
mobj = P_AllocateMobj();
|
||||
|
||||
// this is officially a mobj, declared as soon as possible.
|
||||
mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker;
|
||||
|
|
|
|||
|
|
@ -4511,13 +4511,13 @@ static thinker_t* LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
mobj = (mobj_t*)Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL);
|
||||
mobj = P_AllocateMobj();
|
||||
|
||||
mobj->spawnpoint = &mapthings[spawnpointnum];
|
||||
mapthings[spawnpointnum].mobj = mobj;
|
||||
}
|
||||
else
|
||||
mobj = (mobj_t*)Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL);
|
||||
mobj = P_AllocateMobj();
|
||||
|
||||
// declare this as a valid mobj as soon as possible.
|
||||
mobj->thinker.function.acp1 = thinker;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue