From 9c7eb2c6ff73333485cd34911a7fbf143ec3dfe3 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Sat, 25 Jun 2016 05:21:22 +0000 Subject: [PATCH] Host_Loadgame_f(): no need for entnum >= sv.max_edicts check because EDICT_NUM() does it already. also move ent->free=false statement to partial zero-fill case. Host_ClearMemory(): remove check before free(sv.edicts) SV_Init(): initialize sv.edicts to NULL (just paranoia) git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1319 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/host.c | 2 +- Quake/host_cmd.c | 11 ++++++----- Quake/sv_main.c | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Quake/host.c b/Quake/host.c index 7d3e16e4..8481b09c 100644 --- a/Quake/host.c +++ b/Quake/host.c @@ -549,7 +549,7 @@ void Host_ClearMemory (void) /* host_hunklevel MUST be set at this point */ Hunk_FreeToLowMark (host_hunklevel); cls.signon = 0; - if (sv.edicts) free(sv.edicts); // ericw -- sv.edicts switched to use malloc() + free(sv.edicts); // ericw -- sv.edicts switched to use malloc() memset (&sv, 0, sizeof(sv)); memset (&cl, 0, sizeof(cl)); } diff --git a/Quake/host_cmd.c b/Quake/host_cmd.c index acd79604..fa367738 100644 --- a/Quake/host_cmd.c +++ b/Quake/host_cmd.c @@ -1226,16 +1226,17 @@ void Host_Loadgame_f (void) else { // parse an edict ent = EDICT_NUM(entnum); + #if 0 /* EDICT_NUM() checks this already */ + if (entnum >= sv.max_edicts) + Host_Error ("Loadgame: no free edicts (max_edicts is %i)", sv.max_edicts); + #endif if (entnum < sv.num_edicts) { + ent->free = false; memset (&ent->v, 0, progs->entityfields * 4); } - else if (entnum < sv.max_edicts) { + else { memset (ent, 0, pr_edict_size); } - else { - Host_Error ("Loadgame: no free edicts (max_edicts is %i)", sv.max_edicts); - } - ent->free = false; ED_ParseEdict (start, ent); // link it into the bsp tree diff --git a/Quake/sv_main.c b/Quake/sv_main.c index 431b12ca..401b43ad 100644 --- a/Quake/sv_main.c +++ b/Quake/sv_main.c @@ -87,6 +87,8 @@ void SV_Init (void) extern cvar_t sv_aim; extern cvar_t sv_altnoclip; //johnfitz + sv.edicts = NULL; // ericw -- sv.edicts switched to use malloc() + Cvar_RegisterVariable (&sv_maxvelocity); Cvar_RegisterVariable (&sv_gravity); Cvar_RegisterVariable (&sv_friction);