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

@@ -82,7 +82,8 @@ Item::Item(
bool isModMoveAndEquip,
LWOOBJID subKey,
bool bound,
eLootSourceType lootSourceType) {
eLootSourceType lootSourceType,
const LootMetrics& metrics) {
if (!Inventory::IsValidItem(lot)) {
return;
}
@@ -113,6 +114,7 @@ Item::Item(
GameMessages::AddItemToInventoryClientSync addItem;
addItem.target = entity->GetObjectID();
addItem.SetItem(*this);
addItem.AddMetrics(metrics);
addItem.eLootTypeSource = lootSourceType;
addItem.iSubkey = subKey;
addItem.itemCount = static_cast<int>(this->count);
@@ -178,7 +180,7 @@ PreconditionExpression* Item::GetPreconditionExpression() const {
return preconditions;
}
void Item::SetCount(const uint32_t value, const bool silent, const bool disassemble, const bool showFlyingLoot, eLootSourceType lootSourceType) {
void Item::SetCount(const uint32_t value, const bool silent, const bool disassemble, const bool showFlyingLoot, eLootSourceType lootSourceType, const LootMetrics& metrics, const ItemRemovalSource& removalSource) {
if (value == count) {
return;
}
@@ -202,6 +204,7 @@ void Item::SetCount(const uint32_t value, const bool silent, const bool disassem
GameMessages::AddItemToInventoryClientSync addItem;
addItem.target = entity->GetObjectID();
addItem.SetItem(*this);
addItem.AddMetrics(metrics);
addItem.eLootTypeSource = lootSourceType;
addItem.itemCount = delta;
addItem.newObjID = id;
@@ -213,7 +216,8 @@ void Item::SetCount(const uint32_t value, const bool silent, const bool disassem
removeItem.target = entity->GetObjectID();
removeItem.bConfirmed = true;
removeItem.eInvType = inventory->GetType();
removeItem.eLootTypeSource = LOOTTYPE_NONE;
removeItem.eLootTypeSource = static_cast<int32_t>(removalSource.type);
removeItem.iLootTypeSource = removalSource.object;
removeItem.iObjID = id;
removeItem.iObjTemplate = lot;
removeItem.iStackCount = delta;