mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-01-25 16:06:09 +00:00
p_mobj.c: reference count kitemcap and overlaycap
With the old code, if the object at the head of the list was removed, it would leave the reference behind, extending the lifetime of the thinker until P_RunKartItems or P_RunOverlays was run.
This commit is contained in:
parent
b8a41fa509
commit
33145ab2ae
1 changed files with 8 additions and 8 deletions
16
src/p_mobj.c
16
src/p_mobj.c
|
|
@ -5280,13 +5280,13 @@ void P_AddKartItem(mobj_t *thing)
|
|||
// Keeps the hnext list from corrupting.
|
||||
static void P_RemoveKartItem(mobj_t *thing)
|
||||
{
|
||||
mobj_t *mo;
|
||||
for (mo = kitemcap; mo; mo = mo->itnext)
|
||||
mobj_t *mo, **p;
|
||||
for (mo = *(p = &kitemcap); mo; mo = *(p = &mo->itnext))
|
||||
{
|
||||
if (mo->itnext != thing)
|
||||
if (mo != thing)
|
||||
continue;
|
||||
|
||||
P_SetTarget(&mo->itnext, thing->itnext);
|
||||
P_SetTarget(p, thing->itnext);
|
||||
P_SetTarget(&thing->itnext, NULL);
|
||||
return;
|
||||
}
|
||||
|
|
@ -5433,13 +5433,13 @@ static void P_AddOverlay(mobj_t *thing)
|
|||
// Keeps the hnext list from corrupting.
|
||||
static void P_RemoveOverlay(mobj_t *thing)
|
||||
{
|
||||
mobj_t *mo;
|
||||
for (mo = overlaycap; mo; mo = mo->hnext)
|
||||
mobj_t *mo, **p;
|
||||
for (mo = *(p = &overlaycap); mo; mo = *(p = &mo->hnext))
|
||||
{
|
||||
if (mo->hnext != thing)
|
||||
if (mo != thing)
|
||||
continue;
|
||||
|
||||
P_SetTarget(&mo->hnext, thing->hnext);
|
||||
P_SetTarget(p, thing->hnext);
|
||||
P_SetTarget(&thing->hnext, NULL);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue