From 6611e8e7fc7d1e8f1d66374df0b1d771a5baccf4 Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Sun, 7 Aug 2022 14:14:53 -0700 Subject: [PATCH] Clean up our player enumflags. --- src/shared/player.qc | 50 +++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/shared/player.qc b/src/shared/player.qc index 72ea847..1d14b79 100644 --- a/src/shared/player.qc +++ b/src/shared/player.qc @@ -24,34 +24,16 @@ /* all potential SendFlags bits we can possibly send */ enumflags { - PLAYER_KEEPALIVE, - PLAYER_MODELINDEX, - PLAYER_ORIGIN, - PLAYER_ORIGIN_Z, - PLAYER_ANGLES_X, - PLAYER_ANGLES_Y, - PLAYER_COLORMAP, - PLAYER_VELOCITY, - PLAYER_VELOCITY_Z, - PLAYER_FLAGS, - PLAYER_WEAPON, - PLAYER_ITEMS, - PLAYER_HEALTH, - PLAYER_ARMOR, - PLAYER_MOVETYPE, - PLAYER_VIEWOFS, - PLAYER_TOPFRAME, + PLAYER_TOPFRAME = PLAYER_CUSTOMFIELDSTART, PLAYER_BOTTOMFRAME, PLAYER_AMMO1, PLAYER_AMMO2, PLAYER_AMMO3, - PLAYER_UNUSED1, - PLAYER_UNUSED2 + PLAYER_UNUSED5, + PLAYER_UNUSED6, + PLAYER_UNUSED7 }; - - - #ifdef SERVER void CSEv_ViewAnglesR_fff(float arg_x, float arg_y, float arg_z){ player pl = (player)self; @@ -779,12 +761,36 @@ player::SendEntity float player::SendEntity(entity ePEnt, float fChanged) { + bool is_spec = false; + bool spectarget = false; + /* don't broadcast invisible players */ if (IsFakeSpectator() && ePEnt != this) return (0); if (!GetModelindex() && ePEnt != this) return (0); + /* figure out if we should optimise this player */ + if (ePEnt.flags & FL_CLIENT && ePEnt != this) { + NSClientSpectator sp = (NSClientSpectator)ePEnt; + is_spec = (sp.IsFakeSpectator() || sp.IsRealSpectator()); + spectarget = (is_spec == true && edict_num(sp.spec_ent) == this); + } + + /* if we're a spectator of any type and spectate this player */ + if (ePEnt != this && spectarget == false) { + fChanged &= ~PLAYER_ITEMS; + fChanged &= ~PLAYER_HEALTH; + fChanged &= ~PLAYER_TIMINGS; + fChanged &= ~PLAYER_AMMO1; + fChanged &= ~PLAYER_AMMO2; + fChanged &= ~PLAYER_AMMO3; + fChanged &= ~PLAYER_FLAGS; + fChanged &= ~PLAYER_PUNCHANGLE; + fChanged &= ~PLAYER_VIEWZOOM; + fChanged &= ~PLAYER_SPECTATE; + } + WriteByte(MSG_ENTITY, ENT_PLAYER); WriteFloat(MSG_ENTITY, fChanged);