Fix up them there ghosts!

* Stop orphaning their memory. They ARE PU_LEVEL, so they'll disappear eventually, but, like... it's not good memory management practice to just *orphan* them when you're literally never going to do anything with them ever again. Y'know?
* Make ghosts spawn properly on slopes.
This commit is contained in:
toaster 2018-08-25 17:11:49 +01:00
parent 9d3aad9036
commit 91eb248e46
1 changed files with 21 additions and 15 deletions

View File

@ -4362,6 +4362,7 @@ void G_GhostTicker(void)
p->next = g->next;
else
ghosts = g->next;
Z_Free(g);
continue;
}
p = g;
@ -5314,29 +5315,28 @@ void G_AddGhost(char *defdemoname)
mthing = playerstarts[0];
I_Assert(mthing);
{ // A bit more complex than P_SpawnPlayer because ghosts aren't solid and won't just push themselves out of the ceiling.
fixed_t x,y,z;
sector_t *sector;
x = mthing->x << FRACBITS;
y = mthing->y << FRACBITS;
sector = R_PointInSubsector(x, y)->sector;
fixed_t z,f,c;
gh->mo = P_SpawnMobj(mthing->x << FRACBITS, mthing->y << FRACBITS, 0, MT_GHOST);
gh->mo->angle = FixedAngle(mthing->angle*FRACUNIT);
f = gh->mo->floorz;
c = gh->mo->ceilingz - mobjinfo[MT_PLAYER].height;
if (!!(mthing->options & MTF_AMBUSH) ^ !!(mthing->options & MTF_OBJECTFLIP))
{
z = sector->ceilingheight - mobjinfo[MT_PLAYER].height;
z = c;
if (mthing->options >> ZSHIFT)
z -= ((mthing->options >> ZSHIFT) << FRACBITS);
if (z < sector->floorheight)
z = sector->floorheight;
if (z < f)
z = f;
}
else
{
z = sector->floorheight;
z = f;
if (mthing->options >> ZSHIFT)
z += ((mthing->options >> ZSHIFT) << FRACBITS);
if (z > sector->ceilingheight - mobjinfo[MT_PLAYER].height)
z = sector->ceilingheight - mobjinfo[MT_PLAYER].height;
if (z > c)
z = c;
}
gh->mo = P_SpawnMobj(x, y, z, MT_GHOST);
gh->mo->angle = FixedAngle(mthing->angle*FRACUNIT);
gh->mo->z = z;
}
gh->mo->state = states+S_PLAY_STND;
gh->mo->sprite = gh->mo->state->sprite;
@ -5534,8 +5534,14 @@ boolean G_CheckDemoStatus(void)
{
boolean saved;
if(ghosts) // ... ... ...
ghosts = NULL; // :)
while (ghosts)
{
demoghost *next = ghosts->next;
Z_Free(ghosts);
ghosts = next;
}
ghosts = NULL;
// DO NOT end metal sonic demos here