From 2c5fb2544a77f2cf5fb786aca0d3e8b6e8aaf0cb Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Thu, 18 May 2023 22:34:27 +1000 Subject: [PATCH 1/1] Use correct pickup item bboxes on clients CSQC items currently don't use the item registry so properties including model and size must be networked. --- qcsrc/client/items/items.qc | 14 +++++++------- qcsrc/common/items/item.qh | 1 + qcsrc/server/items/items.qc | 23 ++++++++++++++++++++--- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/qcsrc/client/items/items.qc b/qcsrc/client/items/items.qc index 4c46ae0c4..7e888e037 100644 --- a/qcsrc/client/items/items.qc +++ b/qcsrc/client/items/items.qc @@ -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(); diff --git a/qcsrc/common/items/item.qh b/qcsrc/common/items/item.qh index a4fea71ad..364baeebc 100644 --- a/qcsrc/common/items/item.qh +++ b/qcsrc/common/items/item.qh @@ -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); diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index 57720ef9a..ede9cbbaf 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -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); -- 2.39.2