From: terencehill Date: Sun, 7 May 2023 13:28:22 +0000 (+0200) Subject: LMS and Instagib: fix extralife not counted in the Itemstats panel and wrongly displa... X-Git-Tag: xonotic-v0.8.6~114^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=38c4018ae88cc2ee4ace2ee2832ba2421c2079be;p=xonotic%2Fxonotic-data.pk3dir.git LMS and Instagib: fix extralife not counted in the Itemstats panel and wrongly displayed in the Pickup panel --- diff --git a/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc b/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc index 82899e421..d53b21349 100644 --- a/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc +++ b/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc @@ -686,6 +686,7 @@ MUTATOR_HOOKFUNCTION(lms, ItemTouch) { Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_EXTRALIVES, autocvar_g_lms_extra_lives); GameRules_scoring_add(toucher, LMS_LIVES, autocvar_g_lms_extra_lives); + Inventory_pickupitem(item.itemdef, toucher); return MUT_ITEMTOUCH_PICKUP; } diff --git a/qcsrc/common/items/inventory.qh b/qcsrc/common/items/inventory.qh index 6f6ebdc45..118b7079d 100644 --- a/qcsrc/common/items/inventory.qh +++ b/qcsrc/common/items/inventory.qh @@ -154,9 +154,18 @@ void Inventory_new(PlayerState this) 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 Inventory_pickupitem(Pickup this, entity 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); +} + void Inventory_clear(entity store) { // NOTE: you will need to perform Inventory_update after this to update the storage entity diff --git a/qcsrc/common/items/item/pickup.qc b/qcsrc/common/items/item/pickup.qc index a3c2d779e..52cf8c3e8 100644 --- a/qcsrc/common/items/item/pickup.qc +++ b/qcsrc/common/items/item/pickup.qc @@ -10,12 +10,8 @@ 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); - entity store = IS_PLAYER(player) ? PS(player) : player; - store.inventory.inv_items[this.m_id]++; - Inventory_update(store); - } + if (b) + Inventory_pickupitem(this, player); return b; } diff --git a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc index 3a7d563d8..a6ac55d93 100644 --- a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc +++ b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc @@ -416,6 +416,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, ItemTouch) { GiveResource(toucher, RES_ARMOR, autocvar_g_instagib_extralives); Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_EXTRALIVES, autocvar_g_instagib_extralives); + Inventory_pickupitem(item.itemdef, toucher); return MUT_ITEMTOUCH_PICKUP; }