mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
* Add MarketBoard service and associated interfaces, test and data widget * Dispose of events properly * Make listings readonly lists + provide internal list for internal use * Rename CatalogId to ItemId on interfaces, have kept CatalogId internally as it's technically correct * Removed RetainerOwnerId from the public interface * Removed NextCatalogId from the public interface * Updated test text * Null events in scoped service disposal
93 lines
2.7 KiB
C#
93 lines
2.7 KiB
C#
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>
|
|
public class MarketBoardPurchaseHandler : IMarketBoardPurchaseHandler
|
|
{
|
|
private 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)
|
|
{
|
|
using var stream = new UnmanagedMemoryStream((byte*)dataPtr.ToPointer(), 1544);
|
|
using var reader = new BinaryReader(stream);
|
|
|
|
var output = new MarketBoardPurchaseHandler
|
|
{
|
|
RetainerId = reader.ReadUInt64(),
|
|
ListingId = reader.ReadUInt64(),
|
|
CatalogId = reader.ReadUInt32(),
|
|
ItemQuantity = reader.ReadUInt32(),
|
|
PricePerUnit = reader.ReadUInt32(),
|
|
};
|
|
|
|
return output;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// An interface that represents market board purchase information. This message is sent from the
|
|
/// client when a purchase is made at a market board.
|
|
/// </summary>
|
|
public interface IMarketBoardPurchaseHandler
|
|
{
|
|
/// <summary>
|
|
/// Gets the object ID of the retainer associated with the sale.
|
|
/// </summary>
|
|
ulong RetainerId { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the object ID of the item listing.
|
|
/// </summary>
|
|
ulong ListingId { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the item ID of the item that was purchased.
|
|
/// </summary>
|
|
uint CatalogId { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the quantity of the item that was purchased.
|
|
/// </summary>
|
|
uint ItemQuantity { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the unit price of the item.
|
|
/// </summary>
|
|
uint PricePerUnit { get; }
|
|
}
|