diff --git a/Quake/cl_tent.c b/Quake/cl_tent.c index 43728dcc..36be7de7 100644 --- a/Quake/cl_tent.c +++ b/Quake/cl_tent.c @@ -63,7 +63,7 @@ void CL_ParseBeam (qmodel_t *m, const char *trailname, const char *impactname) beam_t *b; int i; - ent = MSG_ReadShort (); + ent = MSG_ReadEntity (cl.protocol_pext2); start[0] = MSG_ReadCoord (cl.protocolflags); start[1] = MSG_ReadCoord (cl.protocolflags); diff --git a/Quake/common.c b/Quake/common.c index c9eba468..f2308e52 100644 --- a/Quake/common.c +++ b/Quake/common.c @@ -761,6 +761,19 @@ void MSG_WriteAngle16 (sizebuf_t *sb, float f, unsigned int flags) } //johnfitz +//spike -- for PEXT2_REPLACEMENTDELTAS +void MSG_WriteEntity (sizebuf_t *sb, unsigned int entnum, unsigned int pext2) +{ + //high short, low byte + if (entnum > 0x7fff && (pext2 & PEXT2_REPLACEMENTDELTAS)) + { + MSG_WriteShort(sb, 0x8000|(entnum>>8)); + MSG_WriteByte(sb, entnum&0xff); + } + else + MSG_WriteShort(sb, entnum); +} + // // reading functions // @@ -932,9 +945,9 @@ float MSG_ReadAngle16 (unsigned int flags) } //johnfitz -int MSG_ReadEntity(unsigned int pext2) +unsigned int MSG_ReadEntity(unsigned int pext2) { - int e = (unsigned short)MSG_ReadShort(); + unsigned int e = (unsigned short)MSG_ReadShort(); if (pext2 & PEXT2_REPLACEMENTDELTAS) { if (e & 0x8000) diff --git a/Quake/common.h b/Quake/common.h index bbf75064..d962875b 100644 --- a/Quake/common.h +++ b/Quake/common.h @@ -103,6 +103,7 @@ void MSG_WriteString (sizebuf_t *sb, const char *s); void MSG_WriteCoord (sizebuf_t *sb, float f, unsigned int flags); void MSG_WriteAngle (sizebuf_t *sb, float f, unsigned int flags); void MSG_WriteAngle16 (sizebuf_t *sb, float f, unsigned int flags); //johnfitz +void MSG_WriteEntity(sizebuf_t *sb, unsigned int index, unsigned int pext2); //spike struct entity_state_s; void MSG_WriteStaticOrBaseLine(sizebuf_t *buf, int idx, struct entity_state_s *state, unsigned int protocol_pext2, unsigned int protocol, unsigned int protocolflags); //spike @@ -121,7 +122,7 @@ float MSG_ReadCoord (unsigned int flags); float MSG_ReadAngle (unsigned int flags); float MSG_ReadAngle16 (unsigned int flags); //johnfitz byte *MSG_ReadData (unsigned int length); // spike -int MSG_ReadEntity(unsigned int pext2); //spike +unsigned int MSG_ReadEntity(unsigned int pext2); //spike void COM_Effectinfo_Enumerate(int (*cb)(const char *pname)); //spike -- for dp compat diff --git a/Quake/pr_cmds.c b/Quake/pr_cmds.c index 188105a5..da4ea35e 100644 --- a/Quake/pr_cmds.c +++ b/Quake/pr_cmds.c @@ -1638,10 +1638,10 @@ static void PF_sv_WriteString (void) MSG_WriteString (WriteDest(), G_STRING(OFS_PARM1)); } -#define MSG_WriteEntity MSG_WriteShort //fixme - replacement deltas encodes 0x8000+ in 24 bits static void PF_sv_WriteEntity (void) { - MSG_WriteEntity (WriteDest(), G_EDICTNUM(OFS_PARM1)); + extern unsigned int sv_protocol_pext2; //spike -- this ought to be client-specific, but we can't cope with that, so just live with the problems when ents>32768 (which QS doesn't support anyway) + MSG_WriteEntity (WriteDest(), G_EDICTNUM(OFS_PARM1), sv_protocol_pext2); } //============================================================================= diff --git a/Quake/pr_ext.c b/Quake/pr_ext.c index 309e98cf..8041a33c 100644 --- a/Quake/pr_ext.c +++ b/Quake/pr_ext.c @@ -5209,6 +5209,7 @@ static void PF_cl_sendevent(void) const char *eventname = G_STRING(OFS_PARM0); const char *eventargs = G_STRING(OFS_PARM1); int a; + eval_t *val; MSG_WriteByte(&cls.message, clcfte_qcrequest); for (a = 2; a < 8 && *eventargs; a++, eventargs++) @@ -5233,10 +5234,11 @@ static void PF_cl_sendevent(void) MSG_WriteFloat(&cls.message, G_FLOAT(OFS_PARM0+a*3+1)); MSG_WriteFloat(&cls.message, G_FLOAT(OFS_PARM0+a*3+2)); break; -// case 'e': -// MSG_WriteByte(&cls.message, ev_entity); -// MSG_WriteEntity(&cls.message, ent->v.entnum); -// break; + case 'e': + MSG_WriteByte(&cls.message, ev_entity); + val = GetEdictFieldValue(host_client->edict, ED_FindFieldOffset("entnum")); //we need to transmit the SERVER's number, the client's number is meaningless to it. + MSG_WriteEntity(&cls.message, val?val->_float:0, cl.protocol_pext2); + break; } } MSG_WriteByte(&cls.message, 0); diff --git a/Quake/sv_main.c b/Quake/sv_main.c index 35828e89..cbf533a1 100644 --- a/Quake/sv_main.c +++ b/Quake/sv_main.c @@ -274,18 +274,6 @@ static unsigned int MSGFTE_DeltaCalcBits(entity_state_t *from, entity_state_t *t return bits; } -//#undef MSG_WriteEntity -void MSG_WriteEntity (sizebuf_t *sb, int c, unsigned int pext2) -{ - //high short, low byte - if (c > 0x7fff && (pext2 & PEXT2_REPLACEMENTDELTAS)) - { - MSG_WriteShort(sb, 0x8000|(c>>8)); - MSG_WriteByte(sb, c&0xff); - } - else - MSG_WriteShort(sb, c); -} static void MSGFTE_WriteEntityUpdate(unsigned int bits, entity_state_t *state, sizebuf_t *msg, unsigned int pext2, unsigned int protocolflags) { unsigned int predbits = 0;