From: Mario Date: Thu, 25 Oct 2018 22:41:14 +0000 (+1000) Subject: Clean up inventory creation code a bit so that it's somewhat spectatable X-Git-Tag: xonotic-v0.8.5~1747 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e14822e0027ed17bf638cd15dfa3c9221c174913;p=xonotic%2Fxonotic-data.pk3dir.git Clean up inventory creation code a bit so that it's somewhat spectatable --- diff --git a/qcsrc/common/items/inventory.qh b/qcsrc/common/items/inventory.qh index ba824f40b..2ec0cdb7b 100644 --- a/qcsrc/common/items/inventory.qh +++ b/qcsrc/common/items/inventory.qh @@ -106,20 +106,23 @@ 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 = PS(e.enemy); // TODO: how can this *ever* be the case? - TC(Player, e); - Inventory data = e.inventory; - Inventory_Write(data); + TC(PlayerState, this.owner); + Inventory_Write(this); return true; } -void Inventory_new(entity e) +bool Inventory_customize(entity this, entity client) +{ + // sends to spectators too! + return (PS(client) && PS(client).inventory == this); +} + +void Inventory_new(PlayerState this) { Inventory inv = NEW(Inventory), bak = NEW(Inventory); inv.inventory = bak; - inv.drawonlytoclient = IS_CLIENT(e) ? e : e.m_client; - Net_LinkEntity((inv.owner = e).inventory = inv, false, 0, Inventory_Send); + setcefc(inv, Inventory_customize); + Net_LinkEntity((inv.owner = this).inventory = inv, false, 0, Inventory_Send); } void Inventory_delete(entity e) { delete(e.inventory.inventory); delete(e.inventory); } void Inventory_update(entity e) { e.inventory.SendFlags = 0xFFFFFF; } diff --git a/qcsrc/common/state.qc b/qcsrc/common/state.qc index 2e3a262a5..fc3530744 100644 --- a/qcsrc/common/state.qc +++ b/qcsrc/common/state.qc @@ -1,6 +1,6 @@ #include "state.qh" -void Inventory_new(entity this); +void Inventory_new(PlayerState this); void Inventory_delete(entity this); void PlayerState_attach(entity this)