]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Send player/local status so CSQC can do some things with it without relying on entnum
authorMario <mario@smbclan.net>
Fri, 26 Oct 2018 02:18:55 +0000 (12:18 +1000)
committerMario <mario@smbclan.net>
Fri, 26 Oct 2018 02:18:55 +0000 (12:18 +1000)
qcsrc/client/csqcmodel_hooks.qc
qcsrc/client/csqcmodel_hooks.qh
qcsrc/common/effects/qc/damageeffects.qc
qcsrc/common/physics/player.qh
qcsrc/lib/csqcmodel/cl_model.qc
qcsrc/lib/csqcmodel/common.qh
qcsrc/lib/csqcmodel/sv_model.qc

index 522859c8b193ea1d4c4729b72ba50d6322aafc5c..bbe0b4d22dc5d3f972f877fea7a15dc7f554688c 100644 (file)
@@ -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)
index 8ed256379ff2e6d60b6bbf5a8598472f185999b4..f952d0b0a02dcc652482733f72d2debff38c919a 100644 (file)
@@ -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);
index 1fc64d1d259697f7fb04c691a1d83ead70ef220f..7ab6697c34830a8a19d6874912c0c83681081cc4 100644 (file)
@@ -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
index 29c028f03267500aed3f84994ff0b524e14c6c7c..ee78f71a4807a1d020c5fdb2966d27955a6676de 100644 (file)
@@ -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))
 
index 05aba388c4b7c27a49d13cdb160a75afc559a43b..1275f11783a0fb64fe3d2edfef4a31c4f8ec0d3b 100644 (file)
@@ -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
index f8375d09e8202de55cdda5a61dcc6de4d85b9912..942c021e828d0d125bac46ff8808ff84ddaac205 100644 (file)
@@ -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);
index 0ff4389944c03dcda8f0756cb0dba5d21d43fef5..ba18464d723d80b3690c4f81c124c88211b4dabb 100644 (file)
@@ -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 }