From d8cf4ace70f77638bb8224a45182fc7b638c4439 Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 21 May 2007 22:13:46 +0000 Subject: [PATCH] added svc_pointparticles1 for next protocol bump (uses 15 bytes instead of 29 bytes for the potentially common case of zero velocity and a count of 1) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7330 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_parse.c | 12 ++++++++++++ protocol.h | 3 ++- svvm_cmds.c | 29 +++++++++++++++++++++++------ 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/cl_parse.c b/cl_parse.c index 5c80f8a7..7c0dac20 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -2539,6 +2539,15 @@ void CL_ParsePointParticles(void) CL_ParticleEffect(effectindex, count, origin, origin, velocity, velocity, NULL, 0); } +void CL_ParsePointParticles1(void) +{ + int effectindex; + vec3_t origin; + effectindex = (unsigned short)MSG_ReadShort(); + MSG_ReadVector(origin, cls.protocol); + CL_ParticleEffect(effectindex, 1, origin, origin, vec3_origin, vec3_origin, NULL, 0); +} + typedef struct cl_iplog_item_s { char *address; @@ -3714,6 +3723,9 @@ void CL_ParseServerMessage(void) case svc_pointparticles: CL_ParsePointParticles(); break; + case svc_pointparticles1: + CL_ParsePointParticles1(); + break; } } } diff --git a/protocol.h b/protocol.h index b12aab92..30905740 100644 --- a/protocol.h +++ b/protocol.h @@ -251,7 +251,8 @@ void Protocol_Names(char *buffer, size_t buffersize); #define svc_csqcentities 58 // [short] entnum [variable length] entitydata ... [short] 0x0000 #define svc_spawnstaticsound2 59 // [coord3] [short] samp [byte] vol [byte] aten #define svc_trailparticles 60 // [short] entnum [short] effectnum [vector] start [vector] end -#define svc_pointparticles 61 // [short] effectnum [vector] start [vector] end [short] count +#define svc_pointparticles 61 // [short] effectnum [vector] start [vector] velocity [short] count +#define svc_pointparticles1 62 // [short] effectnum [vector] start, same as svc_pointparticles except velocity is zero and count is 1 (PROTOCOL_DARKPLACES8) // // client to server diff --git a/svvm_cmds.c b/svvm_cmds.c index 23a7524e..f6149fe1 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -2648,13 +2648,30 @@ static void VM_SV_trailparticles (void) //#337 void(float effectnum, vector origin, vector dir, float count) pointparticles (EXT_CSQC) static void VM_SV_pointparticles (void) { - VM_SAFEPARMCOUNT(4, VM_SV_pointparticles); + int effectnum, count; + vec3_t org, vel; + VM_SAFEPARMCOUNTRANGE(4, 8, VM_SV_pointparticles); + effectnum = (int)PRVM_G_FLOAT(OFS_PARM0); + VectorCopy(PRVM_G_VECTOR(OFS_PARM1), org); + VectorCopy(PRVM_G_VECTOR(OFS_PARM2), vel); + count = bound(0, (int)PRVM_G_FLOAT(OFS_PARM3), 65535); + if (count == 1 && !VectorLength2(vel) && (sv.protocol != PROTOCOL_QUAKE && sv.protocol != PROTOCOL_QUAKEDP && sv.protocol != PROTOCOL_NEHAHRAMOVIE && sv.protocol != PROTOCOL_DARKPLACES1 && sv.protocol != DARKPLACES2 && sv.protocol != DARKPLACES3 && sv.protocol != DARKPLACES4 && sv.protocol != DARKPLACES5 && sv.protocol != DARKPLACES6 && sv.protocol != DARKPLACES7)) + { + // 1+2+12=15 bytes + MSG_WriteByte(&sv.datagram, svc_pointparticles1); + MSG_WriteShort(&sv.datagram, effectnum); + MSG_WriteVector(&sv.datagram, org, sv.protocol); + } + else + { + // 1+2+12+12+2=29 bytes + MSG_WriteByte(&sv.datagram, svc_pointparticles); + MSG_WriteShort(&sv.datagram, effectnum); + MSG_WriteVector(&sv.datagram, org, sv.protocol); + MSG_WriteVector(&sv.datagram, vel, sv.protocol); + MSG_WriteShort(&sv.datagram, count); + } - MSG_WriteByte(&sv.datagram, svc_pointparticles); - MSG_WriteShort(&sv.datagram, (int)PRVM_G_FLOAT(OFS_PARM0)); - MSG_WriteVector(&sv.datagram, PRVM_G_VECTOR(OFS_PARM1), sv.protocol); - MSG_WriteVector(&sv.datagram, PRVM_G_VECTOR(OFS_PARM2), sv.protocol); - MSG_WriteShort(&sv.datagram, bound(0, (int)PRVM_G_FLOAT(OFS_PARM3), 65535)); SV_FlushBroadcastMessages(); } -- 2.39.2