From 21164088e07ee1abe38b269abf954d07fe656d63 Mon Sep 17 00:00:00 2001 From: divverent Date: Thu, 9 Apr 2009 12:05:29 +0000 Subject: [PATCH] use "realtime", not the float time global, for entity allocation and freeing to protect the entity slot for 0.5 seconds (now 1 second). Should help entity networking a lot, as the time global doesn't grow monotonically when cl_movement is used on a client (basically, a client with 500ms latency can free an entity in PlayerPreThink, and that entity slot could get immediately reused in the next server frame or think function). git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8891 d7cf8633-e32d-0410-b094-e92efae38249 --- prvm_edict.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prvm_edict.c b/prvm_edict.c index be8af7c9..24eeb734 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -262,7 +262,7 @@ prvm_edict_t *PRVM_ED_Alloc (void) e = PRVM_EDICT_NUM(i); // the first couple seconds of server time can involve a lot of // freeing and allocating, so relax the replacement policy - if (e->priv.required->free && ( e->priv.required->freetime < 2 || prog->globaloffsets.time < 0 || (PRVM_GLOBALFIELDVALUE(prog->globaloffsets.time)->_float - e->priv.required->freetime) > 0.5 ) ) + if (e->priv.required->free && ( e->priv.required->freetime < prog->starttime + 2 || (realtime - e->priv.required->freetime) > 1 ) ) { PRVM_ED_ClearEdict (e); e->priv.required->allocation_origin = PRVM_AllocationOrigin(); @@ -302,7 +302,7 @@ void PRVM_ED_Free (prvm_edict_t *ed) PRVM_GCALL(free_edict)(ed); ed->priv.required->free = true; - ed->priv.required->freetime = prog->globaloffsets.time >= 0 ? PRVM_GLOBALFIELDVALUE(prog->globaloffsets.time)->_float : 0; + ed->priv.required->freetime = realtime; if(ed->priv.required->allocation_origin) { PRVM_Free((char *)ed->priv.required->allocation_origin); -- 2.39.2