From d180ed005caaf333acf99906daacd55b442abb1e Mon Sep 17 00:00:00 2001 From: Raymond Date: Wed, 10 Nov 2021 20:25:20 -0500 Subject: [PATCH] More marketboard work, fix 10 instead of 20 history items --- .../MarketBoardItemRequest.cs | 45 ++++++++++++++----- .../Network/Structures/MarketBoardHistory.cs | 26 +++++------ .../Network/Structures/MarketBoardPurchase.cs | 9 +++- .../Structures/MarketBoardPurchaseHandler.cs | 9 +++- .../Game/Network/Structures/MarketTaxRates.cs | 22 ++++----- 5 files changed, 71 insertions(+), 40 deletions(-) diff --git a/Dalamud/Game/Network/Internal/MarketBoardUploaders/MarketBoardItemRequest.cs b/Dalamud/Game/Network/Internal/MarketBoardUploaders/MarketBoardItemRequest.cs index 63d51f0e1..bdd07a8af 100644 --- a/Dalamud/Game/Network/Internal/MarketBoardUploaders/MarketBoardItemRequest.cs +++ b/Dalamud/Game/Network/Internal/MarketBoardUploaders/MarketBoardItemRequest.cs @@ -1,4 +1,6 @@ +using System; using System.Collections.Generic; +using System.IO; using Dalamud.Game.Network.Structures; @@ -9,25 +11,29 @@ namespace Dalamud.Game.Network.Internal.MarketBoardUploaders /// internal class MarketBoardItemRequest { - /// - /// Gets or sets the catalog ID. - /// - public uint CatalogId { get; set; } + private MarketBoardItemRequest() + { + } /// - /// Gets or sets the amount to arrive. + /// Gets the catalog ID. /// - public byte AmountToArrive { get; set; } + public uint CatalogId { get; private set; } /// - /// Gets or sets the offered item listings. + /// Gets the amount to arrive. /// - public List Listings { get; set; } + public byte AmountToArrive { get; private set; } /// - /// Gets or sets the historical item listings. + /// Gets the offered item listings. /// - public List History { get; set; } + public List Listings { get; } = new(); + + /// + /// Gets the historical item listings. + /// + public List History { get; } = new(); /// /// Gets or sets the listing request ID. @@ -38,5 +44,24 @@ namespace Dalamud.Game.Network.Internal.MarketBoardUploaders /// Gets a value indicating whether the upload is complete. /// public bool IsDone => this.Listings.Count == this.AmountToArrive && this.History.Count != 0; + + /// + /// Read a packet off the wire. + /// + /// Packet data. + /// An object representing the data read. + public static unsafe MarketBoardItemRequest Read(IntPtr dataPtr) + { + using var stream = new UnmanagedMemoryStream((byte*)dataPtr.ToPointer(), 1544); + using var reader = new BinaryReader(stream); + + var output = new MarketBoardItemRequest(); + + output.CatalogId = reader.ReadUInt32(); + stream.Position += 0x7; + output.AmountToArrive = reader.ReadByte(); + + return output; + } } } diff --git a/Dalamud/Game/Network/Structures/MarketBoardHistory.cs b/Dalamud/Game/Network/Structures/MarketBoardHistory.cs index c73529da3..d753b0498 100644 --- a/Dalamud/Game/Network/Structures/MarketBoardHistory.cs +++ b/Dalamud/Game/Network/Structures/MarketBoardHistory.cs @@ -20,17 +20,17 @@ namespace Dalamud.Game.Network.Structures /// /// Gets the catalog ID. /// - public uint CatalogId { get; internal set; } + public uint CatalogId { get; private set; } /// /// Gets the second catalog ID. /// - public uint CatalogId2 { get; internal set; } + public uint CatalogId2 { get; private set; } /// /// Gets the list of individual item history listings. /// - public List HistoryListings { get; internal set; } + public List HistoryListings { get; } = new(); /// /// Read a object from memory. @@ -39,17 +39,15 @@ namespace Dalamud.Game.Network.Structures /// A new object. public static unsafe MarketBoardHistory Read(IntPtr dataPtr) { - var output = new MarketBoardHistory(); - using var stream = new UnmanagedMemoryStream((byte*)dataPtr.ToPointer(), 1544); using var reader = new BinaryReader(stream); + var output = new MarketBoardHistory(); + output.CatalogId = reader.ReadUInt32(); output.CatalogId2 = reader.ReadUInt32(); - output.HistoryListings = new List(); - - for (var i = 0; i < 10; i++) + for (var i = 0; i < 20; i++) { var listingEntry = new MarketBoardHistoryListing { @@ -63,10 +61,12 @@ namespace Dalamud.Game.Network.Structures listingEntry.OnMannequin = reader.ReadBoolean(); listingEntry.BuyerName = Encoding.UTF8.GetString(reader.ReadBytes(33)).TrimEnd('\u0000'); - listingEntry.CatalogId = reader.ReadUInt32(); + listingEntry.NextCatalogId = reader.ReadUInt32(); - if (listingEntry.CatalogId != 0) - output.HistoryListings.Add(listingEntry); + output.HistoryListings.Add(listingEntry); + + if (listingEntry.NextCatalogId == 0) + break; } return output; @@ -90,9 +90,9 @@ namespace Dalamud.Game.Network.Structures public string BuyerName { get; internal set; } /// - /// Gets the catalog ID. + /// Gets the next entry's catalog ID. /// - public uint CatalogId { get; internal set; } + public uint NextCatalogId { get; internal set; } /// /// Gets a value indicating whether the item is HQ. diff --git a/Dalamud/Game/Network/Structures/MarketBoardPurchase.cs b/Dalamud/Game/Network/Structures/MarketBoardPurchase.cs index ed8051154..5fc0de786 100644 --- a/Dalamud/Game/Network/Structures/MarketBoardPurchase.cs +++ b/Dalamud/Game/Network/Structures/MarketBoardPurchase.cs @@ -9,6 +9,10 @@ namespace Dalamud.Game.Network.Structures /// internal class MarketBoardPurchase { + private MarketBoardPurchase() + { + } + /// /// Gets the item ID of the item that was purchased. /// @@ -26,10 +30,11 @@ namespace Dalamud.Game.Network.Structures /// An object representing the data read. public static unsafe MarketBoardPurchase Read(IntPtr dataPtr) { - var output = new MarketBoardPurchase(); - using var stream = new UnmanagedMemoryStream((byte*)dataPtr.ToPointer(), 1544); using var reader = new BinaryReader(stream); + + var output = new MarketBoardPurchase(); + output.CatalogId = reader.ReadUInt32(); stream.Position += 4; output.ItemQuantity = reader.ReadUInt32(); diff --git a/Dalamud/Game/Network/Structures/MarketBoardPurchaseHandler.cs b/Dalamud/Game/Network/Structures/MarketBoardPurchaseHandler.cs index 98d7007b0..0557b0e0d 100644 --- a/Dalamud/Game/Network/Structures/MarketBoardPurchaseHandler.cs +++ b/Dalamud/Game/Network/Structures/MarketBoardPurchaseHandler.cs @@ -9,6 +9,10 @@ namespace Dalamud.Game.Network.Structures /// internal class MarketBoardPurchaseHandler { + private MarketBoardPurchaseHandler() + { + } + /// /// Gets the object ID of the retainer associated with the sale. /// @@ -41,10 +45,11 @@ namespace Dalamud.Game.Network.Structures /// An object representing the data read. public static unsafe MarketBoardPurchaseHandler Read(IntPtr dataPtr) { - var output = new MarketBoardPurchaseHandler(); - using var stream = new UnmanagedMemoryStream((byte*)dataPtr.ToPointer(), 1544); using var reader = new BinaryReader(stream); + + var output = new MarketBoardPurchaseHandler(); + output.RetainerId = reader.ReadUInt64(); output.ListingId = reader.ReadUInt64(); output.CatalogId = reader.ReadUInt32(); diff --git a/Dalamud/Game/Network/Structures/MarketTaxRates.cs b/Dalamud/Game/Network/Structures/MarketTaxRates.cs index 5b27b9415..4fb6a2b13 100644 --- a/Dalamud/Game/Network/Structures/MarketTaxRates.cs +++ b/Dalamud/Game/Network/Structures/MarketTaxRates.cs @@ -8,42 +8,39 @@ namespace Dalamud.Game.Network.Structures /// public class MarketTaxRates { - /// - /// Initializes a new instance of the class. - /// - internal MarketTaxRates() + private MarketTaxRates() { } /// /// Gets the tax rate in Limsa Lominsa. /// - public uint LimsaLominsaTax { get; internal set; } + public uint LimsaLominsaTax { get; private set; } /// /// Gets the tax rate in Gridania. /// - public uint GridaniaTax { get; internal set; } + public uint GridaniaTax { get; private set; } /// /// Gets the tax rate in Ul'dah. /// - public uint UldahTax { get; internal set; } + public uint UldahTax { get; private set; } /// /// Gets the tax rate in Ishgard. /// - public uint IshgardTax { get; internal set; } + public uint IshgardTax { get; private set; } /// /// Gets the tax rate in Kugane. /// - public uint KuganeTax { get; internal set; } + public uint KuganeTax { get; private set; } /// /// Gets the tax rate in the Crystarium. /// - public uint CrystariumTax { get; internal set; } + public uint CrystariumTax { get; private set; } /// /// Read a object from memory. @@ -52,13 +49,12 @@ namespace Dalamud.Game.Network.Structures /// A new object. public static unsafe MarketTaxRates Read(IntPtr dataPtr) { - var output = new MarketTaxRates(); - using var stream = new UnmanagedMemoryStream((byte*)dataPtr.ToPointer(), 1544); using var reader = new BinaryReader(stream); - stream.Position += 8; + var output = new MarketTaxRates(); + stream.Position += 8; output.LimsaLominsaTax = reader.ReadUInt32(); output.GridaniaTax = reader.ReadUInt32(); output.UldahTax = reader.ReadUInt32();