fix frame lerp again, dynamically allocate client baselines (should save about 2MB of memory on typical servers), bounds check baselines (stops invalid svc_spawnbaseline from crashing), small DP extension fix, fix demo baselines

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2365 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-07-24 04:24:41 +00:00
parent 0089cf5a3f
commit 084c095dc7
7 changed files with 56 additions and 23 deletions

View File

@ -765,7 +765,7 @@ void CL_Record_f (void)
int n, i, j;
char *s, *p, *fname;
entity_t *ent;
entity_state_t *es, blankes;
entity_state_t *es;
player_info_t *player;
extern char gamedirfile[];
int seq = 1;
@ -1051,12 +1051,11 @@ void CL_Record_f (void)
// baselines
memset(&blankes, 0, sizeof(blankes));
for (i = 0; i < MAX_EDICTS; i++)
for (i = 0; i < cl_baselines_count; i++)
{
es = cl_baselines + i;
if (memcmp(es, &blankes, sizeof(blankes)))
if (memcmp(es, &nullentitystate, sizeof(nullentitystate)))
{
MSG_WriteByte (&buf,svc_spawnbaseline);
MSG_WriteShort (&buf, i);

View File

@ -604,7 +604,9 @@ void CL_ParsePacketEntities (qboolean delta)
newp->entities = BZ_Realloc(newp->entities, sizeof(entity_state_t)*newp->max_entities);
}
CL_ParseDelta (&cl_baselines[newnum], &newp->entities[newindex], word, true);
if (!CL_CheckBaselines(newnum))
Host_EndGame("CL_ParsePacketEntities: check baselines failed with size %i", newnum);
CL_ParseDelta (cl_baselines + newnum, &newp->entities[newindex], word, true);
newindex++;
continue;
}
@ -1064,7 +1066,9 @@ void CLNQ_ParseEntity(unsigned int bits)
from = CL_FindOldPacketEntity(num); //this could be optimised.
base = &cl_baselines[num];
if (!CL_CheckBaselines(num))
Host_EndGame("CLNQ_ParseEntity: check baselines failed with size %i", num);
base = cl_baselines + num;
state->number = num;
@ -2661,7 +2665,7 @@ guess_pm_type:
if (cl.lerpplayers[num].frame != state->frame)
{
cl.lerpplayers[num].oldframechange = cl.lerpplayers[num].framechange;
cl.lerpplayers[num].framechange = cl.servertime;
cl.lerpplayers[num].framechange = cl.time;
cl.lerpplayers[num].frame = state->frame;
//don't care about position interpolation.
@ -3058,8 +3062,8 @@ void CL_LinkViewModel(void)
lerptime[r_refdef.currentplayernum] = realtime;
}
ent.lerpfrac = 1-(realtime-lerptime[r_refdef.currentplayernum])*10;
if (ent.lerpfrac<0)ent.lerpfrac=0;
if (ent.lerpfrac>1)ent.lerpfrac=1;
ent.lerpfrac = bound(0, ent.lerpfrac, 1);
#define Q2RF_VIEWERMODEL 2 // don't draw through eyes, only mirrors
#define Q2RF_WEAPONMODEL 4 // only draw through eyes
#define Q2RF_DEPTHHACK 16 // for view weapon Z crunching

View File

@ -155,7 +155,7 @@ client_static_t cls;
client_state_t cl;
// alot of this should probably be dynamically allocated
entity_state_t cl_baselines[MAX_EDICTS];
entity_state_t *cl_baselines;
efrag_t cl_efrags[MAX_EFRAGS];
entity_t cl_static_entities[MAX_STATIC_ENTITIES];
trailstate_t *cl_static_emit[MAX_STATIC_ENTITIES];
@ -163,6 +163,7 @@ lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
//lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
dlight_t cl_dlights[MAX_DLIGHTS];
int cl_baselines_count;
int dlights_running, dlights_software;
// refresh list
@ -987,12 +988,12 @@ void CL_ClearState (void)
dlights_running = 0;
for (i = 0; i < MAX_EDICTS; i++)
if (cl_baselines)
{
memcpy(&cl_baselines[i], &nullentitystate, sizeof(cl_baselines[i]));
BZ_Free(cl_baselines);
cl_baselines = NULL;
}
cl_baselines_count = 0;
//
// allocate the efrags and chain together into a free list

View File

@ -2320,6 +2320,30 @@ void CLQ2_ParseConfigString (void)
#endif
qboolean CL_CheckBaselines (int size)
{
int i;
if (size < 0)
return false;
if (size > MAX_EDICTS)
return false;
size = (size + 64) & ~63; // round up to next 64
if (size < cl_baselines_count)
return true;
cl_baselines = BZ_Realloc(cl_baselines, sizeof(*cl_baselines)*size);
for (i = cl_baselines_count; i < size; i++)
{
memcpy(cl_baselines + i, &nullentitystate, sizeof(*cl_baselines));
}
cl_baselines_count = size;
return true;
}
/*
==================
CL_ParseBaseline
@ -2347,7 +2371,9 @@ void CL_ParseBaseline2 (void)
entity_state_t es;
CL_ParseDelta(&nullentitystate, &es, MSG_ReadShort(), true);
memcpy(&cl_baselines[es.number], &es, sizeof(es));
if (!CL_CheckBaselines(es.number))
Host_EndGame("CL_ParseBaseline2: check baselines failed with size %i", es.number);
memcpy(cl_baselines + es.number, &es, sizeof(es));
}
void CLQ2_Precache_f (void)
@ -4007,7 +4033,9 @@ void CL_ParseServerMessage (void)
case svc_spawnbaseline:
i = MSG_ReadShort ();
CL_ParseBaseline (&cl_baselines[i]);
if (!CL_CheckBaselines(i))
Host_EndGame("CL_ParseServerMessage: svc_spawnbaseline failed with size %i", i);
CL_ParseBaseline (cl_baselines + i);
break;
case svc_spawnbaseline2:
CL_ParseBaseline2 ();
@ -4678,7 +4706,9 @@ void CLNQ_ParseServerMessage (void)
case svc_spawnbaseline:
i = MSG_ReadShort ();
CL_ParseBaseline (&cl_baselines[i]);
if (!CL_CheckBaselines(i))
Host_EndGame("CLNQ_ParseServerMessage: svc_spawnbaseline failed with size %i", i);
CL_ParseBaseline (cl_baselines + i);
break;
case svc_time:

View File

@ -638,7 +638,7 @@ extern cvar_t name;
extern client_state_t cl;
// FIXME, allocate dynamically
extern entity_state_t cl_baselines[MAX_EDICTS];
extern entity_state_t *cl_baselines;
extern efrag_t cl_efrags[MAX_EFRAGS];
extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
extern trailstate_t *cl_static_emit[MAX_STATIC_ENTITIES];
@ -646,6 +646,7 @@ extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
extern dlight_t cl_dlights[MAX_DLIGHTS];
extern int dlights_running, dlights_software;
extern int cl_baselines_count;
extern qboolean nomaster;
extern float server_version; // version of server we connected to

View File

@ -458,6 +458,8 @@ enum clcq2_ops_e
#define U_COLOURMOD (1<<10) //rgb
#define U_DPFLAGS (1<<11)
#define U_TAGINFO (1<<12)
#define U_LIGHT (1<<13)
#define U_EFFECTS16 (1<<14)

View File

@ -543,12 +543,8 @@ void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qb
if ((to->colormod[0]!=from->colormod[0]||to->colormod[1]!=from->colormod[1]||to->colormod[2]!=from->colormod[2]) && protext & PEXT_COLOURMOD)
evenmorebits |= U_COLOURMOD;
if (to->dpflags != from->dpflags && protext & PEXT_DPFLAGS)
evenmorebits |= U_DPFLAGS;
if (to->glowsize != from->glowsize)
to->dpflags |= 4;
to->dpflags |= 2; // RENDER_GLOWTRAIL
if (to->dpflags != from->dpflags && protext & PEXT_DPFLAGS)
evenmorebits |= U_DPFLAGS;