]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use correct pickup item bboxes on clients
authorbones_was_here <bones_was_here@xonotic.au>
Thu, 18 May 2023 12:34:27 +0000 (22:34 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Sun, 21 May 2023 14:34:13 +0000 (00:34 +1000)
CSQC items currently don't use the item registry so properties including
model and size must be networked.

qcsrc/client/items/items.qc
qcsrc/common/items/item.qh
qcsrc/server/items/items.qc

index 4c46ae0c4ae7d9455e6374ed944be6dfc3e9df12..7e888e037640285cc582daacbeb9e0de7117ee6e 100644 (file)
@@ -145,11 +145,6 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
         this.angles = ReadAngleVector();
     }
 
-    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.
     {
         this.ItemStatus = ReadByte();
@@ -230,10 +225,15 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
         _setmodel(this, this.mdl);
 
         this.skin = ReadByte();
-
-        setsize(this, '-16 -16 0', '16 16 48');
     }
 
+       if(sf & ISF_SIZE && sf & ISF_SIZE2) // Default
+               setsize(this, ITEM_D_MINS, ITEM_D_MAXS);
+       else if(sf & ISF_SIZE && !(sf & ISF_SIZE2)) // Small
+               setsize(this, ITEM_S_MINS, ITEM_S_MAXS);
+       else if(!(sf & ISF_SIZE) && sf & ISF_SIZE2) // Large
+               setsize(this, ITEM_D_MINS, ITEM_L_MAXS);
+
     if(sf & ISF_COLORMAP)
     {
         this.colormap = ReadShort();
index a4fea71ad8ec73842ebbe946d377a8b88a4e2a61..364baeebcac65f4d77c74bd768d225421a19fcf0 100644 (file)
@@ -38,6 +38,7 @@ const int IT_SPEED                                            = BIT(13);
 const int IT_PICKUPMASK                        = IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS | IT_JETPACK | IT_FUEL_REGEN; // strength and invincible are handled separately
 
 // item networking
+const int ISF_SIZE2             = BIT(0);
 const int ISF_LOCATION          = BIT(1);
 const int ISF_MODEL             = BIT(2);
 const int ISF_STATUS            = BIT(3);
index 57720ef9aff2e29fe8912ba276d50bb379e58600..ede9cbbaf0f3b5903b4384ddcdd59b2eba485d6d 100644 (file)
@@ -36,6 +36,26 @@ bool ItemSend(entity this, entity to, int sf)
        else
                sf &= ~ISF_DROP;
 
+       // if the client must set the bbox or model,
+       // reuse ISF_SIZE and ISF_SIZE2 to also tell it which bbox
+       if(sf & ISF_SIZE || sf & ISF_MODEL)
+       {
+               if(this.maxs == ITEM_S_MAXS) // Small
+               {
+                       sf |= ISF_SIZE;
+                       sf &= ~ISF_SIZE2;
+               }
+               else if(this.maxs == ITEM_L_MAXS) // Large
+               {
+                       sf &= ~ISF_SIZE;
+                       sf |= ISF_SIZE2;
+               }
+               else // Default
+                       sf |= ISF_SIZE | ISF_SIZE2;
+       }
+       else // don't set the bbox
+               sf &= ~ISF_SIZE & ~ISF_SIZE2;
+
        WriteHeader(MSG_ENTITY, ENT_CLIENT_ITEM);
        WriteByte(MSG_ENTITY, sf);
 
@@ -50,9 +70,6 @@ bool ItemSend(entity this, entity to, int sf)
                WriteAngleVector(MSG_ENTITY, this.angles);
        }
 
-       // sets size on the client, unused on server
-       //if(sf & ISF_SIZE)
-
        if(sf & ISF_STATUS)
                WriteByte(MSG_ENTITY, this.ItemStatus);