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);
{
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); }
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;
}
{
this._ps = NEW(PlayerState, this);
- Inventory_new(this);
+ Inventory_new(PS(this));
}
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);
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