Create G_FreeGhosts, for the benefit of G_DeferedInitNew (assuming it actually needs to do ghosts = NULL; at all)

This commit is contained in:
Monster Iestyn 2020-03-19 20:42:51 +00:00
parent 1a14234088
commit dd76be16cb
3 changed files with 15 additions and 9 deletions

View file

@ -2223,6 +2223,18 @@ void G_AddGhost(char *defdemoname)
Z_Free(pdemoname);
}
// Clean up all ghosts
void G_FreeGhosts(void)
{
while (ghosts)
{
demoghost *next = ghosts->next;
Z_Free(ghosts);
ghosts = next;
}
ghosts = NULL;
}
//
// G_TimeDemo
// NOTE: name is a full filename for external demos
@ -2389,14 +2401,7 @@ boolean G_CheckDemoStatus(void)
{
boolean saved;
while (ghosts)
{
demoghost *next = ghosts->next;
Z_Free(ghosts);
ghosts = next;
}
ghosts = NULL;
G_FreeGhosts();
// DO NOT end metal sonic demos here

View file

@ -75,6 +75,7 @@ void G_DeferedPlayDemo(const char *demo);
void G_DoPlayDemo(char *defdemoname);
void G_TimeDemo(const char *name);
void G_AddGhost(char *defdemoname);
void G_FreeGhosts(void);
void G_DoPlayMetal(void);
void G_DoneLevelLoad(void);
void G_StopMetalDemo(void);

View file

@ -4490,7 +4490,7 @@ void G_DeferedInitNew(boolean pultmode, const char *mapname, INT32 pickedchar, b
if (demoplayback)
COM_BufAddText("stopdemo\n");
ghosts = NULL;
G_FreeGhosts(); // TODO: do we actually need to do this?
// this leave the actual game if needed
SV_StartSinglePlayerServer();