mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-23 16:27:44 +01:00
Implement market board purchase message reading
Originally from d85146c0d9
This commit is contained in:
parent
41931dcb2d
commit
8b8d1ca74c
3 changed files with 132 additions and 5 deletions
40
Dalamud/Game/Network/Structures/MarketBoardPurchase.cs
Normal file
40
Dalamud/Game/Network/Structures/MarketBoardPurchase.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Dalamud.Game.Network.Structures
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents market board purchase information. This message is received from the
|
||||
/// server when a purchase is made at a market board.
|
||||
/// </summary>
|
||||
internal class MarketBoardPurchase
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the item ID of the item that was purchased.
|
||||
/// </summary>
|
||||
public uint CatalogId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the quantity of the item that was purchased.
|
||||
/// </summary>
|
||||
public uint ItemQuantity { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Reads market board purchase information from the struct at the provided pointer.
|
||||
/// </summary>
|
||||
/// <param name="dataPtr">A pointer to a struct containing market board purchase information from the server.</param>
|
||||
/// <returns>An object representing the data read.</returns>
|
||||
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);
|
||||
output.CatalogId = reader.ReadUInt32();
|
||||
stream.Position += 4;
|
||||
output.ItemQuantity = reader.ReadUInt32();
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Dalamud.Game.Network.Structures
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents market board purchase information. This message is sent from the
|
||||
/// client when a purchase is made at a market board.
|
||||
/// </summary>
|
||||
internal class MarketBoardPurchaseHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the object ID of the retainer associated with the sale.
|
||||
/// </summary>
|
||||
public ulong RetainerId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the object ID of the item listing.
|
||||
/// </summary>
|
||||
public ulong ListingId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the item ID of the item that was purchased.
|
||||
/// </summary>
|
||||
public uint CatalogId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the quantity of the item that was purchased.
|
||||
/// </summary>
|
||||
public uint ItemQuantity { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unit price of the item.
|
||||
/// </summary>
|
||||
public uint PricePerUnit { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Reads market board purchase information from the struct at the provided pointer.
|
||||
/// </summary>
|
||||
/// <param name="dataPtr">A pointer to a struct containing market board purchase information from the client.</param>
|
||||
/// <returns>An object representing the data read.</returns>
|
||||
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);
|
||||
output.RetainerId = reader.ReadUInt64();
|
||||
output.ListingId = reader.ReadUInt64();
|
||||
output.CatalogId = reader.ReadUInt32();
|
||||
output.ItemQuantity = reader.ReadUInt32();
|
||||
output.PricePerUnit = reader.ReadUInt32();
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue