Skip to content

Commit a755319

Browse files
committed
Add value to inventory service response (Closes #1545) (#1546)
1 parent 7e72cb3 commit a755319

18 files changed

Lines changed: 2465 additions & 2183 deletions

File tree

Daybreak.API/Interop/GWCA.cs

Lines changed: 224 additions & 87 deletions
Large diffs are not rendered by default.

Daybreak.API/Services/InventoryService.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public sealed class InventoryService(
4141
return default;
4242
}
4343

44-
var itemTuples = new List<(GWCA.GW.Constants.BagType Type, List<(uint ModelId, string EncodedCompleteName, string EncodedSingleName, string EncodedName, bool Inscribable, int Quantity, uint[] Modifiers, ItemType ItemType, uint Interaction, uint ModelFileId, Byte DyeTint)>)>();
44+
var itemTuples = new List<(GWCA.GW.Constants.BagType Type, List<(uint ModelId, string EncodedCompleteName, string EncodedSingleName, string EncodedName, bool Inscribable, int Quantity, uint[] Modifiers, ItemType ItemType, uint Interaction, uint ModelFileId, Byte DyeTint, ushort Value)>)>();
4545
for (var i = 0; i < 23; i++)
4646
{
4747
// Use GWCA helper to fetch bag pointers by index — safer than reading an inline array directly.
@@ -51,7 +51,7 @@ public sealed class InventoryService(
5151
continue;
5252
}
5353

54-
var retBag = new List<(uint ModelId, string EncodedCompleteName, string EncodedSingleName, string EncodedName, bool Inscribable, int Quantity, uint[] Modifiers, ItemType ItemType, uint Interaction, uint ModelFileId, Byte DyeTint)>();
54+
var retBag = new List<(uint ModelId, string EncodedCompleteName, string EncodedSingleName, string EncodedName, bool Inscribable, int Quantity, uint[] Modifiers, ItemType ItemType, uint Interaction, uint ModelFileId, Byte DyeTint, ushort Value)>();
5555
itemTuples.Add((bag->BagType, retBag));
5656
if (bag->ItemsCount is 0)
5757
{
@@ -75,7 +75,7 @@ public sealed class InventoryService(
7575
modifiers[j] = item->ModStruct[j].Mod;
7676
}
7777

78-
retBag.Add((item->ModelId, completeNameEncoded, singleItemName, nameEncoded, (item->Interaction & 0x08000000) != 0, item->Quantity, modifiers, (ItemType)item->Type, item->Interaction, item->ModelFileId, item->Dye.DyeTint));
78+
retBag.Add((item->ModelId, completeNameEncoded, singleItemName, nameEncoded, (item->Interaction & 0x08000000) != 0, item->Quantity, modifiers, (ItemType)item->Type, item->Interaction, item->ModelFileId, item->Dye.DyeTint, item->Value));
7979
}
8080
}
8181

@@ -90,16 +90,16 @@ public sealed class InventoryService(
9090

9191
// Decode strings sequentially to avoid race conditions with the game's TextParser language field.
9292
// Parallel decoding causes crashes because multiple operations race to set/restore the language.
93-
var decodedItemTuples = new List<(GWCA.GW.Constants.BagType Type, List<(uint ModelId, string EncodedName, string? DecodedName, string EncodedSingleName, string? DecodedSingleName, string EncodedCompleteName, string? DecodedCompleteName, bool Inscribable, int Quantity, uint[] Modifiers, ItemType ItemType, uint Interaction, uint ModelFileId, byte DyeTint)> Items)>();
93+
var decodedItemTuples = new List<(GWCA.GW.Constants.BagType Type, List<(uint ModelId, string EncodedName, string? DecodedName, string EncodedSingleName, string? DecodedSingleName, string EncodedCompleteName, string? DecodedCompleteName, bool Inscribable, int Quantity, uint[] Modifiers, ItemType ItemType, uint Interaction, uint ModelFileId, byte DyeTint, ushort Value)> Items)>();
9494
foreach (var tuple in itemTuples)
9595
{
96-
var decodedItems = new List<(uint ModelId, string EncodedName, string? DecodedName, string EncodedSingleName, string? DecodedSingleName, string EncodedCompleteName, string? DecodedCompleteName, bool Inscribable, int Quantity, uint[] Modifiers, ItemType ItemType, uint Interaction, uint ModelFileId, byte DyeTint)>();
96+
var decodedItems = new List<(uint ModelId, string EncodedName, string? DecodedName, string EncodedSingleName, string? DecodedSingleName, string EncodedCompleteName, string? DecodedCompleteName, bool Inscribable, int Quantity, uint[] Modifiers, ItemType ItemType, uint Interaction, uint ModelFileId, byte DyeTint, ushort Value)>();
9797
foreach (var item in tuple.Item2)
9898
{
9999
var decodedName = await this.uIService.DecodeString(item.EncodedName, (GWCA.GW.Constants.Language)Language.English, cancellationToken);
100100
var decodedCompleteName = await this.uIService.DecodeString(item.EncodedCompleteName, (GWCA.GW.Constants.Language)Language.English, cancellationToken);
101101
var decodedSingleName = await this.uIService.DecodeString(item.EncodedSingleName, (GWCA.GW.Constants.Language)Language.English, cancellationToken);
102-
decodedItems.Add((item.ModelId, item.EncodedName, decodedName, item.EncodedSingleName, decodedSingleName, item.EncodedCompleteName, decodedCompleteName, item.Inscribable, item.Quantity, item.Modifiers, item.ItemType, item.Interaction, item.ModelFileId, item.DyeTint));
102+
decodedItems.Add((item.ModelId, item.EncodedName, decodedName, item.EncodedSingleName, decodedSingleName, item.EncodedCompleteName, decodedCompleteName, item.Inscribable, item.Quantity, item.Modifiers, item.ItemType, item.Interaction, item.ModelFileId, item.DyeTint, item.Value));
103103
}
104104

105105
decodedItemTuples.Add((tuple.Type, decodedItems));
@@ -125,7 +125,8 @@ public sealed class InventoryService(
125125
ItemType: item.ItemType.ToString(),
126126
Interaction: item.Interaction,
127127
ModelFileId: item.ModelFileId,
128-
DyeTint: item.DyeTint))]))]);
128+
DyeTint: item.DyeTint,
129+
Value: item.Value))]))]);
129130
}
130131

131132
private static string ToBase64(string encoded)

Daybreak.Shared/Models/Api/ItemEntry.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public sealed record ItemEntry(
2020
ItemProperty[] Properties,
2121
uint Interaction,
2222
uint ModelFileId,
23-
byte DyeTint)
23+
byte DyeTint,
24+
ushort Value)
2425
{
2526
}

0 commit comments

Comments
 (0)