From cbbcbe8bed50b3a69cf6c9daca7175322bc392d3 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Fri, 30 Oct 2026 11:28:22 +0000 Subject: [PATCH] Decompile 6 functions in Source/Client/Session.cpp, Source/Client/Session.h, ... Batch #5353 by eAthena: 0 byte-identical, 6 confirmed by peer review. - fn_23593 CSession::FlagInventoryItem: logic confirmed by peer review - fn_23594 CSession::FlagItem1740: logic confirmed by peer review - fn_23595 CSession::FlagItem1738: logic confirmed by peer review - fn_23596 CSession::CollectItems1750: logic confirmed by peer review - fn_23597 CSession::RefreshItems1750: logic confirmed by peer review - fn_23600 ClientItemLists::AddExchangeItem: logic confirmed by peer review Peer-reviewed-by: alisonrag, sherollyner, Snow, ragnarok-clanker, tayoba, bigodeira Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Client/Session.cpp | 95 +++++++++++++++++++++++++++++ Source/Client/Session.h | 7 ++- Source/Contents/ClientItemLists.cpp | 47 +++++++++++++- 3 files changed, 146 insertions(+), 3 deletions(-) diff --git a/Source/Client/Session.cpp b/Source/Client/Session.cpp index a3220016..87fd10a4 100644 --- a/Source/Client/Session.cpp +++ b/Source/Client/Session.cpp @@ -1680,3 +1680,98 @@ void CSession::RefreshHpSpWindows() { static_cast(g_modeMgr.GetGameMode())->NotifyItemBounds(); } + +// OFFSET: 0x00DFC0B0 +// FUNCTION: fn_23593 +void CSession::FlagInventoryItem(std::uint32_t id) { + for (ITEM_INFO& item : this->m_inventoryItems) { + if (item.unknown_0000[1] == id) { + item.unknown_0074[2] = 1; + RefreshItemWindows(&g_windowMgr); + return; + } + } +} + +// OFFSET: 0x00DFC0F0 +// FUNCTION: fn_23594 +void CSession::FlagItem1740(std::uint32_t id) { + for (ITEM_INFO& item : this->unknown_1740) { + if (item.unknown_0000[1] == id) { + item.unknown_0074[2] = 1; + RefreshItemWindows(&g_windowMgr); + return; + } + } +} + +// OFFSET: 0x00DFC130 +// FUNCTION: fn_23595 +void CSession::FlagItem1738(std::uint32_t id) { + for (ITEM_INFO& item : this->unknown_1738) { + if (item.unknown_0000[1] == id) { + item.unknown_0074[2] = 1; + RefreshItemWindows(&g_windowMgr); + return; + } + } +} + +// OFFSET: 0x00DFC170 +// FUNCTION: fn_23596 +void CSession::CollectItems1750() { + this->unknown_1750.erase(this->unknown_1750.begin(), this->unknown_1750.end()); + + const int count = static_cast(this->m_inventoryItems.size()); + for (int i = 0; i < count; ++i) { + ITEM_INFO item = this->GetInventoryItemAt(i); + if (item.unknown_0000[1] > 0) { + const int itemId = std::atoi(item.itemId.c_str()); + if (std::find(this->unknown_1778.begin(), this->unknown_1778.end(), itemId) != this->unknown_1778.end()) { + this->unknown_1750.push_back(item); + } + } + } +} + +// OFFSET: 0x00DFC330 +// FUNCTION: fn_23597 +void CSession::RefreshItems1750() { + this->unknown_1750.erase(this->unknown_1750.begin(), this->unknown_1750.end()); + + const int count = static_cast(this->m_inventoryItems.size()); + for (int i = 0; i < count; ++i) { + ITEM_INFO item = this->GetInventoryItemAt(i); + if (item.unknown_0000[1] > 0) { + const int itemId = std::atoi(item.itemId.c_str()); + if (std::find(this->unknown_1778.begin(), this->unknown_1778.end(), itemId) != this->unknown_1778.end()) { + this->unknown_1750.push_back(item); + } + } + } + + for (auto it = this->unknown_1750.begin(); it != this->unknown_1750.end();) { + const int itemId = std::atoi(it->itemId.c_str()); + auto match = this->unknown_1748.begin(); + for (; match != this->unknown_1748.end(); ++match) { + if (std::atoi(match->itemId.c_str()) == itemId) { + break; + } + } + + if (match == this->unknown_1748.end()) { + it = this->unknown_1750.erase(it); + continue; + } + + const std::uint32_t value = match->unknown_0014[0]; + if (value == 0xFFFFFFFF || g_session.HasItem61B8(it->unknown_0000[1]) == 1) { + it = this->unknown_1750.erase(it); + continue; + } + + it->unknown_0014[0] = value; + it->unknown_0014[1] = value; + ++it; + } +} diff --git a/Source/Client/Session.h b/Source/Client/Session.h index 9c7d5875..62813347 100644 --- a/Source/Client/Session.h +++ b/Source/Client/Session.h @@ -204,7 +204,7 @@ public: /* 1760 */ std::list unknown_1760; /* 1768 */ std::list unknown_1768; /* 1770 */ std::list unknown_1770; - /* 1778 */ unsigned char unknown_1778[0x0C]; + /* 1778 */ std::vector unknown_1778; /* 1784 */ std::list unknown_1784[11]; /* 17DC */ std::list m_partyMembers; /* 17E4 */ std::list m_friends; @@ -655,6 +655,11 @@ public: void ClearNormalItemSlots(); void ResetItems6B68(); void ResetItems61B8(); + void FlagInventoryItem(std::uint32_t id); + void FlagItem1740(std::uint32_t id); + void FlagItem1738(std::uint32_t id); + void CollectItems1750(); + void RefreshItems1750(); bool IsPartyRecommendTarget(std::uint32_t aid); int GetBodyStyle(int job, int style, int renderJob); int GetUnknown8148() const; diff --git a/Source/Contents/ClientItemLists.cpp b/Source/Contents/ClientItemLists.cpp index e9d6e62d..94bb9759 100644 --- a/Source/Contents/ClientItemLists.cpp +++ b/Source/Contents/ClientItemLists.cpp @@ -196,7 +196,8 @@ struct ClientItemLists { /* 17DC */ std::list partyMembers; /* 17E4 */ unsigned char unknown_17E4[0x9BC]; /* 21A0 */ ITEM_INFO equipped[10]; - /* 2B50 */ unsigned char unknown_2B50[0x1D10]; + /* 2B50 */ unsigned char unknown_2B50[0x1360]; + /* 3EB0 */ ITEM_INFO exchangeItems[10]; /* 4860 */ ITEM_INFO itemSlots[10]; /* 5210 */ int unknown_5210; /* 5214 */ int unknown_5214; @@ -227,7 +228,8 @@ struct ClientItemLists { bool AddItem1738(const ITEM_INFO& item, unsigned char refresh); EquipSlots GetEquipSlots(int location); void RemoveItem1758ByItemId(ITEM_INFO& item); - void RemoveItem1710(std::uint32_t id, int quantity); + __declspec(noinline) void RemoveItem1710(std::uint32_t id, int quantity); + bool AddExchangeItem(ITEM_INFO item); bool RemoveItem1768(const ITEM_INFO& item, unsigned char alternate); bool RemoveItem1740(const ITEM_INFO& item); bool RemoveItem1750(const ITEM_INFO& item, int type, unsigned char refresh); @@ -1496,3 +1498,44 @@ void ClientItemLists::SetItems1750(int count, const short* ids) { } } } + +// OFFSET: 0x00DFCBB0 +// FUNCTION: fn_23600 +bool ClientItemLists::AddExchangeItem(ITEM_INFO item) { + int count = 0; + for (int i = 0; i < 10; ++i) { + if (this->exchangeItems[i].quantity != 0) { + ++count; + } + } + + if (count == 10) { + return false; + } + + this->RemoveItem1710(item.unknown_0000[1], item.quantity); + + ITEM_INFO added = item; + int index = 0; + for (; index < 10; ++index) { + if (this->exchangeItems[index].quantity != 0 && this->exchangeItems[index].unknown_0000[1] == added.unknown_0000[1]) { + this->exchangeItems[index].quantity += added.quantity; + break; + } + } + + if (index == 10) { + for (int i = 0; i < 10; ++i) { + if (this->exchangeItems[i].quantity == 0) { + this->exchangeItems[i] = added; + break; + } + } + } + + if (UIWindow* window = g_windowMgr.LookupWindow(10011)) { + window->SendMsg(nullptr, 23, 0, 0, 0, 0); + } + + return true; +}