mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-26 14:42:49 +00:00
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:
@@ -9,6 +9,7 @@
|
||||
#include "Inventory.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "Item.h"
|
||||
#include "LootMetrics.h"
|
||||
#include "BrickByBrick.h"
|
||||
|
||||
#include <ranges>
|
||||
@@ -53,6 +54,13 @@ namespace GameMessages {
|
||||
slotID = item.GetSlot();
|
||||
}
|
||||
|
||||
void AddItemToInventoryClientSync::AddMetrics(const LootMetrics& metrics) {
|
||||
const auto text = metrics.ToExtraInfo();
|
||||
if (text.empty()) return;
|
||||
if (!extraInfo.empty()) extraInfo += u',';
|
||||
extraInfo += text;
|
||||
}
|
||||
|
||||
void AddItemToInventoryClientSync::Serialize(RakNet::BitStream& bitStream) const {
|
||||
bitStream.Write(bBound);
|
||||
bitStream.Write(bIsBOE);
|
||||
|
||||
@@ -17,6 +17,8 @@ class Item;
|
||||
// and groups.
|
||||
// Field names follow the client (legouniverse.exe 1.10.64); fields are listed in wire order.
|
||||
// Received messages are handled by the target's InventoryComponent.
|
||||
struct LootMetrics;
|
||||
|
||||
namespace GameMessages {
|
||||
// Server -> client.
|
||||
struct AddItemToInventoryClientSync : public NetGameMsg {
|
||||
@@ -28,6 +30,9 @@ namespace GameMessages {
|
||||
// slot). The caller sets the rest.
|
||||
void SetItem(const Item& item);
|
||||
|
||||
// Adds where the items came from (LootMetrics) to the extra info, after the item's config
|
||||
void AddMetrics(const LootMetrics& metrics);
|
||||
|
||||
bool bBound{};
|
||||
bool bIsBOE{};
|
||||
bool bIsBOP{};
|
||||
|
||||
Reference in New Issue
Block a user