Make the client side IS_PLAYER and IS_CLIENT checks more accurate
authorMario <mario@smbclan.net>
Fri, 26 Oct 2018 02:38:28 +0000 (12:38 +1000)
committerMario <mario@smbclan.net>
Fri, 26 Oct 2018 02:38:28 +0000 (12:38 +1000)
qcsrc/client/csqcmodel_hooks.qc
qcsrc/common/physics/player.qh
qcsrc/lib/csqcmodel/cl_model.qc
qcsrc/lib/csqcmodel/common.qh
qcsrc/lib/csqcmodel/sv_model.qc

index bbe0b4d..0b62704 100644 (file)
@@ -413,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.isplayermodel & ISPLAYER_ENT));
+                       CSQCModel_Hook_PreDraw(this.tag_entity, (this.tag_entity.isplayermodel & ISPLAYER_CLIENT));
                }
 
                if(this.tag_entity.modelindex != this.tag_entity_lastmodelindex)
index ee78f71..9ecf7ea 100644 (file)
@@ -190,8 +190,8 @@ STATIC_INIT(PHYS_INPUT_BUTTON)
        .entity hook;
 
 // TODO
-       #define IS_CLIENT(s)                        (((s).isplayermodel & ISPLAYER_ENT) || (s) == csqcplayer)
-       #define IS_PLAYER(s)                        ((s).isplayermodel & ISPLAYER_ENT)
+       #define IS_CLIENT(s)                        (((s).isplayermodel & ISPLAYER_CLIENT) || (s) == csqcplayer)
+       #define IS_PLAYER(s)                        ((s).isplayermodel & ISPLAYER_PLAYER)
        #define IS_NOT_A_CLIENT(s)                  (!(s).isplayermodel && (s) != csqcplayer)
        #define isPushable(s)                       ((s).isplayermodel || (s).pushable || ((s).flags & FL_PROJECTILE))
 
index 1275f11..12be0db 100644 (file)
@@ -179,7 +179,7 @@ void CSQCModel_InterpolateAnimation_Do(entity this)
 void CSQCModel_Draw(entity this)
 {
        // some nice flags for CSQCMODEL_IF and the hooks
-       bool isplayer = (this.entnum >= 1 && this.entnum <= maxclients);
+       bool isplayer = (this.isplayermodel & ISPLAYER_CLIENT);
        noref bool islocalplayer = (this.entnum == player_localnum + 1);
        noref bool isnolocalplayer = (isplayer && (this.entnum != player_localnum + 1));
 
@@ -226,7 +226,7 @@ NET_HANDLE(ENT_CLIENT_MODEL, bool isnew)
        int psf = ReadByte();
 
        // some nice flags for CSQCMODEL_IF and the hooks
-       bool isplayer = (psf & ISPLAYER_ENT) || (this.entnum >= 1 && this.entnum <= maxclients);
+       bool isplayer = (psf & ISPLAYER_CLIENT) || (this.entnum >= 1 && this.entnum <= maxclients);
        if (isnew && isplayer)
        {
                CSQCModel_players[this.entnum - 1] = this;
@@ -235,8 +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_CLIENT, isplayer);
        this.isplayermodel = BITSET(this.isplayermodel, ISPLAYER_LOCAL, islocalplayer);
+       this.isplayermodel = BITSET(this.isplayermodel, ISPLAYER_PLAYER, (psf & ISPLAYER_PLAYER));
 
        this.classname = "csqcmodel";
        this.iflags |= IFLAG_ORIGIN; // interpolate origin too
index 942c021..a2c9e68 100644 (file)
@@ -54,8 +54,9 @@ IN THE SOFTWARE.\
 .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_CLIENT = BIT(1); // is a client
 const int ISPLAYER_LOCAL = BIT(2); // is the local player
+const int ISPLAYER_PLAYER = BIT(3); // is a player in the match
 
 const int CSQCMODEL_PROPERTY_FRAME = BIT(23);
 const int CSQCMODEL_PROPERTY_TELEPORTED = BIT(22); // the "teleport bit" cancelling interpolation
index ba18464..584bfc2 100644 (file)
@@ -33,8 +33,9 @@ bool CSQCModel_Send(entity this, entity to, int sf)
        noref bool isnolocalplayer = (isplayer && (this != to));
 
        int psf = 0;
-       psf = BITSET(psf, ISPLAYER_ENT, isplayer);
+       psf = BITSET(psf, ISPLAYER_CLIENT, isplayer);
        psf = BITSET(psf, ISPLAYER_LOCAL, islocalplayer);
+       psf = BITSET(psf, ISPLAYER_PLAYER, IS_PLAYER(this));
 
        WriteHeader(MSG_ENTITY, ENT_CLIENT_MODEL);
        WriteInt24_t(MSG_ENTITY, sf);