From 9addd9793f8a2ac3002cd58fef6567a8d6d4ae8a Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Wed, 11 Nov 2026 09:32:35 +0000 Subject: [PATCH] Decompile 7 functions in Source/Client/Session/Session.cpp Batch #16829 by eAthena: 6 byte-identical, 1 confirmed by peer review. - fn_23483 CSession::GetShopType: byte-identical - fn_23488 CSession::HiFriends: byte-identical - fn_23506 CSession::LoadSessionTables: logic confirmed by peer review - fn_23510 CSession::InitWeaponHitWaveNames: byte-identical (already on main) - fn_23616 CSession::SaveMiniPartyInfo: byte-identical - fn_24166 CSession::CountDistinctCostumeItems: byte-identical - fn_24167 CSession::CountDistinctEquippedItems: byte-identical Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Client/Session/Session.cpp | 93 ++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 32 deletions(-) diff --git a/Source/Client/Session/Session.cpp b/Source/Client/Session/Session.cpp index 5e5376a11..1f6fdee7b 100644 --- a/Source/Client/Session/Session.cpp +++ b/Source/Client/Session/Session.cpp @@ -75,6 +75,29 @@ #include #include #include "Utility/StdStringCompare.h" +#include "Utility/Math/AffineMatrix.h" + +using SessionShopTree = std::_Tree, std::allocator>, false>>; +extern template std::_Tree_find_result, void*>*> +SessionShopTree::_Find_lower_bound(const int&) const; + +using NameToIdTree = std::_Tree, std::allocator>, false>>; +extern template std::_Tree_find_result, void*>*> +NameToIdTree::_Find_lower_bound(const std::string&) const; + +using ShopEntryTree = std::_Tree, std::less, std::allocator>>, false>>; +extern template std::_Tree_find_result>, void*>*> +ShopEntryTree::_Find_lower_bound(const int&) const; + +using ActorIdTree = std::_Tree, std::allocator, false>>; +extern template std::_Tree_find_result*> +ActorIdTree::_Find_lower_bound(const std::uint32_t&) const; + +extern template void std::vector::resize(size_type, const std::string&); // STATIC: 0x01732638 // GLOBAL: gl_24474 @@ -1981,7 +2004,7 @@ void CSession::IgnoreText(std::string text) { // OFFSET: 0x00DFF2A0 // FUNCTION: fn_23616 void CSession::SaveMiniPartyInfo() { - std::string text; + std::string text(""); for (auto it = this->miniPartyRecords.begin(); it != this->miniPartyRecords.end(); ++it) { char line[512]; @@ -2508,10 +2531,10 @@ std::uint32_t CSession::GetItemNameColor(const ITEM_INFO& item) const { // OFFSET: 0x00E30720 // FUNCTION: fn_24166 int CSession::CountDistinctCostumeItems() const { - std::vector itemIds; int count = 0; + std::vector itemIds; for (int i = 0; i < 10; ++i) { - const std::uint32_t itemId = this->costumeItems[i].identity[1]; + const int itemId = this->costumeItems[i].identity[1]; if (itemId != 0 && std::find(itemIds.begin(), itemIds.end(), itemId) == itemIds.end()) { itemIds.push_back(itemId); ++count; @@ -2524,10 +2547,10 @@ int CSession::CountDistinctCostumeItems() const { // OFFSET: 0x00E30830 // FUNCTION: fn_24167 int CSession::CountDistinctEquippedItems() const { - std::vector itemIds; int count = 0; + std::vector itemIds; for (int i = 0; i < 10; ++i) { - const std::uint32_t itemId = this->equippedItems[i].identity[1]; + const int itemId = this->equippedItems[i].identity[1]; if (itemId != 0 && std::find(itemIds.begin(), itemIds.end(), itemId) == itemIds.end()) { itemIds.push_back(itemId); ++count; @@ -2566,12 +2589,12 @@ const char* CSession::GetMonsterW3dName(int job) const { // OFFSET: 0x00DE38E0 // FUNCTION: fn_23483 unsigned char CSession::GetShopType(int id) { - auto it = this->m_shops.lower_bound(id); - if (it == this->m_shops.end() || it->first != id) { - return 0; + auto it = this->m_shops.find(id); + if (it != this->m_shops.end()) { + return it->second.flag; } - return it->second.flag; + return 0; } // OFFSET: 0x00DE3930 @@ -2613,11 +2636,15 @@ bool CSession::HasControlCharacter(std::string text) { // FUNCTION: fn_23488 void CSession::HiFriends(char* text) { std::string greeting = "(Hi) "; - greeting += text ? text : "*^_^*"; + if (text) { + greeting += text; + } else { + greeting += "*^_^*"; + } - for (const MessengerMember& member : this->m_friends) { + for (auto it = this->m_friends.begin(); it != this->m_friends.end(); ++it) { g_windowMgr.chatInputText = greeting.c_str(); - g_modeMgr.gameMode->SendMsg(MM_WHISPERMSG, reinterpret_cast(member.name.c_str()), 0, 0, 0); + g_modeMgr.gameMode->SendMsg(MM_WHISPERMSG, reinterpret_cast(it->name.c_str()), 0, 0, 0); if (++g_pendingWhisperCount > 40) { g_pendingWhisperCount = 40; } @@ -7054,18 +7081,19 @@ void CSession::LoadSessionTables() { session->InitJobHitWaveNames(); CCommonObject& storage = reinterpret_cast(session->minimapTokenStorage[0x30]); - std::vector tokens; - session->m_bgmFileNames.clear(); - session->m_bgmFileNames.reserve(512); - storage.LoadTokens(tokens, "mp3NameTable.txt", 0); - for (auto token = tokens.begin(); token != tokens.end(); token += 2) { - session->m_bgmFileNames.push_back(std::make_pair(token[0], token[1])); + { + std::vector tokens; + session->m_bgmFileNames.clear(); + session->m_bgmFileNames.reserve(512); + storage.LoadTokens(tokens, "mp3NameTable.txt", 0); + for (auto token = tokens.begin(); token != tokens.end(); token += 2) { + session->m_bgmFileNames.push_back(std::make_pair(token[0], token[1])); + } + std::sort(session->m_bgmFileNames.begin(), session->m_bgmFileNames.end(), + [](const std::pair& left, const std::pair& right) { + return std::strcmp(left.first, right.first) < 0; + }); } - std::sort(session->m_bgmFileNames.begin(), session->m_bgmFileNames.end(), - [](const std::pair& left, const std::pair& right) { - return std::strcmp(left.first, right.first) < 0; - }); - tokens = std::vector(); storage.LoadTokens(session->m_indoorRswNames, "indoorRswTable.txt", 0); std::sort(session->m_indoorRswNames.begin(), session->m_indoorRswNames.end(), @@ -7098,20 +7126,21 @@ void CSession::LoadSessionTables() { session->InitCommandTables(); session->ResetCharacterState(); session->ClearItemContainers(); - session->m_inventoryItems.clear(); - session->m_pingSamples.clear(); + session->m_inventoryItems.erase(session->m_inventoryItems.begin(), session->m_inventoryItems.end()); + session->m_pingSamples.erase(session->m_pingSamples.begin(), session->m_pingSamples.end()); for (int index = 0; index < 10; ++index) { session->equippedItems[index].Reset(); } - std::vector buyingStoreItems; - session->inventoryFilterIds.clear(); - session->inventoryFilterIds.reserve(512); - storage.LoadTokens(buyingStoreItems, "BuyingStoreItemList.txt", 0); - for (char* token : buyingStoreItems) { - session->inventoryFilterIds.push_back(std::atoi(token)); + { + std::vector buyingStoreItems; + session->inventoryFilterIds.clear(); + session->inventoryFilterIds.reserve(512); + storage.LoadTokens(buyingStoreItems, "BuyingStoreItemList.txt", 0); + for (char* token : buyingStoreItems) { + session->inventoryFilterIds.push_back(std::atoi(token)); + } } - buyingStoreItems = std::vector(); session->mapPositionsScaled = 0; session->m_mapPosListCount = -1;