feat(inventory): items can carry where they came from to the client

Live servers put _Metric_ keys in AddItemToInventoryClientSync's extra info,
after the item's own config, saying where the items came from: the source
object's LOT (_Metric_Souce_LOT_Int, misspelt as live had it), the mission,
activity, coins paid, mail or trade. LootMetrics holds them and writes them
with the key names and name value types live used (the mail ID as type 8,
the trade ID as type 9). AddItem, ReceiveItem (its options), the new item
constructor and Item::SetCount pass them through to the message; the item
does not keep them.

RemoveItem and Item::SetCount can also say what took items away
(ItemRemovalSource), filling RemoveItemFromInventory's loot source and
source object instead of none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-30 07:45:50 -05:00
parent 3018312f29
commit a1ee18fce7
9 changed files with 112 additions and 16 deletions

View File

@@ -8,6 +8,7 @@
#include "Preconditions.h"
#include "eInventoryType.h"
#include "eLootSourceType.h"
#include "LootMetrics.h"
namespace tinyxml2 {
class XMLElement;
@@ -58,6 +59,7 @@ public:
* @param isModMoveAndEquip equips the item
* @param subKey optional subkey for this item, e.g. for pets
* @param bound if the item should be bound
* @param metrics where the items came from, sent with the item (not kept)
*/
explicit Item(
LOT lot,
@@ -70,7 +72,8 @@ public:
bool isModMoveAndEquip = false,
LWOOBJID subKey = LWOOBJID_EMPTY,
bool bound = false,
eLootSourceType lootSourceType = eLootSourceType::NONE
eLootSourceType lootSourceType = eLootSourceType::NONE,
const LootMetrics& metrics = {}
);
~Item();
@@ -93,8 +96,10 @@ public:
* @param silent if true, the client will not be notified of the change with GMs
* @param disassemble if items were removed, this returns all the sub parts of the item individually if it had assembly part lots
* @param showFlyingLoot shows flying loot to the client, if not silent
* @param metrics where added items came from, sent with them (not kept)
* @param removalSource what took removed items away, sent with the removal
*/
void SetCount(uint32_t value, bool silent = false, bool disassemble = true, bool showFlyingLoot = true, eLootSourceType lootSourceType = eLootSourceType::NONE);
void SetCount(uint32_t value, bool silent = false, bool disassemble = true, bool showFlyingLoot = true, eLootSourceType lootSourceType = eLootSourceType::NONE, const LootMetrics& metrics = {}, const ItemRemovalSource& removalSource = {});
/**
* Returns the number of items this item represents (e.g. for stacks)