[nq] Fix a particularly nasty memory leak

Nasty because it was caused by spaghetti (normally, I like the stuff).
Drinking-age spaghetti at that. Nicely, this removes the need for one
function in sv_ded.c (which is what I think I was trying to achieve).
This commit is contained in:
Bill Currie 2022-05-12 22:49:48 +09:00
parent a17deb3ef2
commit 1f811e6310
3 changed files with 19 additions and 29 deletions

View file

@ -231,9 +231,27 @@ CL_ClearMemory (void)
SCR_SetFullscreen (0);
cls.signon = 0;
SZ_Clear (&cls.message);
if (cl.viewstate.weapon_entity) {
Scene_DestroyEntity (cl_world.scene, cl.viewstate.weapon_entity);
}
if (cl.players) {
int i;
for (i = 0; i < cl.maxclients; i++)
Info_Destroy (cl.players[i].userinfo);
}
// wipe the entire cl structure
__auto_type cam = cl.viewstate.camera_transform;
memset (&cl, 0, sizeof (cl));
cl.viewstate.camera_transform = cam;
CL_ClearTEnts ();
SCR_NewScene (0);
CL_ClearEnts ();
}
void
@ -267,24 +285,10 @@ CL_InitCvars (void)
void
CL_ClearState (void)
{
CL_ClearMemory ();
if (!sv.active)
Host_ClearMemory ();
if (cl.viewstate.weapon_entity) {
Scene_DestroyEntity (cl_world.scene, cl.viewstate.weapon_entity);
}
if (cl.players) {
int i;
for (i = 0; i < cl.maxclients; i++)
Info_Destroy (cl.players[i].userinfo);
}
// wipe the entire cl structure
__auto_type cam = cl.viewstate.camera_transform;
memset (&cl, 0, sizeof (cl));
cl.viewstate.camera_transform = cam;
cl.viewstate.player_origin = (vec4f_t) {0, 0, 0, 1};
cl.viewstate.chase = 1;
cl.viewstate.chasestate = &cl.chasestate;
@ -293,14 +297,6 @@ CL_ClearState (void)
SCR_SetFullscreen (0);
r_data->lightstyle = cl.lightstyle;
SZ_Clear (&cls.message);
CL_ClearTEnts ();
SCR_NewScene (0);
CL_ClearEnts ();
cl.viewstate.weapon_entity = Scene_CreateEntity (cl_world.scene);
CL_Init_Entity (cl.viewstate.weapon_entity);
r_data->view_model = cl.viewstate.weapon_entity;

View file

@ -627,7 +627,6 @@ void
Host_ClearMemory (void)
{
Sys_MaskPrintf (SYS_dev, "Clearing memory\n");
CL_ClearMemory ();
Mod_ClearAll ();
if (host_hunklevel)
Hunk_FreeToLowMark (0, host_hunklevel);

View file

@ -72,11 +72,6 @@ CL_UpdateScreen (double realtime)
{
}
void
CL_ClearMemory (void)
{
}
void
CL_Cmd_ForwardToServer (void)
{