0,//unsigned char flags;
0,//unsigned char tagindex;
{32, 32, 32},//unsigned char colormod[3];
+ 0,//unsigned char internaleffects; // INTEF_FLAG1QW and so on
// padding to a multiple of 8 bytes (to align the double time)
- {0,0}//unsigned char unused[2]; // !
+ 0//unsigned char unused; // !
};
// LordHavoc: I own protocol ranges 96, 97, 3500-3599
sv2csqcbuf = NULL;
}
+void Protocol_UpdateClientStats(const int *stats)
+{
+ int i;
+ // update the stats array and set deltabits for any changed stats
+ for (i = 0;i < MAX_CL_STATS;i++)
+ {
+ if (host_client->stats[i] != stats[i])
+ {
+ host_client->statsdeltabits[i >> 3] |= 1 << (i & 7);
+ host_client->stats[i] = stats[i];
+ }
+ }
+}
+
+void Protocol_WriteStatsReliable(void)
+{
+ int i;
+ if (!host_client->netconnection)
+ return;
+ // detect changes in stats and write reliable messages
+ for (i = 0;i < MAX_CL_STATS;i++)
+ {
+ // quickly skip zero bytes
+ if (!host_client->statsdeltabits[i >> 3])
+ {
+ i |= 7;
+ continue;
+ }
+ // check if this bit is set
+ if (host_client->statsdeltabits[i >> 3] & (1 << (i & 7)))
+ {
+ host_client->statsdeltabits[i >> 3] -= (1 << (i & 7));
+ // send the stat as a byte if possible
+ if (host_client->stats[i] >= 0 && host_client->stats[i] < 256)
+ {
+ MSG_WriteByte(&host_client->netconnection->message, svc_updatestatubyte);
+ MSG_WriteByte(&host_client->netconnection->message, i);
+ MSG_WriteByte(&host_client->netconnection->message, host_client->stats[i]);
+ }
+ else
+ {
+ MSG_WriteByte(&host_client->netconnection->message, svc_updatestat);
+ MSG_WriteByte(&host_client->netconnection->message, i);
+ MSG_WriteLong(&host_client->netconnection->message, host_client->stats[i]);
+ }
+ }
+ }
+}
+
+
void EntityFrameQuake_WriteFrame(sizebuf_t *msg, int numstates, const entity_state_t *states)
{
const entity_state_t *s;
cl.latestframenums[LATESTFRAMENUMS-1] = framenum = MSG_ReadLong();
// read the start number
enumber = (unsigned short) MSG_ReadShort();
- if (developer_networkentities.integer >= 1)
+ if (developer_networkentities.integer >= 10)
{
Con_Printf("recv svc_entities num:%i ref:%i database: ref:%i commits:", framenum, referenceframenum, d->referenceframenum);
for (i = 0;i < MAX_ENTITY_HISTORY;i++)
MSG_WriteByte(msg, svc_entities);
MSG_WriteLong(msg, d->referenceframenum);
MSG_WriteLong(msg, d->currentcommit->framenum);
- if (developer_networkentities.integer >= 1)
+ if (developer_networkentities.integer >= 10)
{
Con_Printf("send svc_entities num:%i ref:%i (database: ref:%i commits:", d->currentcommit->framenum, d->referenceframenum, d->referenceframenum);
for (i = 0;i < MAX_ENTITY_HISTORY;i++)
else
{
bits = changedbits;
- if ((bits & E5_ORIGIN) && (!(s->flags & RENDER_LOWPRECISION) || s->origin[0] < -4096 || s->origin[0] >= 4096 || s->origin[1] < -4096 || s->origin[1] >= 4096 || s->origin[2] < -4096 || s->origin[2] >= 4096))
+ if ((bits & E5_ORIGIN) && ((s->flags & RENDER_EXTERIORMODEL) || s->origin[0] < -4096 || s->origin[0] >= 4096 || s->origin[1] < -4096 || s->origin[1] >= 4096 || s->origin[2] < -4096 || s->origin[2] >= 4096))
bits |= E5_ORIGIN32;
if ((bits & E5_ANGLES) && !(s->flags & RENDER_LOWPRECISION))
bits |= E5_ANGLES16;
bits |= E5_FRAME16;
if (bits & E5_EFFECTS)
{
- if (s->effects >= 65536)
+ if (s->effects & 0xFFFF0000)
bits |= E5_EFFECTS32;
- else if (s->effects >= 256)
+ else if (s->effects & 0xFFFFFF00)
bits |= E5_EFFECTS16;
}
if (bits >= 256)
}
}
-void EntityState5_ReadUpdate(entity_state_t *s)
+void EntityState5_ReadUpdate(entity_state_t *s, int number)
{
int bits;
bits = MSG_ReadByte();
if (developer_networkentities.integer >= 2)
{
- Con_Printf("ReadFields e%i", s->number);
+ Con_Printf("ReadFields e%i", number);
if (bits & E5_ORIGIN)
Con_Printf(" E5_ORIGIN %f %f %f", s->origin[0], s->origin[1], s->origin[2]);
for (i = 0;i < LATESTFRAMENUMS-1;i++)
cl.latestframenums[i] = cl.latestframenums[i+1];
cl.latestframenums[LATESTFRAMENUMS-1] = MSG_ReadLong();
- if (developer_networkentities.integer)
+ if (developer_networkentities.integer >= 10)
Con_Printf("recv: svc_entities %i\n", cl.latestframenums[LATESTFRAMENUMS-1]);
if (cls.protocol != PROTOCOL_QUAKE && cls.protocol != PROTOCOL_QUAKEDP && cls.protocol != PROTOCOL_NEHAHRAMOVIE && cls.protocol != PROTOCOL_DARKPLACES1 && cls.protocol != PROTOCOL_DARKPLACES2 && cls.protocol != PROTOCOL_DARKPLACES3 && cls.protocol != PROTOCOL_DARKPLACES4 && cls.protocol != PROTOCOL_DARKPLACES5 && cls.protocol != PROTOCOL_DARKPLACES6)
cls.servermovesequence = MSG_ReadLong();
else
{
// update entity
- EntityState5_ReadUpdate(s);
+ EntityState5_ReadUpdate(s, enumber);
}
// set the cl.entities_active flag
cl.entities_active[enumber] = s->active;
for (j = 0;j < MAX_CL_STATS;j++)
{
for (l = 0;l < (MAX_CL_STATS+7)/8;l++)
- statsdeltabits[l] = p->statsdeltabits[l] & ~d->statsdeltabits[l];
+ statsdeltabits[l] = p->statsdeltabits[l] & ~host_client->statsdeltabits[l];
for (k = 0, p2 = d->packetlog;k < ENTITYFRAME5_MAXPACKETLOGS;k++, p2++)
if (p2->packetnumber > framenum)
for (l = 0;l < (MAX_CL_STATS+7)/8;l++)
statsdeltabits[l] = p->statsdeltabits[l] & ~p2->statsdeltabits[l];
for (l = 0;l < (MAX_CL_STATS+7)/8;l++)
- d->statsdeltabits[l] |= statsdeltabits[l];
+ host_client->statsdeltabits[l] |= statsdeltabits[l];
}
// delete this packet log as it is now obsolete
p->packetnumber = 0;
d->packetlog[i].packetnumber = 0;
}
-void EntityFrame5_WriteFrame(sizebuf_t *msg, entityframe5_database_t *d, int numstates, const entity_state_t *states, int viewentnum, int *stats, int movesequence)
+void EntityFrame5_WriteFrame(sizebuf_t *msg, entityframe5_database_t *d, int numstates, const entity_state_t *states, int viewentnum, int movesequence)
{
const entity_state_t *n;
int i, num, l, framenum, packetlognumber, priority;
buf.data = data;
buf.maxsize = sizeof(data);
- // detect changes in stats
- for (i = 0;i < MAX_CL_STATS;i++)
- {
- if (d->stats[i] != stats[i])
- {
- d->statsdeltabits[i>>3] |= (1<<(i&7));
- d->stats[i] = stats[i];
- }
- }
-
// detect changes in states
num = 1;
for (i = 0, n = states;i < numstates;i++, n++)
{
if (d->priorities[num])
{
- if (d->priorities[num] < (E5_PROTOCOL_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->deltabits[num])
+ {
+ if (d->priorities[num] < (E5_PROTOCOL_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;
+ }
+ else
+ d->priorities[num] = 0;
}
}
{
for (i = 0;i < MAX_CL_STATS && msg->cursize + 6 + 11 <= msg->maxsize;i++)
{
- if (d->statsdeltabits[i>>3] & (1<<(i&7)))
+ if (host_client->statsdeltabits[i>>3] & (1<<(i&7)))
{
- d->statsdeltabits[i>>3] &= ~(1<<(i&7));
+ host_client->statsdeltabits[i>>3] &= ~(1<<(i&7));
packetlog->statsdeltabits[i>>3] |= (1<<(i&7));
- if (d->stats[i] >= 0 && d->stats[i] < 256)
+ if (host_client->stats[i] >= 0 && host_client->stats[i] < 256)
{
MSG_WriteByte(msg, svc_updatestatubyte);
MSG_WriteByte(msg, i);
- MSG_WriteByte(msg, d->stats[i]);
+ MSG_WriteByte(msg, host_client->stats[i]);
}
else
{
MSG_WriteByte(msg, svc_updatestat);
MSG_WriteByte(msg, i);
- MSG_WriteLong(msg, d->stats[i]);
+ MSG_WriteLong(msg, host_client->stats[i]);
}
}
}
}
// write state updates
- if (developer_networkentities.integer)
+ if (developer_networkentities.integer >= 10)
Con_Printf("send: svc_entities %i\n", framenum);
d->latestframenum = framenum;
MSG_WriteByte(msg, svc_entities);
}
-static int QW_TranslateEffects(int qweffects, int number)
+static void QW_TranslateEffects(entity_state_t *s, int qweffects)
{
- int effects = 0;
+ s->effects = 0;
+ s->internaleffects = 0;
if (qweffects & QW_EF_BRIGHTFIELD)
- effects |= EF_BRIGHTFIELD;
+ s->effects |= EF_BRIGHTFIELD;
if (qweffects & QW_EF_MUZZLEFLASH)
- effects |= EF_MUZZLEFLASH;
+ s->effects |= EF_MUZZLEFLASH;
if (qweffects & QW_EF_FLAG1)
{
// mimic FTEQW's interpretation of EF_FLAG1 as EF_NODRAW on non-player entities
- if (number > cl.maxclients)
- effects |= EF_NODRAW;
+ if (s->number > cl.maxclients)
+ s->effects |= EF_NODRAW;
else
- effects |= EF_FLAG1QW;
+ s->internaleffects |= INTEF_FLAG1QW;
}
if (qweffects & QW_EF_FLAG2)
{
// mimic FTEQW's interpretation of EF_FLAG2 as EF_ADDITIVE on non-player entities
- if (number > cl.maxclients)
- effects |= EF_ADDITIVE;
+ if (s->number > cl.maxclients)
+ s->effects |= EF_ADDITIVE;
else
- effects |= EF_FLAG2QW;
+ s->internaleffects |= INTEF_FLAG2QW;
}
if (qweffects & QW_EF_RED)
{
if (qweffects & QW_EF_BLUE)
- effects |= EF_RED | EF_BLUE;
+ s->effects |= EF_RED | EF_BLUE;
else
- effects |= EF_RED;
+ s->effects |= EF_RED;
}
else if (qweffects & QW_EF_BLUE)
- effects |= EF_BLUE;
+ s->effects |= EF_BLUE;
else if (qweffects & QW_EF_BRIGHTLIGHT)
- effects |= EF_BRIGHTLIGHT;
+ s->effects |= EF_BRIGHTLIGHT;
else if (qweffects & QW_EF_DIMLIGHT)
- effects |= EF_DIMLIGHT;
- return effects;
+ s->effects |= EF_DIMLIGHT;
}
void EntityStateQW_ReadPlayerUpdate(void)
s = &ent->state_current;
*s = defaultstate;
s->active = true;
+ s->number = enumber;
s->colormap = enumber;
playerflags = MSG_ReadShort();
MSG_ReadVector(s->origin, cls.protocol);
if (playerflags & QW_PF_SKINNUM)
s->skin = MSG_ReadByte();
if (playerflags & QW_PF_EFFECTS)
- s->effects = QW_TranslateEffects(MSG_ReadByte(), enumber);
+ QW_TranslateEffects(s, MSG_ReadByte());
if (playerflags & QW_PF_WEAPONFRAME)
weaponframe = MSG_ReadByte();
else
cl.entities_active[enumber] = s->active;
// set the update time
s->time = cl.mtime[0] - msec * 0.001; // qw has no clock
- // fix the number (it gets wiped occasionally by copying from defaultstate)
- s->number = enumber;
// check if we need to update the lerp stuff
if (s->active)
CL_MoveLerpEntityStates(&cl.entities[enumber]);
if (bits & QW_U_SKIN)
s->skin = MSG_ReadByte();
if (bits & QW_U_EFFECTS)
- s->effects = QW_TranslateEffects(qweffects = MSG_ReadByte(), s->number);
+ QW_TranslateEffects(s, qweffects = MSG_ReadByte());
if (bits & QW_U_ORIGIN1)
s->origin[0] = MSG_ReadCoord13i();
if (bits & QW_U_ANGLE1)