NX/VITA: Considerable protocol bandwidth optimizations

This commit is contained in:
cypress 2023-12-05 13:00:57 -05:00
parent bace222fce
commit e7458c4824
5 changed files with 93 additions and 72 deletions

View file

@ -779,15 +779,12 @@ void CL_ParseClientdata (void)
} }
//johnfitz //johnfitz
for(i = 0; i < 3; i++) // Flash_Offset
cl.ads_offset[i] = MSG_ReadFloat();
for(i = 0; i < 3; i++) for(i = 0; i < 3; i++)
cl.flash_offset[i] = MSG_ReadFloat(); cl.flash_offset[i] = MSG_ReadFloat();
cl.flash_size = MSG_ReadByte();
if (bits & SU_PERKS) if (bits & SU_PERKS)
i = MSG_ReadLong (); i = MSG_ReadByte ();
else else
i = 0; i = 0;
if (cl.perks != i) if (cl.perks != i)
@ -981,18 +978,6 @@ void CL_ParseClientdata (void)
else else
cl.facingenemy = 0; cl.facingenemy = 0;
if (bits & SU_WEAPONNAME) {
size_t len = MSG_ReadByte();
for(i = 0; i < 32; i++) {
cl.weaponname[i] = 0;
}
for(i = 0; i < len; i++) {
cl.weaponname[i] = MSG_ReadChar();
}
}
if (bits & SU_TOUCHNAME) { if (bits & SU_TOUCHNAME) {
size_t len = MSG_ReadByte(); size_t len = MSG_ReadByte();
@ -1006,7 +991,7 @@ void CL_ParseClientdata (void)
} }
cl.onground = (bits & SU_ONGROUND) != 0; cl.onground = (bits & SU_ONGROUND) != 0;
cl.inwater = (bits & SU_INWATER) != 0; // cl.inwater = (bits & SU_INWATER) != 0;
if (bits & SU_WEAPONFRAME) if (bits & SU_WEAPONFRAME)
cl.stats[STAT_WEAPONFRAME] = MSG_ReadByte (); cl.stats[STAT_WEAPONFRAME] = MSG_ReadByte ();
@ -1018,18 +1003,45 @@ void CL_ParseClientdata (void)
else else
cl.stats[STAT_WEAPONSKIN] = 0; cl.stats[STAT_WEAPONSKIN] = 0;
if (bits & SU_WEAPON) // Active Weapon
i = MSG_ReadByte (); i = MSG_ReadByte ();
else if (cl.stats[STAT_ACTIVEWEAPON] != i)
i = 0; {
cl.stats[STAT_ACTIVEWEAPON] = i;
HUD_Change_time = Sys_DoubleTime() + 5;
}
// Weapon model index
i = MSG_ReadByte();
if (cl.stats[STAT_WEAPON] != i) if (cl.stats[STAT_WEAPON] != i)
{ {
cl.stats[STAT_WEAPON] = i; cl.stats[STAT_WEAPON] = i;
Sbar_Changed (); Sbar_Changed ();
} }
// Other weapon stats
if (bits & SU_WEAPON) {
// Weapon Name
size_t len = MSG_ReadByte();
for(i = 0; i < 32; i++) {
cl.weaponname[i] = 0;
}
for(i = 0; i < len; i++) {
cl.weaponname[i] = MSG_ReadChar();
}
// Weapon ADS Offset
for(i = 0; i < 3; i++)
cl.ads_offset[i] = MSG_ReadFloat();
// Muzzle flash size
cl.flash_size = MSG_ReadByte();
}
if (bits & SU_GRENADES) if (bits & SU_GRENADES)
i = MSG_ReadLong (); i = MSG_ReadByte();
else else
i = 0; i = 0;
@ -1039,7 +1051,7 @@ void CL_ParseClientdata (void)
cl.stats[STAT_GRENADES] = i; cl.stats[STAT_GRENADES] = i;
} }
i = MSG_ReadShort (); i = MSG_ReadByte();
if (cl.stats[STAT_PRIGRENADES] != i) if (cl.stats[STAT_PRIGRENADES] != i)
{ {
HUD_Change_time = Sys_DoubleTime() + 5; HUD_Change_time = Sys_DoubleTime() + 5;
@ -1047,14 +1059,14 @@ void CL_ParseClientdata (void)
} }
i = MSG_ReadShort (); i = MSG_ReadByte();
if (cl.stats[STAT_SECGRENADES] != i) if (cl.stats[STAT_SECGRENADES] != i)
{ {
HUD_Change_time = Sys_DoubleTime() + 5; HUD_Change_time = Sys_DoubleTime() + 5;
cl.stats[STAT_SECGRENADES] = i; cl.stats[STAT_SECGRENADES] = i;
} }
i = MSG_ReadShort (); i = MSG_ReadByte();
if (cl.stats[STAT_HEALTH] != i) if (cl.stats[STAT_HEALTH] != i)
{ {
cl.stats[STAT_HEALTH] = i; cl.stats[STAT_HEALTH] = i;
@ -1079,13 +1091,6 @@ void CL_ParseClientdata (void)
if (cl.stats[STAT_ZOOM] != i) if (cl.stats[STAT_ZOOM] != i)
cl.stats[STAT_ZOOM] = i; cl.stats[STAT_ZOOM] = i;
i = MSG_ReadByte ();
if (cl.stats[STAT_ACTIVEWEAPON] != i)
{
cl.stats[STAT_ACTIVEWEAPON] = i;
HUD_Change_time = Sys_DoubleTime() + 5;
}
// This corresponds to SV_WriteClientdataToMessage // This corresponds to SV_WriteClientdataToMessage
i = MSG_ReadByte (); i = MSG_ReadByte ();
if (cl.stats[STAT_ROUNDS] != i) if (cl.stats[STAT_ROUNDS] != i)

View file

@ -46,6 +46,7 @@ typedef struct edict_s
int leafnums[MAX_ENT_LEAFS]; int leafnums[MAX_ENT_LEAFS];
entity_state_t baseline; entity_state_t baseline;
int last_weapon; /* cypress -- hack to avoid spamming a bunch of data, and only send on wep change */
unsigned char alpha; /* johnfitz -- hack to support alpha since it's not part of entvars_t */ unsigned char alpha; /* johnfitz -- hack to support alpha since it's not part of entvars_t */
qboolean sendinterval; /* johnfitz -- send time until nextthink to client for better lerp timing */ qboolean sendinterval; /* johnfitz -- send time until nextthink to client for better lerp timing */

View file

@ -105,10 +105,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SU_WEAPONALPHA (1<<25) // 1 byte, this is alpha for weaponmodel, uses ENTALPHA_ENCODE, not sent if ENTALPHA_DEFAULT #define SU_WEAPONALPHA (1<<25) // 1 byte, this is alpha for weaponmodel, uses ENTALPHA_ENCODE, not sent if ENTALPHA_DEFAULT
#define SU_MAXSPEED (1<<26) #define SU_MAXSPEED (1<<26)
#define SU_FACINGENEMY (1<<27) #define SU_FACINGENEMY (1<<27)
#define SU_WEAPONNAME (1<<28) #define SU_TOUCHNAME (1<<28)
#define SU_TOUCHNAME (1<<29) #define SU_UNUSED30 (1<<29)
#define SU_UNUSED30 (1<<30) #define SU_EXTEND3 (1<<30) // another byte to follow, future expansion
#define SU_EXTEND3 (1<<31) // another byte to follow, future expansion
//johnfitz //johnfitz
// a sound with no channel is a local only sound // a sound with no channel is a local only sound

2
source/qconsole.log Normal file
View file

@ -0,0 +1,2 @@
LOG started on: 12/02/2023 14:54:40
Playing registered version.

View file

@ -838,20 +838,15 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
if (ent->v.facingenemy) if (ent->v.facingenemy)
bits |= SU_FACINGENEMY; bits |= SU_FACINGENEMY;
if (ent->v.Weapon_Name)
bits |= SU_WEAPONNAME;
if (ent->v.Weapon_Name_Touch) if (ent->v.Weapon_Name_Touch)
bits |= SU_TOUCHNAME; bits |= SU_TOUCHNAME;
//if (ent->v.ADS_Offset[0])
// bits |= SU_ADSOFS;
if ( (int)ent->v.flags & FL_ONGROUND) if ( (int)ent->v.flags & FL_ONGROUND)
bits |= SU_ONGROUND; bits |= SU_ONGROUND;
if ( ent->v.waterlevel >= 2) // cypress - Water stuff is useless.
bits |= SU_INWATER; // if ( ent->v.waterlevel >= 2)
// bits |= SU_INWATER;
for (i=0 ; i<3 ; i++) for (i=0 ; i<3 ; i++)
{ {
@ -867,8 +862,10 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
if (ent->v.weaponskin) if (ent->v.weaponskin)
bits |= SU_WEAPONSKIN; bits |= SU_WEAPONSKIN;
// if (ent->v.weapon) if ((int)ent->v.weapon != ent->last_weapon) {
bits |= SU_WEAPON; bits |= SU_WEAPON;
ent->last_weapon = (int)ent->v.weapon; // cypress -- don't network a bunch of weapon shit. also, why is this a float?
}
if (ent->v.grenades) if (ent->v.grenades)
bits |= SU_GRENADES; bits |= SU_GRENADES;
@ -909,16 +906,15 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
MSG_WriteChar (msg, ent->v.velocity[i]/16); MSG_WriteChar (msg, ent->v.velocity[i]/16);
} }
for(i = 0; i < 3; i++) // FIXME: We allow QC to change Flash_Offset on-the-fly
MSG_WriteFloat(msg, ent->v.ADS_Offset[i]); // for left-handed weapons. May want to make this it's
// own field, but until then it's float spam!
for(i = 0; i < 3; i++) for(i = 0; i < 3; i++)
MSG_WriteFloat(msg, ent->v.Flash_Offset[i]); MSG_WriteFloat(msg, ent->v.Flash_Offset[i]);
MSG_WriteByte(msg, ent->v.Flash_Size); // WHY WAS THIS A LONG????
if (bits & SU_PERKS) if (bits & SU_PERKS)
MSG_WriteLong (msg, ent->v.perks); MSG_WriteByte (msg, ent->v.perks);
if (bits & SU_MAXSPEED) if (bits & SU_MAXSPEED)
MSG_WriteFloat (msg, ent->v.maxspeed); MSG_WriteFloat (msg, ent->v.maxspeed);
@ -926,17 +922,8 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
if (bits & SU_FACINGENEMY) if (bits & SU_FACINGENEMY)
MSG_WriteByte (msg, ent->v.facingenemy); MSG_WriteByte (msg, ent->v.facingenemy);
if (bits & SU_WEAPONNAME) { // FIXME: I don't really like forcing a pass of 32 bytes per frame whenever
size_t len = 32; // we touch a weapon or something. Kinda lame.
if (strlen(pr_strings+ent->v.Weapon_Name) < 32)
len = strlen(pr_strings+ent->v.Weapon_Name);
MSG_WriteByte(msg, len);
for(i = 0; i < len; i++) {
MSG_WriteChar(msg, (pr_strings+ent->v.Weapon_Name)[i]);
}
}
if (bits & SU_TOUCHNAME) { if (bits & SU_TOUCHNAME) {
size_t len = 32; size_t len = 32;
if (strlen(pr_strings+ent->v.Weapon_Name_Touch) < 32) if (strlen(pr_strings+ent->v.Weapon_Name_Touch) < 32)
@ -952,20 +939,47 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
MSG_WriteByte (msg, ent->v.weaponframe); MSG_WriteByte (msg, ent->v.weaponframe);
if (bits & SU_WEAPONSKIN) if (bits & SU_WEAPONSKIN)
MSG_WriteByte (msg, ent->v.weaponskin); MSG_WriteByte (msg, ent->v.weaponskin);
if (bits & SU_WEAPON)
// Active Weapon
MSG_WriteByte (msg, ent->v.weapon);
// Weapon model index
MSG_WriteByte (msg, SV_ModelIndex(PR_GetString(ent->v.weaponmodel))); MSG_WriteByte (msg, SV_ModelIndex(PR_GetString(ent->v.weaponmodel)));
if (bits & SU_GRENADES) // Cypress -- SU_WEAPON exchanges are now a lot more involved, so they only
MSG_WriteLong (msg, ent->v.grenades); // happen if absolutely necessary.
if (bits & SU_WEAPON) {
// Weapon Name
size_t len = 32; // hard-coded 32 character limit, deal with it.
if (strlen(pr_strings+ent->v.Weapon_Name) < 32)
len = strlen(pr_strings+ent->v.Weapon_Name);
MSG_WriteByte(msg, len);
for(i = 0; i < len; i++) {
MSG_WriteChar(msg, (pr_strings+ent->v.Weapon_Name)[i]);
}
// Weapon ADS Offset
for(i = 0; i < 3; i++)
MSG_WriteFloat(msg, ent->v.ADS_Offset[i]);
// Muzzle flash size
MSG_WriteByte(msg, ent->v.Flash_Size);
}
// Why the fuck was this a long?
if (bits & SU_GRENADES)
MSG_WriteByte(msg, ent->v.grenades);
// Why the FUCK were these shorts?!?!?
MSG_WriteByte (msg, ent->v.primary_grenades);
MSG_WriteByte (msg, ent->v.secondary_grenades);
MSG_WriteByte (msg, ent->v.health); // this one was id's 'fault'
MSG_WriteShort (msg, ent->v.primary_grenades);
MSG_WriteShort (msg, ent->v.secondary_grenades);
MSG_WriteShort (msg, ent->v.health);
MSG_WriteByte (msg, ent->v.currentammo); MSG_WriteByte (msg, ent->v.currentammo);
MSG_WriteByte (msg, ent->v.currentmag); MSG_WriteByte (msg, ent->v.currentmag);
MSG_WriteByte (msg, ent->v.zoom); MSG_WriteByte (msg, ent->v.zoom);
MSG_WriteByte (msg, ent->v.weapon);
MSG_WriteByte (msg, pr_global_struct->rounds); // This cooresponds to CL_ParseClientdata MSG_WriteByte (msg, pr_global_struct->rounds); // This cooresponds to CL_ParseClientdata
MSG_WriteByte (msg, pr_global_struct->rounds_change); MSG_WriteByte (msg, pr_global_struct->rounds_change);
MSG_WriteByte (msg, ent->v.x2_icon); MSG_WriteByte (msg, ent->v.x2_icon);