Skip to content

Commit

Permalink
Add CurrencyManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Haselnussbomber committed Dec 21, 2023
1 parent edc7543 commit 95f5ad4
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 0 deletions.
139 changes: 139 additions & 0 deletions FFXIVClientStructs/FFXIV/Client/Game/CurrencyManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
namespace FFXIVClientStructs.FFXIV.Client.Game;

[StructLayout(LayoutKind.Explicit, Size = 0x30)]
public unsafe partial struct CurrencyManager {
[StaticAddress("48 8B 1D ?? ?? ?? ?? 48 85 DB 74 15 48 8B CB E8 ?? ?? ?? ?? BA ?? ?? ?? ?? 48 8B CB E8 ?? ?? ?? ?? 33 D2", 3, isPointer: true)]
public static partial CurrencyManager* Instance();

/// <remarks>
/// This bucket is known to contain the following items:<br/>
/// <code>
/// |-----------|--------|-------------------------|<br/>
/// | SpecialId | ItemId | Item Name |<br/>
/// |-----------|--------|-------------------------|<br/>
/// | 1 | 17833 | Yellow Crafters' Scrip |<br/>
/// | 2 | 25199 | White Crafters' Scrip |<br/>
/// | 3 | 17834 | Yellow Gatherers' Scrip |<br/>
/// | 4 | 25200 | White Gatherers' Scrip |<br/>
/// | 5 | 10307 | Centurio Seal |<br/>
/// | 6 | 33913 | Purple Crafters' Scrip |<br/>
/// | 7 | 33914 | Purple Gatherers' Scrip |<br/>
/// |-----------|--------|-------------------------|
/// </code>
/// </remarks>
[FieldOffset(0x0)] public StdMap<uint, SpecialCurrencyItem> SpecialItemBucket;

/// <remarks>
/// This bucket is known to contain the following items:<br/>
/// <code>
/// |--------|-------------------------|<br/>
/// | ItemId | Item Name |<br/>
/// |--------|-------------------------|<br/>
/// | 30341 | Faux Leaf |<br/>
/// | 38534 | Sil'dihn Silver |<br/>
/// | 39885 | Shishu Coin |<br/>
/// | 21072 | Venture |<br/>
/// | 21073 | Ixali Oaknot |<br/>
/// | 21074 | Vanu Whitebone |<br/>
/// | 21075 | Sylphic Goldleaf |<br/>
/// | 21076 | Steel Amalj'ok |<br/>
/// | 21077 | Rainbowtide Psashp |<br/>
/// | 21078 | Titan Cobaltpiece |<br/>
/// | 21079 | Black Copper Gil |<br/>
/// | 21080 | Carved Kupo Nut |<br/>
/// | 21081 | Kojin Sango |<br/>
/// | 28186 | Fae Fancy |<br/>
/// | 28187 | Qitari Compliment |<br/>
/// | 28188 | Hammered Frogment |<br/>
/// | 41629 | MGF |<br/>
/// | 37854 | Omicron Omnitoken |<br/>
/// | 28063 | Skybuilders' Scrip |<br/>
/// | 26533 | Sack of Nuts |<br/>
/// | 38952 | Loporrit Carat |<br/>
/// | 21935 | Ananta Dreamstaff |<br/>
/// | 36656 | Trophy Crystal |<br/>
/// | 36657 | Arkasodara Pana |<br/>
/// | 21172 | Achievement Certificate |<br/>
/// | 21173 | |<br/>
/// | 26807 | Bicolor Gemstone |<br/>
/// | 41079 | Aloalo Coin |<br/>
/// | 22525 | Namazu Koban |<br/>
/// |--------|-------------------------|
/// </code>
/// </remarks>
[FieldOffset(0x10)] public StdMap<uint, CurrencyItem> ItemBucket;

/// <remarks>
/// This bucket is known to contain the following items:<br/>
/// <code>
/// |--------|-------------------------|<br/>
/// | ItemId | Item Name |<br/>
/// |--------|-------------------------|<br/>
/// | 33138 | |<br/>
/// |--------|-------------------------|
/// </code>
/// </remarks>
[FieldOffset(0x20)] public StdMap<uint, UnknownItem> UnknownItemBucket;

/// <remarks>
/// Used for items in <see cref="SpecialItemBucket"/> only.
/// </remarks>
[MemberFunction("E8 ?? ?? ?? ?? 8B D8 EB 11")]
public partial uint GetItemIdBySpecialId(byte specialId);

[MemberFunction("E8 ?? ?? ?? ?? 3B C3 76 0A")]
public partial uint GetItemCount(uint itemId);

[MemberFunction("E8 ?? ?? ?? ?? 0F B7 CF 03 CB")]
public partial uint GetItemMaxCount(uint itemId);

[MemberFunction("E8 ?? ?? ?? ?? 39 06")]
public partial uint GetItemCountRemaining(uint itemId); // returns maxCount - count

/// <remarks>Checks if the item is in any bucket, regardless of its Count.</remarks>
/// <returns>Returns <c>true</c> when the player has owned this item before, <c>false</c> otherwise.</returns>
[MemberFunction("E8 ?? ?? ?? ?? 84 C0 41 8B CD")]
public partial bool IsItemKnown(uint itemId);

[MemberFunction("E8 ?? ?? ?? ?? 84 C0 75 32 8B D7")]
public partial bool IsItemLimited(uint itemId);

/// <summary>
/// Fills data for a currency item.
/// </summary>
/// <remarks>Only used in ProcessActorControlPacket.</remarks>
/// <param name="specialId">
/// If -1, <see cref="UnknownItemBucket"/> is used.<br/>
/// If 0, <see cref="ItemBucket"/> is used.<br/>
/// Otherwise, <see cref="SpecialItemBucket"/> is used and this value is assigned to <see cref="SpecialCurrencyItem.SpecialId"/>.
/// </param>
/// <param name="itemId">The ID of the Item.</param>
/// <param name="maxCount">The maximum amount of this currency a player can have.</param>
/// <param name="count">The amount of this currency currently held by the player.</param>
/// <param name="isUnlimited">Wether the currency has a limit or not.</param>
[MemberFunction("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 40 41 8B D8")]
public partial void SetItemData(sbyte specialId, uint itemId, uint maxCount, uint count, bool isUnlimited);

[StructLayout(LayoutKind.Explicit, Size = 0x20)]
public struct SpecialCurrencyItem {
[FieldOffset(0x0)] public byte SpecialId;
[FieldOffset(0x4)] public uint MaxCount;
[FieldOffset(0x8)] public uint Count;
}

[StructLayout(LayoutKind.Explicit, Size = 0x20)]
public struct CurrencyItem {
[FieldOffset(0x0)] public ushort MaxCount;
[FieldOffset(0x2)] public ushort Count;
[FieldOffset(0x4)] public bool IsUnlimited;
// [FieldOffset(0x5)] public byte Unk5;
}

// unknown struct
[StructLayout(LayoutKind.Explicit, Size = 0x20)]
public struct UnknownItem {
[FieldOffset(0x0)] public uint MaxCount;
[FieldOffset(0x4)] public ushort Count;
[FieldOffset(0x8)] public bool IsUnlimited;
}
}
18 changes: 18 additions & 0 deletions ida/data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,24 @@ classes:
0x1407460A0: RestorePrismBoxItem
0x1407464F0: RequestGlamourPlates
0x140746750: ApplyGlamourPlate
Client::Game::CurrencyManager:
instances:
- ea: 0x142221D10
pointer: True
funcs:
0x140B8D700: Create
0x140B8D770: Destroy
0x140B8D7B0: Initialize
0x140B8D8A0: Finalize
0x140B8D6D0: HasInstance
0x140B8D6F0: GetInstance
0x140B8D940: IsItemKnown
0x140B8DA10: GetItemCount
0x140B8DAE0: GetItemMaxCount
0x140B8DBB0: GetItemCountRemaining
0x140B8DCB0: IsItemLimited
0x140B8DD80: GetItemIdBySpecialId
0x140B8DE00: SetItemData
Client::Game::InventoryManager:
instances:
- ea: 0x1421EDC40
Expand Down

0 comments on commit 95f5ad4

Please sign in to comment.