From: Mario Date: Fri, 26 Oct 2018 02:18:55 +0000 (+1000) Subject: Send player/local status so CSQC can do some things with it without relying on entnum X-Git-Tag: xonotic-v0.8.5~1746 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4d91f9f38ee0fe58d4ac93662da2bcd52921d373;p=xonotic%2Fxonotic-data.pk3dir.git Send player/local status so CSQC can do some things with it without relying on entnum --- diff --git a/qcsrc/client/csqcmodel_hooks.qc b/qcsrc/client/csqcmodel_hooks.qc index 522859c8b..bbe0b4d22 100644 --- a/qcsrc/client/csqcmodel_hooks.qc +++ b/qcsrc/client/csqcmodel_hooks.qc @@ -18,8 +18,6 @@ .float death_time; .int modelflags; -.bool isplayermodel; - // FEATURE: LOD .int lodmodelindex0; .int lodmodelindex1; @@ -415,7 +413,7 @@ void CSQCModel_AutoTagIndex_Apply(entity this) // recursive predraw call to fix issues with forcemodels and LOD if bone indexes mismatch if(this.tag_entity.classname == "csqcmodel") { - CSQCModel_Hook_PreDraw(this.tag_entity, (this.tag_entity.entnum >= 1 && this.tag_entity.entnum <= maxclients)); + CSQCModel_Hook_PreDraw(this.tag_entity, (this.tag_entity.isplayermodel & ISPLAYER_ENT)); } if(this.tag_entity.modelindex != this.tag_entity_lastmodelindex) @@ -610,7 +608,7 @@ void CSQCModel_Hook_PreDraw(entity this, bool isplayer) if(this.isplayermodel && this.drawmask) // this checks if it's a player MODEL! { - CSQCPlayer_ModelAppearance_Apply(this, this.entnum == player_localnum + 1); + CSQCPlayer_ModelAppearance_Apply(this, (this.isplayermodel & ISPLAYER_LOCAL)); CSQCPlayer_LOD_Apply(this); if(!isplayer) @@ -710,7 +708,9 @@ void CSQCModel_Hook_PreUpdate(entity this, bool isnew, bool isplayer, bool isloc void CSQCModel_Hook_PostUpdate(entity this, bool isnew, bool isplayer, bool islocalplayer) { // is it a player model? (shared state) - this.isplayermodel = (substring(this.model, 0, 14) == "models/player/" || substring(this.model, 0, 17) == "models/ok_player/" || (substring(this.model, 0, 16) == "models/monsters/" && (this.entnum >= 1 && this.entnum <= maxclients))); + bool is_playermodel = (substring(this.model, 0, 14) == "models/player/" || substring(this.model, 0, 17) == "models/ok_player/" || + (substring(this.model, 0, 16) == "models/monsters/" && (this.isplayermodel & BIT(1)))); + this.isplayermodel = BITSET(this.isplayermodel, ISPLAYER_MODEL, is_playermodel); // save values set by server if(this.isplayermodel) diff --git a/qcsrc/client/csqcmodel_hooks.qh b/qcsrc/client/csqcmodel_hooks.qh index 8ed256379..f952d0b0a 100644 --- a/qcsrc/client/csqcmodel_hooks.qh +++ b/qcsrc/client/csqcmodel_hooks.qh @@ -23,6 +23,8 @@ const int MF_TRACER3 = BIT(7); // purple trail .int csqcmodel_modelflags; .int csqcmodel_traileffect; +.int isplayermodel; + void CSQCModel_Effects_Apply(entity this); void CSQCModel_Hook_PreDraw(entity this, bool isplayer); diff --git a/qcsrc/common/effects/qc/damageeffects.qc b/qcsrc/common/effects/qc/damageeffects.qc index 1fc64d1d2..7ab6697c3 100644 --- a/qcsrc/common/effects/qc/damageeffects.qc +++ b/qcsrc/common/effects/qc/damageeffects.qc @@ -53,7 +53,6 @@ void Damage_DamageInfo(vector org, float coredamage, float edgedamage, float rad .float cnt; .int state; -.bool isplayermodel; void DamageEffect_Think(entity this) { @@ -79,7 +78,7 @@ void DamageEffect_Think(entity this) return; } this.state = this.owner.csqcmodel_isdead; - if(this.owner.isplayermodel && (this.owner.entnum == player_localentnum) && !autocvar_chase_active) + if(this.owner.isplayermodel && (this.owner.isplayermodel & ISPLAYER_LOCAL) && !autocvar_chase_active) return; // if we aren't using a third person camera, hide our own effects // now generate the particles diff --git a/qcsrc/common/physics/player.qh b/qcsrc/common/physics/player.qh index 29c028f03..ee78f71a4 100644 --- a/qcsrc/common/physics/player.qh +++ b/qcsrc/common/physics/player.qh @@ -190,8 +190,8 @@ STATIC_INIT(PHYS_INPUT_BUTTON) .entity hook; // TODO - #define IS_CLIENT(s) ((s).isplayermodel || (s) == csqcplayer) - #define IS_PLAYER(s) ((s).isplayermodel) + #define IS_CLIENT(s) (((s).isplayermodel & ISPLAYER_ENT) || (s) == csqcplayer) + #define IS_PLAYER(s) ((s).isplayermodel & ISPLAYER_ENT) #define IS_NOT_A_CLIENT(s) (!(s).isplayermodel && (s) != csqcplayer) #define isPushable(s) ((s).isplayermodel || (s).pushable || ((s).flags & FL_PROJECTILE)) diff --git a/qcsrc/lib/csqcmodel/cl_model.qc b/qcsrc/lib/csqcmodel/cl_model.qc index 05aba388c..1275f1178 100644 --- a/qcsrc/lib/csqcmodel/cl_model.qc +++ b/qcsrc/lib/csqcmodel/cl_model.qc @@ -223,9 +223,10 @@ void CSQCModel_remove(entity this) NET_HANDLE(ENT_CLIENT_MODEL, bool isnew) { int sf = ReadInt24_t(); + int psf = ReadByte(); // some nice flags for CSQCMODEL_IF and the hooks - bool isplayer = ReadByte() || (this.entnum >= 1 && this.entnum <= maxclients); + bool isplayer = (psf & ISPLAYER_ENT) || (this.entnum >= 1 && this.entnum <= maxclients); if (isnew && isplayer) { CSQCModel_players[this.entnum - 1] = this; @@ -234,6 +235,9 @@ NET_HANDLE(ENT_CLIENT_MODEL, bool isnew) bool islocalplayer = (this.entnum == player_localnum + 1); noref bool isnolocalplayer = (isplayer && !islocalplayer); + this.isplayermodel = BITSET(this.isplayermodel, ISPLAYER_ENT, isplayer); + this.isplayermodel = BITSET(this.isplayermodel, ISPLAYER_LOCAL, islocalplayer); + this.classname = "csqcmodel"; this.iflags |= IFLAG_ORIGIN; // interpolate origin too this.iflags |= IFLAG_ANGLES; // interpolate angles too diff --git a/qcsrc/lib/csqcmodel/common.qh b/qcsrc/lib/csqcmodel/common.qh index f8375d09e..942c021e8 100644 --- a/qcsrc/lib/csqcmodel/common.qh +++ b/qcsrc/lib/csqcmodel/common.qh @@ -53,6 +53,10 @@ IN THE SOFTWARE.\ .float frame2time; .float lerpfrac; +const int ISPLAYER_MODEL = BIT(0); // using a player model +const int ISPLAYER_ENT = BIT(1); // is an actual player +const int ISPLAYER_LOCAL = BIT(2); // is the local player + const int CSQCMODEL_PROPERTY_FRAME = BIT(23); const int CSQCMODEL_PROPERTY_TELEPORTED = BIT(22); // the "teleport bit" cancelling interpolation const int CSQCMODEL_PROPERTY_MODELINDEX = BIT(21); diff --git a/qcsrc/lib/csqcmodel/sv_model.qc b/qcsrc/lib/csqcmodel/sv_model.qc index 0ff438994..ba18464d7 100644 --- a/qcsrc/lib/csqcmodel/sv_model.qc +++ b/qcsrc/lib/csqcmodel/sv_model.qc @@ -32,9 +32,13 @@ bool CSQCModel_Send(entity this, entity to, int sf) noref bool islocalplayer = (this == to); noref bool isnolocalplayer = (isplayer && (this != to)); + int psf = 0; + psf = BITSET(psf, ISPLAYER_ENT, isplayer); + psf = BITSET(psf, ISPLAYER_LOCAL, islocalplayer); + WriteHeader(MSG_ENTITY, ENT_CLIENT_MODEL); WriteInt24_t(MSG_ENTITY, sf); - WriteByte(MSG_ENTITY, isplayer); + WriteByte(MSG_ENTITY, psf); #define CSQCMODEL_IF(cond) if(cond) { #define CSQCMODEL_ENDIF }