{
if (MUTATOR_CALLHOOK(DrawScoreboardItemStats))
return false;
- if (!autocvar_hud_panel_scoreboard_itemstats || warmup_stage || ypos > 0.91 * vid_conheight)
+ if (!autocvar_hud_panel_scoreboard_itemstats || !g_inventory || warmup_stage || ypos > 0.91 * vid_conheight)
return false;
if (time < scoreboard_time + autocvar_hud_panel_scoreboard_itemstats_showdelay
#ifdef CSQC
Inventory g_inventory;
+void Inventory_remove(entity this)
+{
+ if(g_inventory == this)
+ g_inventory = NULL;
+}
+
NET_HANDLE(ENT_CLIENT_INVENTORY, bool isnew)
{
make_pure(this);
g_inventory = this;
+ this.entremove = Inventory_remove;
const int majorBits = Readbits(Inventory_groups_major);
for (int i = 0; i < Inventory_groups_major; ++i) {
if (!(majorBits & BIT(i))) {
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_detach(entity e) { delete(e.inventory_store); }
+void InventoryStorage_delete(entity e) { delete(e.inventory_store); }
+void InventoryStorage_clear(entity e)
+{
+ // we don't need to network the changes, that is done when the inventory is detached
+ FOREACH(Items, true, {
+ .int fld = inv_items[it.m_id];
+ e.inventory_store.(fld) = 0;
+ });
+}
#endif
void Inventory_new(PlayerState this);
void Inventory_delete(entity this);
void InventoryStorage_attach(PlayerState this);
-void InventoryStorage_detach(PlayerState this);
+void InventoryStorage_delete(PlayerState this);
+void InventoryStorage_clear(PlayerState this);
void PlayerState_attach(entity this)
{
PlayerState ps = PS(this);
if (!ps) return; // initial connect
PS(this) = NULL;
+ InventoryStorage_clear(this);
if (ps.m_client != this) return; // don't own state, spectator
ps.ps_push(ps, this);
W_HitPlotClose(this);
ClientData_Detach(this);
entcs_detach(this);
- InventoryStorage_detach(this);
+ InventoryStorage_delete(this);
delete(CS(this));
this._cs = NULL;