From: Mario Date: Mon, 10 Sep 2018 15:30:20 +0000 (+1000) Subject: Move Inventory to PlayerState and disable the entity pickup messages X-Git-Tag: xonotic-v0.8.5~1881 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8066377c13a55198882ee1262d2c9ec00571eb94;p=xonotic%2Fxonotic-data.pk3dir.git Move Inventory to PlayerState and disable the entity pickup messages --- diff --git a/qcsrc/common/items/inventory.qh b/qcsrc/common/items/inventory.qh index 9075c0912..ba824f40b 100644 --- a/qcsrc/common/items/inventory.qh +++ b/qcsrc/common/items/inventory.qh @@ -107,7 +107,7 @@ bool Inventory_Send(Inventory this, Client to, int sf) TC(Inventory, this); WriteHeader(MSG_ENTITY, ENT_CLIENT_INVENTORY); entity e = this.owner; - if (IS_SPEC(e)) e = e.enemy; + if (IS_SPEC(e)) e = PS(e.enemy); // TODO: how can this *ever* be the case? TC(Player, e); Inventory data = e.inventory; Inventory_Write(data); @@ -118,7 +118,7 @@ void Inventory_new(entity e) { Inventory inv = NEW(Inventory), bak = NEW(Inventory); inv.inventory = bak; - inv.drawonlytoclient = e; + inv.drawonlytoclient = IS_CLIENT(e) ? e : e.m_client; Net_LinkEntity((inv.owner = e).inventory = inv, false, 0, Inventory_Send); } void Inventory_delete(entity e) { delete(e.inventory.inventory); delete(e.inventory); } diff --git a/qcsrc/common/items/item/pickup.qc b/qcsrc/common/items/item/pickup.qc index b5944fc0a..a3c2d779e 100644 --- a/qcsrc/common/items/item/pickup.qc +++ b/qcsrc/common/items/item/pickup.qc @@ -11,9 +11,10 @@ METHOD(Pickup, giveTo, bool(Pickup this, entity item, entity player)) TC(Pickup, this); bool b = Item_GiveTo(item, player); if (b) { - LOG_DEBUGF("entity %i picked up %s", player, this.m_name); - player.inventory.inv_items[this.m_id]++; - Inventory_update(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); } return b; } diff --git a/qcsrc/common/state.qc b/qcsrc/common/state.qc index 772dbccbd..2e3a262a5 100644 --- a/qcsrc/common/state.qc +++ b/qcsrc/common/state.qc @@ -7,7 +7,7 @@ void PlayerState_attach(entity this) { this._ps = NEW(PlayerState, this); - Inventory_new(this); + Inventory_new(PS(this)); } void PlayerState_detach(entity this) @@ -18,11 +18,10 @@ void PlayerState_detach(entity this) if (ps.m_client != this) return; // don't own state, spectator ps.ps_push(ps, this); + Inventory_delete(ps); FOREACH_CLIENT(PS(it) == ps, { PS(it) = NULL; }); delete(ps); - - Inventory_delete(this); } void GetCvars(entity this, entity store, int); diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index a3f2336a9..cdf5748e6 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -162,9 +162,9 @@ CLASS(WeaponPickup, Pickup) METHOD(WeaponPickup, giveTo, bool(entity this, entity item, entity player)) { bool b = Item_GiveTo(item, player); - if (b) { - LOG_TRACEF("entity %i picked up %s", player, this.m_name); - } + //if (b) { + //LOG_TRACEF("entity %i picked up %s", player, this.m_name); + //} return b; } #endif