From ef5690eecfe614cee99b56d32b3634980b9a0e9d Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Tue, 25 Sep 2007 13:41:22 +0000 Subject: * Replace "powerups" state data with "misc" * Remove ps->ammo[ ] and replace with ps->ammo and ps->clips; this means only one ammo using weapon may be carried at once, but this is the case anyway * No need for BG_(Un)PackAmmoArray anymore, so remove them --- src/qcommon/msg.c | 65 +++++++++++++++----------------------------------- src/qcommon/q_shared.h | 9 +++---- 2 files changed, 24 insertions(+), 50 deletions(-) (limited to 'src/qcommon') diff --git a/src/qcommon/msg.c b/src/qcommon/msg.c index d46c2a3b..ac581b9e 100644 --- a/src/qcommon/msg.c +++ b/src/qcommon/msg.c @@ -823,7 +823,7 @@ netField_t entityStateFields[] = { NETF(origin[1]), 0 }, { NETF(origin[2]), 0 }, { NETF(solid), 24 }, -{ NETF(powerups), MAX_POWERUPS }, +{ NETF(misc), MAX_MISC }, { NETF(modelindex), 8 }, { NETF(otherEntityNum2), GENTITYNUM_BITS }, { NETF(loopSound), 8 }, @@ -1143,6 +1143,8 @@ netField_t playerStateFields[] = { PSF(damageYaw), 8 }, { PSF(damagePitch), 8 }, { PSF(damageCount), 8 }, +{ PSF(ammo), 12 }, +{ PSF(clips), 4 }, { PSF(generic1), 16 }, { PSF(pm_type), 8 }, { PSF(delta_angles[0]), 16 }, @@ -1171,8 +1173,7 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p playerState_t dummy; int statsbits; int persistantbits; - int ammobits; - int powerupbits; + int miscbits; int numFields; int c; netField_t *field; @@ -1252,20 +1253,14 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p persistantbits |= 1<ammo[i] != from->ammo[i]) { - ammobits |= 1<powerups[i] != from->powerups[i]) { - powerupbits |= 1<misc[i] != from->misc[i]) { + miscbits |= 1<ammo[i]); - } else { - MSG_WriteBits( msg, 0, 1 ); // no change - } - - - if ( powerupbits ) { + if ( miscbits ) { MSG_WriteBits( msg, 1, 1 ); // changed - MSG_WriteBits( msg, powerupbits, MAX_POWERUPS ); - for (i=0 ; ipowerups[i] ); + MSG_WriteBits( msg, miscbits, MAX_MISC ); + for (i=0 ; imisc[i] ); } else { MSG_WriteBits( msg, 0, 1 ); // no change } @@ -1424,24 +1408,13 @@ void MSG_ReadDeltaPlayerstate (msg_t *msg, playerState_t *from, playerState_t *t } } - // parse ammo - if ( MSG_ReadBits( msg, 1 ) ) { - LOG("PS_AMMO"); - bits = MSG_ReadBits (msg, MAX_WEAPONS); - for (i=0 ; iammo[i] = MSG_ReadShort(msg); - } - } - } - - // parse powerups + // parse misc data if ( MSG_ReadBits( msg, 1 ) ) { - LOG("PS_POWERUPS"); - bits = MSG_ReadBits (msg, MAX_POWERUPS); - for (i=0 ; ipowerups[i] = MSG_ReadLong(msg); + to->misc[i] = MSG_ReadLong(msg); } } } diff --git a/src/qcommon/q_shared.h b/src/qcommon/q_shared.h index 8c61aa7d..3622097b 100644 --- a/src/qcommon/q_shared.h +++ b/src/qcommon/q_shared.h @@ -1013,7 +1013,7 @@ typedef struct { // bit field limits #define MAX_STATS 16 #define MAX_PERSISTANT 16 -#define MAX_POWERUPS 16 +#define MAX_MISC 16 #define MAX_WEAPONS 16 #define MAX_PS_EVENTS 2 @@ -1085,8 +1085,9 @@ typedef struct playerState_s { int stats[MAX_STATS]; int persistant[MAX_PERSISTANT]; // stats that aren't cleared on death - int powerups[MAX_POWERUPS]; // level.time that the powerup runs out - int ammo[MAX_WEAPONS]; + int misc[MAX_MISC]; // misc data + int ammo; // ammo held + int clips; // clips held int generic1; int loopSound; @@ -1204,7 +1205,7 @@ typedef struct entityState_s { int eventParm; // for players - int powerups; // bit flags + int misc; // bit flags int weapon; // determines weapon and flash model, etc int legsAnim; // mask off ANIM_TOGGLEBIT int torsoAnim; // mask off ANIM_TOGGLEBIT -- cgit