#include "quakedef.h"
-#define E5_PROTOCOL_PRIORITYLEVELS 32
-
// this is 88 bytes (must match entity_state_t in protocol.h)
entity_state_t defaultstate =
{
{0, NULL}
};
-static entity_frame_t deltaframe; // FIXME?
-static entity_frame_t framedata; // FIXME?
-
-int entityframe5_prioritychaincounts[E5_PROTOCOL_PRIORITYLEVELS];
-unsigned short entityframe5_prioritychains[E5_PROTOCOL_PRIORITYLEVELS][ENTITYFRAME5_MAXSTATES];
-
protocolversion_t Protocol_EnumForName(const char *s)
{
int i;
void EntityFrame_WriteFrame(sizebuf_t *msg, entityframe_database_t *d, int numstates, const entity_state_t *states, int viewentnum)
{
int i, onum, number;
- entity_frame_t *o = &deltaframe;
+ entity_frame_t *o = &d->deltaframe;
const entity_state_t *ent, *delta;
vec3_t eye;
prvm_eval_t *val;
void EntityFrame_CL_ReadFrame(void)
{
int i, number, removed;
- entity_frame_t *f = &framedata, *delta = &deltaframe;
+ entity_frame_t *f, *delta;
entity_state_t *e, *old, *oldend;
entity_t *ent;
entityframe_database_t *d;
if (!cl.entitydatabase)
cl.entitydatabase = EntityFrame_AllocDatabase(cls.levelmempool);
d = cl.entitydatabase;
+ f = &d->framedata;
+ delta = &d->deltaframe;
EntityFrame_Clear(f, NULL, -1);
entity_state_t *s;
// if it is the player, update urgently
if (stateindex == d->viewentnum)
- return E5_PROTOCOL_PRIORITYLEVELS - 1;
+ return ENTITYFRAME5_PRIORITYLEVELS - 1;
// priority increases each frame no matter what happens
priority = d->priorities[stateindex] + 1;
// players get an extra priority boost
if (!d->states[stateindex].active)
{
priority++;
- return bound(1, priority, E5_PROTOCOL_PRIORITYLEVELS - 1);
+ return bound(1, priority, ENTITYFRAME5_PRIORITYLEVELS - 1);
}
// certain changes are more noticable than others
if (d->deltabits[stateindex] & (E5_FULLUPDATE | E5_ATTACHMENT | E5_MODEL | E5_FLAGS | E5_COLORMAP))
// distance from the player
if (VectorDistance(d->states[d->viewentnum].netcenter, s->netcenter) < 1024.0f)
priority++;
- return bound(1, priority, E5_PROTOCOL_PRIORITYLEVELS - 1);
+ return bound(1, priority, ENTITYFRAME5_PRIORITYLEVELS - 1);
}
void EntityState5_WriteUpdate(int number, const entity_state_t *s, int changedbits, sizebuf_t *msg)
return;
// build lists of entities by priority level
- memset(entityframe5_prioritychaincounts, 0, sizeof(entityframe5_prioritychaincounts));
+ memset(d->prioritychaincounts, 0, sizeof(d->prioritychaincounts));
l = 0;
for (num = 0;num < d->maxedicts;num++)
{
{
if (d->deltabits[num])
{
- if (d->priorities[num] < (E5_PROTOCOL_PRIORITYLEVELS - 1))
+ if (d->priorities[num] < (ENTITYFRAME5_PRIORITYLEVELS - 1))
d->priorities[num] = EntityState5_Priority(d, num);
l = num;
priority = d->priorities[num];
- if (entityframe5_prioritychaincounts[priority] < ENTITYFRAME5_MAXSTATES)
- entityframe5_prioritychains[priority][entityframe5_prioritychaincounts[priority]++] = num;
+ if (d->prioritychaincounts[priority] < ENTITYFRAME5_MAXSTATES)
+ d->prioritychains[priority][d->prioritychaincounts[priority]++] = num;
}
else
d->priorities[num] = 0;
MSG_WriteLong(msg, framenum);
if (sv.protocol != PROTOCOL_QUAKE && sv.protocol != PROTOCOL_QUAKEDP && sv.protocol != PROTOCOL_NEHAHRAMOVIE && sv.protocol != PROTOCOL_DARKPLACES1 && sv.protocol != PROTOCOL_DARKPLACES2 && sv.protocol != PROTOCOL_DARKPLACES3 && sv.protocol != PROTOCOL_DARKPLACES4 && sv.protocol != PROTOCOL_DARKPLACES5 && sv.protocol != PROTOCOL_DARKPLACES6)
MSG_WriteLong(msg, movesequence);
- for (priority = E5_PROTOCOL_PRIORITYLEVELS - 1;priority >= 0 && packetlog->numstates < ENTITYFRAME5_MAXSTATES;priority--)
+ for (priority = ENTITYFRAME5_PRIORITYLEVELS - 1;priority >= 0 && packetlog->numstates < ENTITYFRAME5_MAXSTATES;priority--)
{
- for (i = 0;i < entityframe5_prioritychaincounts[priority] && packetlog->numstates < ENTITYFRAME5_MAXSTATES;i++)
+ for (i = 0;i < d->prioritychaincounts[priority] && packetlog->numstates < ENTITYFRAME5_MAXSTATES;i++)
{
- num = entityframe5_prioritychains[priority][i];
+ num = d->prioritychains[priority][i];
n = d->states + num;
if (d->deltabits[num] & E5_FULLUPDATE)
d->deltabits[num] = E5_FULLUPDATE | EntityState5_DeltaBits(&defaultstate, n);
server updates entities in looping ranges, a frame consists of a range of visible entities (not always all visible entities),
*/
+#define MAX_ENTITY_HISTORY 64
+#define MAX_ENTITY_DATABASE (MAX_EDICTS * 2)
+
+// build entity data in this, to pass to entity read/write functions
+typedef struct entity_frame_s
+{
+ double time;
+ int framenum;
+ int numentities;
+ int firstentitynum;
+ int lastentitynum;
+ vec3_t eye;
+ entity_state_t entitydata[MAX_ENTITY_DATABASE];
+}
+entity_frame_t;
+
typedef struct entity_frameinfo_s
{
double time;
}
entity_frameinfo_t;
-#define MAX_ENTITY_HISTORY 64
-#define MAX_ENTITY_DATABASE (MAX_EDICTS * 2)
-
typedef struct entityframe_database_s
{
// note: these can be far out of range, modulo with MAX_ENTITY_DATABASE to get a valid range (which may wrap)
entity_frameinfo_t frames[MAX_ENTITY_HISTORY];
// entities
entity_state_t entitydata[MAX_ENTITY_DATABASE];
-}
-entityframe_database_t;
-// build entity data in this, to pass to entity read/write functions
-typedef struct entity_frame_s
-{
- double time;
- int framenum;
- int numentities;
- int firstentitynum;
- int lastentitynum;
- vec3_t eye;
- entity_state_t entitydata[MAX_ENTITY_DATABASE];
+ // structs for building new frames and reading them
+ entity_frame_t deltaframe;
+ entity_frame_t framedata;
}
-entity_frame_t;
+entityframe_database_t;
// LordHavoc: these are in approximately sorted order, according to cost and
// likelyhood of being used for numerous objects in a frame
#define ENTITYFRAME5_MAXPACKETLOGS 64
#define ENTITYFRAME5_MAXSTATES 1024
+#define ENTITYFRAME5_PRIORITYLEVELS 32
typedef struct entityframe5_changestate_s
{
// rather than a memmove to remove them from the start.
//int numchangestates;
//entityframe5_changestate_t changestates[MAX_EDICTS];
+
+ // buffers for building priority info
+ int prioritychaincounts[ENTITYFRAME5_PRIORITYLEVELS];
+ unsigned short prioritychains[ENTITYFRAME5_PRIORITYLEVELS][ENTITYFRAME5_MAXSTATES];
}
entityframe5_database_t;