Have replay recording of "hits" use the reference count system, so that it doesn't potentially access free'd memory.

(This is not THE replay fix, but it is A replay fix.)
This commit is contained in:
toaster 2021-11-21 13:35:08 +00:00
parent d22705727b
commit fa8bffabfc

View file

@ -621,7 +621,7 @@ void G_GhostAddHit(INT32 playernum, mobj_t *victim)
ghostext[playernum].flags |= EZT_HIT; ghostext[playernum].flags |= EZT_HIT;
ghostext[playernum].hits++; ghostext[playernum].hits++;
ghostext[playernum].hitlist = Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_LEVEL, NULL); ghostext[playernum].hitlist = Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_LEVEL, NULL);
ghostext[playernum].hitlist[ghostext[playernum].hits-1] = victim; P_SetTarget(ghostext[playernum].hitlist + (ghostext[playernum].hits-1), victim);
} }
void G_WriteAllGhostTics(void) void G_WriteAllGhostTics(void)
@ -793,6 +793,7 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum)
WRITEFIXED(demo_p,mo->y); WRITEFIXED(demo_p,mo->y);
WRITEFIXED(demo_p,mo->z); WRITEFIXED(demo_p,mo->z);
WRITEANGLE(demo_p,mo->angle); WRITEANGLE(demo_p,mo->angle);
P_SetTarget(ghostext[playernum].hitlist+i, NULL);
} }
Z_Free(ghostext[playernum].hitlist); Z_Free(ghostext[playernum].hitlist);
ghostext[playernum].hits = 0; ghostext[playernum].hits = 0;