]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/items/items.qc
Merge branch 'terencehill/menu_registries' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / items / items.qc
index 1b03ba8fc22443dbd100ebb101b3e7be3d906abe..b72269a9e4b36c36c1b34ee4a49d36b82da47e66 100644 (file)
@@ -15,6 +15,7 @@
 .float anim_start_time; // reusing for bob waveform synchronisation
 .vector angles_held; // reusing for (re)storing original angles
 .float wait, delay, pointtime; // reusing for despawn effects
+.vector m_mins, m_maxs; // reusing for storing standard bbox (same purpose as in SVQC itemdef)
 
 HashMap ENT_CLIENT_ITEM_simple;
 STATIC_INIT(ENT_CLIENT_ITEM_simple)
@@ -69,18 +70,17 @@ void ItemSetModel(entity this, bool wantsimple)
                LOG_WARNF("this.model is unset for item %s", this.classname);
        precache_model(this.model);
        _setmodel(this, this.model);
-       setsize(this, '-16 -16 0', '16 16 48');
-       // bones_was_here TODO: network proper box size for sv_legacy_bbox_expand 0
+       setsize(this, this.m_mins, this.m_maxs);
 }
 
 void ItemDraw(entity this)
 {
-       bool wantsimple = autocvar_cl_simple_items && this.ItemStatus & ITS_ALLOWSI;
+       bool wantsimple = autocvar_cl_simple_items && (this.ItemStatus & ITS_ALLOWSI);
        if(wantsimple != this.item_simple && this.item_simple != -1)
                ItemSetModel(this, wantsimple);
 
        // no bobbing applied to simple items, for consistency's sake (no visual difference between ammo and weapons)
-       bool animate = autocvar_cl_items_animate & 1 && this.item_simple <= 0 && (this.ItemStatus & ITS_ANIMATE1 || this.ItemStatus & ITS_ANIMATE2);
+       bool animate = (autocvar_cl_items_animate & 1) && this.item_simple <= 0 && ((this.ItemStatus & ITS_ANIMATE1) || (this.ItemStatus & ITS_ANIMATE2));
 
        // rotation must be set before running physics
        if(!animate)
@@ -137,9 +137,8 @@ void ItemDraw(entity this)
        if (bobheight != this.origin_z - this.oldorigin_z)
        {
                this.origin_z = this.oldorigin_z + bobheight;
-               this.mins_z = 0 - bobheight; // don't want the absmin and absmax to bob
-               this.maxs_z = 48 - bobheight;
-               // bones_was_here TODO: network proper box size for sv_legacy_bbox_expand 0
+               this.mins_z = this.m_mins.z - bobheight; // don't want the absmin and absmax to bob
+               this.maxs_z = this.m_maxs.z - bobheight;
        }
 
        // set alpha based on distance
@@ -201,7 +200,7 @@ void ItemDraw(entity this)
                if(autocvar_cl_items_animate & 2)
                        this.alpha *= (this.wait - time) / IT_DESPAWNFX_TIME;
 
-               if(autocvar_cl_items_animate & 4 && time >= this.pointtime)
+               if((autocvar_cl_items_animate & 4) && time >= this.pointtime)
                {
                        pointparticles(EFFECT_ITEM_DESPAWN, this.origin + '0 0 16', '0 0 0', 1);
                        if (this.delay > 0.0625)
@@ -235,13 +234,6 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
                this.angles = this.angles_held = ReadAngleVector();
        }
 
-       /* bones_was_here TODO: network proper box size for sv_legacy_bbox_expand 0
-       if(sf & ISF_SIZE)
-       {
-               setsize(this, '-16 -16 0', '16 16 48');
-       }
-       */
-
        if(sf & ISF_STATUS) // need to read/write status first so model can handle simple, fb etc.
        {
                int prevItemStatus = this.ItemStatus;
@@ -275,12 +267,12 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
 
                        if(this.ItemStatus & ITS_GLOW)
                                this.effects &= ~(EF_ADDITIVE | EF_FULLBRIGHT);
-                       if(prevItemStatus & ITS_AVAILABLE && this.alpha)
+                       if((prevItemStatus & ITS_AVAILABLE) && this.alpha)
                                pointparticles(EFFECT_ITEM_PICKUP, (this.absmin + this.absmax) * 0.5, '0 0 0', 1);
                }
        }
 
-       if(sf & ISF_MODEL)
+       if(sf & ISF_SIZE || sf & ISF_SIZE2) // always true when it's spawned (in CSQC's perspective)
        {
                if(isnew)
                {
@@ -290,6 +282,22 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
                        this.entremove = ItemRemove;
                }
 
+               if(sf & ISF_SIZE && !(sf & ISF_SIZE2)) // Small
+               {
+                       this.m_mins = ITEM_S_MINS;
+                       this.m_maxs = ITEM_S_MAXS;
+               }
+               else if(!(sf & ISF_SIZE) && sf & ISF_SIZE2) // Large
+               {
+                       this.m_mins = ITEM_D_MINS;
+                       this.m_maxs = ITEM_L_MAXS;
+               }
+               else // Default
+               {
+                       this.m_mins = ITEM_D_MINS;
+                       this.m_maxs = ITEM_D_MAXS;
+               }
+
                this.fade_end = ReadShort();
 
                strcpy(this.mdl, ReadString());
@@ -323,7 +331,7 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
                SET_ONGROUND(this); // extra overkill
        }
 
-       if(sf & ISF_REMOVEFX && !(sf & ISF_SIZE) && !(sf & ISF_MODEL)) // TODO !isnew isn't reliable for this... are we double sending initialisations?
+       if(sf & ISF_REMOVEFX && !(sf & ISF_SIZE) && !(sf & ISF_SIZE2)) // TODO !isnew isn't reliable for this... are we double sending initialisations?
        {
                // no longer available to pick up, about to be removed
                if (this.drawmask) // this.alpha > 0