]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/items/inventory.qh
Explicitly enable sv_gameplayfix_unstickplayers
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items / inventory.qh
index abc367d51389615815274c79100f7a462e208e31..118b7079d0c832303ae7aa563172515fea190273 100644 (file)
@@ -37,7 +37,10 @@ STATIC_INIT(Inventory)
 #endif
 
 #ifdef CSQC
+#include <client/hud/panel/pickup.qh>
+
 Inventory g_inventory;
+
 void Inventory_remove(entity this)
 {
     if(g_inventory == this)
@@ -63,11 +66,20 @@ NET_HANDLE(ENT_CLIENT_INVENTORY, bool isnew)
             .int fld = inv_items[it.m_id];
             int prev = this.(fld);
             int next = this.(fld) = ReadByte();
+
+            Pickup_Update(it, next - prev);
             LOG_DEBUGF("%s: %.0f -> %.0f", it.m_name, prev, next);
         }
     }
     return true;
 }
+
+NET_HANDLE(TE_CSQC_WEAPONPICKUP, bool isnew)
+{
+       const Weapon it = REGISTRY_GET(Weapons, ReadByte());
+       Pickup_Update(it, 1);
+       return true;
+}
 #endif
 
 #ifdef SVQC
@@ -138,11 +150,22 @@ void Inventory_new(PlayerState this)
 {
     Inventory inv = NEW(Inventory);
     setcefc(inv, Inventory_customize);
-    Net_LinkEntity((inv.owner = this).inventory = inv, false, 0, Inventory_Send);
+       this.inventory = inv;
+       inv.owner = this;
+       Net_LinkEntity(inv, false, 0, Inventory_Send);
 }
+
 void Inventory_delete(entity e) { delete(e.inventory); }
 void Inventory_update(entity e) { e.inventory.SendFlags = 0xFFFFFF; }
 
+void Inventory_pickupitem(Pickup this, entity player)
+{
+       //LOG_DEBUGF("entity %i picked up %s", player, this.m_name);
+       entity store = IS_PLAYER(player) ? PS(player) : player;
+       ++store.inventory.inv_items[this.m_id];
+       Inventory_update(store);
+}
+
 void Inventory_clear(entity store)
 {
     // NOTE: you will need to perform Inventory_update after this to update the storage entity