return;
}
cl.protocol = i;
+ Con_DPrintf("Protocol %i\n", cl.protocol);
// parse maxclients
cl.maxclients = MSG_ReadByte ();
for (i = 0;i < 3;i++)
{
ent->state_baseline.origin[i] = MSG_ReadCoord(cl.protocol);
- ent->state_baseline.angles[i] = MSG_ReadAngle8i();
+ ent->state_baseline.angles[i] = MSG_ReadAngle(cl.protocol);
}
CL_ValidateState(&ent->state_baseline);
ent->state_previous = ent->state_current = ent->state_baseline;
void CL_ParseServerMessage(void)
{
int cmd;
- int i, entitiesupdated;
+ int i;
qbyte cmdlog[32];
char *cmdlogname[32], *temp;
int cmdindex, cmdcount = 0;
//
//MSG_BeginReading ();
- entitiesupdated = false;
-
parsingerror = true;
while (1)
// if the high bit of the command byte is set, it is a fast update
if (cmd & 128)
{
- entitiesupdated = true;
// LordHavoc: fix for bizarre problem in MSVC that I do not understand (if I assign the string pointer directly it ends up storing a NULL pointer)
temp = "entity";
cmdlogname[cmdindex] = temp;
case svc_setangle:
for (i=0 ; i<3 ; i++)
- {
- if (cl.protocol == PROTOCOL_DARKPLACES5)
- cl.viewangles[i] = MSG_ReadAngle16i ();
- else
- cl.viewangles[i] = MSG_ReadAngle8i ();
- }
+ cl.viewangles[i] = MSG_ReadAngle (cl.protocol);
break;
case svc_setview:
}
}
- if (entitiesupdated)
- EntityFrameQuake_ISeeDeadEntities();
+ EntityFrameQuake_ISeeDeadEntities();
parsingerror = false;
}
MSG_WriteFloat (sb, f);
}
+void MSG_WriteAngle (sizebuf_t *sb, float f, int protocol)
+{
+ if (protocol == PROTOCOL_DARKPLACES5)
+ MSG_WriteAngle16i (sb, f);
+ else
+ MSG_WriteAngle8i (sb, f);
+}
//
// reading functions
float MSG_ReadAngle16i (void)
{
- return MSG_ReadShort () * (360.0/65536.0);
+ return (unsigned short)MSG_ReadShort () * (360.0/65536.0);
}
float MSG_ReadAngle32f (void)
return MSG_ReadFloat ();
}
+float MSG_ReadAngle (int protocol)
+{
+ if (protocol == PROTOCOL_DARKPLACES5)
+ return MSG_ReadAngle16i ();
+ else
+ return MSG_ReadAngle8i ();
+}
+
//===========================================================================
*cur++ = ' ';
*cur++ = ' ';
}
- if ((j & 3) == 0)
+ if ((j & 3) == 3)
*cur++ = ' ';
}
// print text
void MSG_WriteCoord32f (sizebuf_t *sb, float f);
void MSG_WriteCoord (sizebuf_t *sb, float f, int protocol);
void MSG_WriteVector (sizebuf_t *sb, float *v, int protocol);
+void MSG_WriteAngle (sizebuf_t *sb, float f, int protocol);
extern int msg_readcount;
extern qboolean msg_badread; // set if a read goes beyond end of message
float MSG_ReadCoord32f (void);
float MSG_ReadCoord (int protocol);
void MSG_ReadVector (float *v, int protocol);
+float MSG_ReadAngle (int protocol);
//============================================================================
// and it won't happen if the game was just loaded, so you wind up
// with a permanent head tilt
MSG_WriteByte (&host_client->message, svc_setangle);
- if (sv.protocol == PROTOCOL_DARKPLACES5)
- {
- MSG_WriteAngle16i (&host_client->message, sv_player->v->angles[0]);
- MSG_WriteAngle16i (&host_client->message, sv_player->v->angles[1]);
- MSG_WriteAngle16i (&host_client->message, 0);
- }
- else
- {
- MSG_WriteAngle8i (&host_client->message, sv_player->v->angles[0]);
- MSG_WriteAngle8i (&host_client->message, sv_player->v->angles[1]);
- MSG_WriteAngle8i (&host_client->message, 0);
- }
+ MSG_WriteAngle (&host_client->message, sv_player->v->angles[0], sv.protocol);
+ MSG_WriteAngle (&host_client->message, sv_player->v->angles[1], sv.protocol);
+ MSG_WriteAngle (&host_client->message, 0, sv.protocol);
SV_WriteClientdataToMessage (sv_player, &host_client->message);
void PF_WriteAngle (void)
{
- if (sv.protocol == PROTOCOL_DARKPLACES5)
- MSG_WriteAngle16i (WriteDest(), G_FLOAT(OFS_PARM1));
- else
- MSG_WriteAngle8i (WriteDest(), G_FLOAT(OFS_PARM1));
+ MSG_WriteAngle (WriteDest(), G_FLOAT(OFS_PARM1), sv.protocol);
}
void PF_WriteCoord (void)
for (i=0 ; i<3 ; i++)
{
MSG_WriteCoord(&sv.signon, ent->v->origin[i], sv.protocol);
- MSG_WriteAngle8i(&sv.signon, ent->v->angles[i]);
+ MSG_WriteAngle(&sv.signon, ent->v->angles[i], sv.protocol);
}
// throw the entity away now
{0,0,0,0}//unsigned char unused[4]; // !
};
-double entityframequake_mtime = 0;
+// keep track of quake entities because they need to be killed if they get stale
+int cl_lastquakeentity = 0;
+qbyte cl_isquakeentity[MAX_EDICTS];
void EntityFrameQuake_ReadEntity(int bits)
{
entity_t *ent;
entity_state_t s;
- entityframequake_mtime = cl.mtime[0];
-
if (bits & U_MOREBITS)
bits |= (MSG_ReadByte()<<8);
if ((bits & U_EXTEND1) && cl.protocol != PROTOCOL_NEHAHRAMOVIE)
s.active = true;
}
+ cl_isquakeentity[num] = true;
+ if (cl_lastquakeentity < num)
+ cl_lastquakeentity = num;
s.number = num;
s.time = cl.mtime[0];
s.flags = 0;
if (bits & U_COLORMAP) s.colormap = MSG_ReadByte();
if (bits & U_SKIN) s.skin = MSG_ReadByte();
if (bits & U_EFFECTS) s.effects = (s.effects & 0xFF00) | MSG_ReadByte();
- if (bits & U_ORIGIN1) s.origin[0] = MSG_ReadCoord13i();
- if (bits & U_ANGLE1) s.angles[0] = MSG_ReadAngle8i();
- if (bits & U_ORIGIN2) s.origin[1] = MSG_ReadCoord13i();
- if (bits & U_ANGLE2) s.angles[1] = MSG_ReadAngle8i();
- if (bits & U_ORIGIN3) s.origin[2] = MSG_ReadCoord13i();
- if (bits & U_ANGLE3) s.angles[2] = MSG_ReadAngle8i();
+ if (bits & U_ORIGIN1) s.origin[0] = MSG_ReadCoord(cl.protocol);
+ if (bits & U_ANGLE1) s.angles[0] = MSG_ReadAngle(cl.protocol);
+ if (bits & U_ORIGIN2) s.origin[1] = MSG_ReadCoord(cl.protocol);
+ if (bits & U_ANGLE2) s.angles[1] = MSG_ReadAngle(cl.protocol);
+ if (bits & U_ORIGIN3) s.origin[2] = MSG_ReadCoord(cl.protocol);
+ if (bits & U_ANGLE3) s.angles[2] = MSG_ReadAngle(cl.protocol);
if (bits & U_STEP) s.flags |= RENDER_STEP;
if (bits & U_ALPHA) s.alpha = MSG_ReadByte();
if (bits & U_SCALE) s.scale = MSG_ReadByte();
void EntityFrameQuake_ISeeDeadEntities(void)
{
- int i;
- for (i = 0;i < cl_max_entities;i++)
+ int num, lastentity;
+ if (cl_lastquakeentity == 0)
+ return;
+ lastentity = cl_lastquakeentity;
+ cl_lastquakeentity = 0;
+ for (num = 0;num < lastentity;num++)
{
- if (cl_entities_active[i] && cl_entities[i].state_current.time != cl.mtime[0])
+ if (cl_isquakeentity[num])
{
- cl_entities_active[i] = false;
- cl_entities[i].state_current = defaultstate;
- cl_entities[i].state_current.number = i;
+ cl_isquakeentity[num] = false;
+ if (cl_entities_active[num])
+ {
+ if (cl_entities[num].state_current.time == cl.mtime[0])
+ {
+ cl_isquakeentity[num] = true;
+ cl_lastquakeentity = num;
+ }
+ else
+ {
+ cl_isquakeentity[num] = false;
+ cl_entities_active[num] = false;
+ cl_entities[num].state_current = defaultstate;
+ cl_entities[num].state_current.number = num;
+ }
+ }
}
}
}
if (bits & U_COLORMAP) MSG_WriteByte(&buf, s->colormap);
if (bits & U_SKIN) MSG_WriteByte(&buf, s->skin);
if (bits & U_EFFECTS) MSG_WriteByte(&buf, s->effects);
- if (bits & U_ORIGIN1) MSG_WriteCoord13i(&buf, s->origin[0]);
- if (bits & U_ANGLE1) MSG_WriteAngle8i(&buf, s->angles[0]);
- if (bits & U_ORIGIN2) MSG_WriteCoord13i(&buf, s->origin[1]);
- if (bits & U_ANGLE2) MSG_WriteAngle8i(&buf, s->angles[1]);
- if (bits & U_ORIGIN3) MSG_WriteCoord13i(&buf, s->origin[2]);
- if (bits & U_ANGLE3) MSG_WriteAngle8i(&buf, s->angles[2]);
+ if (bits & U_ORIGIN1) MSG_WriteCoord(&buf, s->origin[0], sv.protocol);
+ if (bits & U_ANGLE1) MSG_WriteAngle(&buf, s->angles[0], sv.protocol);
+ if (bits & U_ORIGIN2) MSG_WriteCoord(&buf, s->origin[1], sv.protocol);
+ if (bits & U_ANGLE2) MSG_WriteAngle(&buf, s->angles[1], sv.protocol);
+ if (bits & U_ORIGIN3) MSG_WriteCoord(&buf, s->origin[2], sv.protocol);
+ if (bits & U_ANGLE3) MSG_WriteAngle(&buf, s->angles[2], sv.protocol);
if (bits & U_ALPHA) MSG_WriteByte(&buf, s->alpha);
if (bits & U_SCALE) MSG_WriteByte(&buf, s->scale);
if (bits & U_EFFECTS2) MSG_WriteByte(&buf, s->effects >> 8);
void VM_WriteAngle (void)
{
- MSG_WriteAngle16i (VM_WriteDest(), PRVM_G_FLOAT(OFS_PARM0));
+ MSG_WriteAngle (VM_WriteDest(), PRVM_G_FLOAT(OFS_PARM0), sv.protocol);
}
void VM_WriteCoord (void)
if (bits & U_COLORMAP) MSG_WriteByte(msg, ent->v->colormap);
if (bits & U_SKIN) MSG_WriteByte(msg, ent->v->skin);
if (bits & U_EFFECTS) MSG_WriteByte(msg, ent->v->effects);
- if (bits & U_ORIGIN1) MSG_WriteCoord13i(msg, origin[0]);
- if (bits & U_ANGLE1) MSG_WriteAngle8i(msg, angles[0]);
- if (bits & U_ORIGIN2) MSG_WriteCoord13i(msg, origin[1]);
- if (bits & U_ANGLE2) MSG_WriteAngle8i(msg, angles[1]);
- if (bits & U_ORIGIN3) MSG_WriteCoord13i(msg, origin[2]);
- if (bits & U_ANGLE3) MSG_WriteAngle8i(msg, angles[2]);
+ if (bits & U_ORIGIN1) MSG_WriteCoord(msg, origin[0], sv.protocol);
+ if (bits & U_ANGLE1) MSG_WriteAngle(msg, angles[0], sv.protocol);
+ if (bits & U_ORIGIN2) MSG_WriteCoord(msg, origin[1], sv.protocol);
+ if (bits & U_ANGLE2) MSG_WriteAngle(msg, angles[1], sv.protocol);
+ if (bits & U_ORIGIN3) MSG_WriteCoord(msg, origin[2], sv.protocol);
+ if (bits & U_ANGLE3) MSG_WriteAngle(msg, angles[2], sv.protocol);
// LordHavoc: new stuff
if (bits & U_ALPHA) MSG_WriteByte(msg, alpha);
{
MSG_WriteByte (msg, svc_setangle);
for (i=0 ; i < 3 ; i++)
- {
- if (sv.protocol == PROTOCOL_DARKPLACES5)
- MSG_WriteAngle16i (msg, ent->v->angles[i] );
- else
- MSG_WriteAngle8i (msg, ent->v->angles[i] );
- }
+ MSG_WriteAngle (msg, ent->v->angles[i], sv.protocol);
ent->v->fixangle = 0;
}
for (i=0 ; i<3 ; i++)
{
MSG_WriteCoord(&sv.signon, svent->e->baseline.origin[i], sv.protocol);
- MSG_WriteAngle8i(&sv.signon, svent->e->baseline.angles[i]);
+ MSG_WriteAngle(&sv.signon, svent->e->baseline.angles[i], sv.protocol);
}
}
}