]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/items/inventory.qh
Merge branch 'Mario/resource_registry' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items / inventory.qh
index 3ffa6c003d63155fd6c3f4dd2450cc04a779089e..22a4d94c387335f833d0867f2acb1df01e776663 100644 (file)
@@ -138,19 +138,23 @@ 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 InventoryStorage_attach(entity e) { e.inventory_store = NEW(Inventory); e.inventory_store.drawonlytoclient = e; }
-void InventoryStorage_delete(entity e) { delete(e.inventory_store); }
-void InventoryStorage_clear(entity e)
+void Inventory_clear(entity store)
 {
-    // we don't need to network the changes, that is done when the inventory is detached
+    // NOTE: you will need to perform Inventory_update after this to update the storage entity
+    // (unless store is the storage entity)
     FOREACH(Items, true, {
         .int fld = inv_items[it.m_id];
-        e.inventory_store.(fld) = 0;
+        store.(fld) = 0;
     });
 }
+
+void InventoryStorage_attach(entity e) { e.inventory_store = NEW(Inventory); e.inventory_store.drawonlytoclient = e; }
+void InventoryStorage_delete(entity e) { delete(e.inventory_store); }
 #endif