diff --git a/Source/Contents/Async/AsyncWorkMgr.cpp b/Source/Contents/Async/AsyncWorkMgr.cpp index 0c3d0cf3..c3f3c1a8 100644 --- a/Source/Contents/Async/AsyncWorkMgr.cpp +++ b/Source/Contents/Async/AsyncWorkMgr.cpp @@ -112,12 +112,12 @@ void CAsyncWorkMgr::ChangePartyMaster( // OFFSET: 0x00574190 // FUNCTION: fn_02502 void CAsyncWorkMgr::LoadCharacter( - std::uint32_t accountId, std::uint32_t characterId, std::string world, std::string url, std::string token, CharacterConfigLoad& context + std::uint32_t accountId, std::uint32_t characterId, std::string world, std::string url, std::string token ) { NAsyncWorkPtr work(this->m_pools, "CharacterLinkedUserData_Load"); if (work.Get()) { - static_cast(work.Get())->Bind(accountId, characterId, world, url, token, context); + static_cast(work.Get())->Bind(accountId, characterId, world, url, token); this->Submit(work); } } diff --git a/Source/Contents/Async/AsyncWorkMgr.h b/Source/Contents/Async/AsyncWorkMgr.h index 570c0ab0..b7dcdbaf 100644 --- a/Source/Contents/Async/AsyncWorkMgr.h +++ b/Source/Contents/Async/AsyncWorkMgr.h @@ -9,7 +9,6 @@ class CConnection; class CEmblemDataMgr; #include "UI/Window/WindowManagerWindows.h" struct AccountConfigLoad; -struct CharacterConfigLoad; class CAsyncWorkMgr : public NAsyncWorkMgr { public: @@ -25,7 +24,7 @@ public: std::uint32_t accountId, std::uint32_t characterId, std::string characterName, std::uint32_t targetAccountId, std::uint32_t targetCharacterId, std::string targetName, std::string world, std::string url, std::string token, WindowManagerWindows& windows ); - void LoadCharacter(std::uint32_t accountId, std::uint32_t characterId, std::string world, std::string url, std::string token, CharacterConfigLoad& context); + void LoadCharacter(std::uint32_t accountId, std::uint32_t characterId, std::string world, std::string url, std::string token); void SaveCharacter(std::uint32_t accountId, std::uint32_t characterId, std::string world, std::string url, std::string token, std::string data); void DownloadEmblem( std::string url, std::uint32_t accountId, std::string token, std::string world, std::uint32_t guildId, std::uint32_t version, CConnection& connection diff --git a/Source/Contents/Skills/SkillLevelConfig.cpp b/Source/Contents/Skills/SkillLevelConfig.cpp index 2a2e6fc5..5609a87f 100644 --- a/Source/Contents/Skills/SkillLevelConfig.cpp +++ b/Source/Contents/Skills/SkillLevelConfig.cpp @@ -1,10 +1,13 @@ -#include "Contents/Skills/SkillLevelConfig.h" +#include "Client/Session.h" +#include "Contents/UserData/CharacterLinkedUserDataMgr.h" + +#include #include // OFFSET: 0x005E6A10 // FUNCTION: fn_03930 -void LoadUseSkillLevels(Json::Value& data, int* levels) { +void CCharacterLinkedUserDataMgr::LoadUseSkillLevels(Json::Value& data) { Json::Value values = data["UseSkillInfo"]; if (!values.isNull()) { for (auto it = values.begin(); it != values.end(); ++it) { @@ -12,9 +15,7 @@ void LoadUseSkillLevels(Json::Value& data, int* levels) { if (value.isObject()) { int id = value.get("SKID", 0).asInt(); int level = value.get("SKLv", 0).asInt(); - if (static_cast(id) - 1 <= 0x1F3D) { - levels[id] = level; - } + g_session.m_skillBundle.SetUnknownValue(id, level); } } } @@ -22,7 +23,7 @@ void LoadUseSkillLevels(Json::Value& data, int* levels) { // OFFSET: 0x005E63B0 // FUNCTION: fn_03928 -void LoadHomunculusSkillLevels(Json::Value& data, int* levels) { +void CCharacterLinkedUserDataMgr::LoadHomunculusSkillLevels(Json::Value& data) { Json::Value values = data["HomunSkillInfo"]; if (!values.isNull()) { for (auto it = values.begin(); it != values.end(); ++it) { @@ -31,10 +32,7 @@ void LoadHomunculusSkillLevels(Json::Value& data, int* levels) { int id = value.get("HomunSKID", 0).asInt(); int level = value.get("HomunSKLv", 0).asInt(); - std::uint32_t index = static_cast(id) - 8000; - if (static_cast(index) > -1) { - levels[index] = level; - } + g_session.SetHomunSkillLevel(id, level); } } } diff --git a/Source/Contents/Skills/SkillLevelConfig.h b/Source/Contents/Skills/SkillLevelConfig.h deleted file mode 100644 index b19fc458..00000000 --- a/Source/Contents/Skills/SkillLevelConfig.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef RAGNAROK_SOURCE_CONTENTS_SKILLS_SKILLLEVELCONFIG_H -#define RAGNAROK_SOURCE_CONTENTS_SKILLS_SKILLLEVELCONFIG_H - -#include - -void LoadUseSkillLevels(Json::Value& data, int* levels); -void LoadHomunculusSkillLevels(Json::Value& data, int* levels); - -#endif diff --git a/Source/Contents/Skills/SkillLevelRegistry.cpp b/Source/Contents/Skills/SkillLevelRegistry.cpp index 5d4147bd..6183cbe6 100644 --- a/Source/Contents/Skills/SkillLevelRegistry.cpp +++ b/Source/Contents/Skills/SkillLevelRegistry.cpp @@ -1,4 +1,6 @@ #include "Contents/Skills/SkillInfo.h" +#include "Client/Registry.h" +#include "Client/Session.h" #include "Contents/Skills/SkillLevelRegistry.h" #include "Script/LuaScript.h" @@ -9,9 +11,9 @@ // OFFSET: 0x00A92370 // FUNCTION: fn_17177 -void SkillLevelRegistry::Load() { +void LoadSkillUseLevelRegistry() { char key[512]; - std::strcpy(key, this->baseKey); + std::strcpy(key, g_subKey); std::strcat(key, "\\SkillUseLevelInfo"); HKEY handle; @@ -30,11 +32,11 @@ void SkillLevelRegistry::Load() { DWORD size = sizeof(int); int value; char name[100] = {}; - const int character = this->character; - const char* skill = CSkillInfo::IdName(this->script, id); + const int character = g_session.unknown_0F50; + const char* skill = CSkillInfo::IdName(*g_luaScript, id); std::sprintf(name, "%s%d", skill, character); - if (RegQueryValueExA(handle, name, nullptr, &type, reinterpret_cast(&value), &size) != ERROR_SUCCESS || !CSkillInfo::UsesLevel(this->script, id)) { + if (RegQueryValueExA(handle, name, nullptr, &type, reinterpret_cast(&value), &size) != ERROR_SUCCESS || !CSkillInfo::UsesLevel(*g_luaScript, id)) { return 0; } @@ -42,15 +44,15 @@ void SkillLevelRegistry::Load() { }; for (int id = 1; id < 7999; ++id) { - this->useLevels[id] = read(id); + g_session.m_skillBundle.SetUnknownValue(id, read(id)); } for (int id = 8000; id < 8061; ++id) { - this->homunculusLevels[id - 8000] = read(id); + g_session.SetHomunSkillLevel(id, read(id)); } for (int id = 8200; id < 8458; ++id) { - this->otherLevels[id - 8200] = read(id); + g_session.SetMercSkillLevel(id, read(id)); } RegCloseKey(handle); diff --git a/Source/Contents/Skills/SkillLevelRegistry.h b/Source/Contents/Skills/SkillLevelRegistry.h index 2e2ef934..4b63146d 100644 --- a/Source/Contents/Skills/SkillLevelRegistry.h +++ b/Source/Contents/Skills/SkillLevelRegistry.h @@ -1,17 +1,6 @@ #ifndef RAGNAROK_SOURCE_CONTENTS_SKILLS_SKILLLEVELREGISTRY_H #define RAGNAROK_SOURCE_CONTENTS_SKILLS_SKILLLEVELREGISTRY_H -class LuaScript; - -struct SkillLevelRegistry { - LuaScript& script; - const char* baseKey; - const int& character; - int* useLevels; - int* homunculusLevels; - int* otherLevels; - - void Load(); -}; +void LoadSkillUseLevelRegistry(); #endif diff --git a/Source/Contents/UserData/CharacterConfigLoad.cpp b/Source/Contents/UserData/CharacterConfigLoad.cpp index da193928..1496747e 100644 --- a/Source/Contents/UserData/CharacterConfigLoad.cpp +++ b/Source/Contents/UserData/CharacterConfigLoad.cpp @@ -1,11 +1,9 @@ #include "Client/Session.h" #include "Contents/Async/AsyncWorkMgr.h" -#include "Contents/UserData/CharacterConfigLoad.h" #include "Contents/UserData/CharacterLinkedUserDataMgr.h" #include "Contents/Configuration/ServiceOptions.h" -#include "Contents/Skills/SkillLevelConfig.h" #include "Contents/Skills/SkillLevelRegistry.h" -#include "UI/Shortcuts/NormalItemSlotLoad.h" +#include "UI/Window/UIWindowMgr.h" #include "Utility/Async/AsyncDiagnostic.h" #include @@ -14,7 +12,7 @@ // OFFSET: 0x005E6090 // FUNCTION: fn_03927 void CCharacterLinkedUserDataMgr::CompleteLoad( - AsyncDiagnostic diagnostic, std::uint32_t accountId, std::uint32_t characterId, std::string accountName, std::string response, CharacterConfigLoad& context + AsyncDiagnostic diagnostic, std::uint32_t accountId, std::uint32_t characterId, std::string accountName, std::string response ) { if (!diagnostic.success) { return; @@ -31,22 +29,21 @@ void CCharacterLinkedUserDataMgr::CompleteLoad( const int type = root["Type"].asInt(); if (type == 4) { - context.registry.Load(); + LoadSkillUseLevelRegistry(); g_session.SetOption(7, 1, 0); g_session.SetOption(8, 1, 0); this->m_loaded = true; } else if (type == 1) { - Json::Value& data = root["data"]; - LoadUseSkillLevels(data, context.useLevels); - LoadHomunculusSkillLevels(data, context.homunculusLevels); + this->LoadUseSkillLevels(root["data"]); + this->LoadHomunculusSkillLevels(root["data"]); - const Json::Value comparison = data["ItemComparison"]; - context.serviceOptions.Set(264, comparison.isNull() ? true : comparison.asBool()); + const Json::Value comparison = root["data"]["ItemComparison"]; + g_serviceOptions.Set(264, comparison.isNull() ? true : comparison.asBool()); - const Json::Value sorting = data["SortPrivateTab"]; - context.sortPrivate = sorting.isNull() ? false : sorting.asBool(); + const Json::Value sorting = root["data"]["SortPrivateTab"]; + g_sortPrivateTab = sorting.isNull() ? false : sorting.asBool(); - LoadNormalItemSlots(data, context.items, context.saved, context.itemSlotActive, context.windows); + this->LoadNormalItemSlots(root["data"]); this->m_loaded = true; } @@ -57,14 +54,12 @@ void CCharacterLinkedUserDataMgr::CompleteLoad( // OFFSET: 0x005E6E20 // FUNCTION: fn_03932 -void CCharacterLinkedUserDataMgr::Load( - std::uint32_t accountId, std::uint32_t characterId, std::string accountName, const char* token16, CAsyncWorkMgr& workManager, CharacterConfigLoad& context -) { +void CCharacterLinkedUserDataMgr::Load(std::uint32_t accountId, std::uint32_t characterId, std::string accountName) { if (accountId == 0 || characterId == 0) { return; } - const std::string token(token16, 16); + const std::string token(reinterpret_cast(&g_session.unknown_807C[0x08]), 16); const std::string url = this->LoadUrl(); - workManager.LoadCharacter(accountId, characterId, accountName, url, token, context); + g_asyncWorkMgr->LoadCharacter(accountId, characterId, accountName, url, token); } diff --git a/Source/Contents/UserData/CharacterConfigLoad.h b/Source/Contents/UserData/CharacterConfigLoad.h deleted file mode 100644 index 0e369ea0..00000000 --- a/Source/Contents/UserData/CharacterConfigLoad.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef RAGNAROK_SOURCE_CONTENTS_USERDATA_CHARACTERCONFIGLOAD_H -#define RAGNAROK_SOURCE_CONTENTS_USERDATA_CHARACTERCONFIGLOAD_H - -struct NormalItemSlot; -struct NormalItemSlotWindow; -struct ServiceOptions; -struct SkillLevelRegistry; -#include "UI/Window/WindowManagerWindows.h" - -struct CharacterConfigLoad { - int* useLevels; - int* homunculusLevels; - ServiceOptions& serviceOptions; - SkillLevelRegistry& registry; - bool& sortPrivate; - NormalItemSlot* items; - NormalItemSlotWindow& saved; - bool& itemSlotActive; - WindowManagerWindows& windows; -}; - -#endif diff --git a/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.cpp b/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.cpp index d3657e42..71b7f047 100644 --- a/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.cpp +++ b/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.cpp @@ -22,7 +22,7 @@ namespace { // OFFSET: 0x005E4A50 // FUNCTION: fn_03916 CCharacterLinkedUserDataLoadAsyncWork::CCharacterLinkedUserDataLoadAsyncWork() - : NAsyncWork("CharacterLinkedUserData_Load"), m_accountId(0), m_characterId(0), m_diagnostic(Diagnostic(false, "unknwon", 29)), m_context(nullptr) { + : NAsyncWork("CharacterLinkedUserData_Load"), m_accountId(0), m_characterId(0), m_diagnostic(Diagnostic(false, "unknwon", 29)) { } // INLINED @@ -36,7 +36,7 @@ void CCharacterLinkedUserDataLoadAsyncWork::Reset() { // OFFSET: 0x005E4F10 // FUNCTION: fn_03918 void CCharacterLinkedUserDataLoadAsyncWork::Bind( - std::uint32_t accountId, std::uint32_t characterId, std::string accountName, std::string url, std::string token, CharacterConfigLoad& context + std::uint32_t accountId, std::uint32_t characterId, std::string accountName, std::string url, std::string token ) { this->m_group = timeGetTime(); this->m_accountId = accountId; @@ -46,7 +46,6 @@ void CCharacterLinkedUserDataLoadAsyncWork::Bind( this->m_url = url; this->m_token = token; this->m_response.clear(); - this->m_context = &context; AsyncDiagnostic diagnostic = Diagnostic(false, "unknwon", 55); this->m_diagnostic.MoveFrom(diagnostic); @@ -80,6 +79,6 @@ bool CCharacterLinkedUserDataLoadAsyncWork::Execute() { // FUNCTION: fn_03920 void CCharacterLinkedUserDataLoadAsyncWork::Complete() { g_characterLinkedUserDataMgr->CompleteLoad( - this->m_diagnostic, this->m_accountId, this->m_characterId, this->m_accountName, this->m_response, *this->m_context + this->m_diagnostic, this->m_accountId, this->m_characterId, this->m_accountName, this->m_response ); } diff --git a/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.h b/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.h index 8cc81d1c..4c52867a 100644 --- a/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.h +++ b/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.h @@ -4,8 +4,6 @@ #include "Utility/Async/AsyncDiagnostic.h" #include "Utility/Async/NAsyncWork.h" -struct CharacterConfigLoad; - class CCharacterLinkedUserDataLoadAsyncWork : public NAsyncWork { public: CCharacterLinkedUserDataLoadAsyncWork(); @@ -13,7 +11,7 @@ public: void Reset() override; bool Execute() override; void Complete() override; - void Bind(std::uint32_t accountId, std::uint32_t characterId, std::string accountName, std::string url, std::string token, CharacterConfigLoad& context); + void Bind(std::uint32_t accountId, std::uint32_t characterId, std::string accountName, std::string url, std::string token); protected: /* 0028 */ std::uint32_t m_accountId; @@ -23,12 +21,10 @@ protected: /* 0060 */ std::string m_token; /* 0078 */ std::string m_response; /* 0090 */ AsyncDiagnostic m_diagnostic; - - CharacterConfigLoad* m_context; }; #if defined(_WIN32) && !defined(_WIN64) -static_assert(sizeof(CCharacterLinkedUserDataLoadAsyncWork) == 204); +static_assert(sizeof(CCharacterLinkedUserDataLoadAsyncWork) == 200); #endif #endif diff --git a/Source/Contents/UserData/CharacterLinkedUserDataMgr.h b/Source/Contents/UserData/CharacterLinkedUserDataMgr.h index a9ace729..88627da1 100644 --- a/Source/Contents/UserData/CharacterLinkedUserDataMgr.h +++ b/Source/Contents/UserData/CharacterLinkedUserDataMgr.h @@ -6,7 +6,9 @@ class LuaScript; struct AsyncDiagnostic; -struct CharacterConfigLoad; +namespace Json { + class Value; +} struct CharacterConfigSave; class CAsyncWorkMgr; @@ -19,12 +21,11 @@ public: std::string LoadUrl() const; std::string SaveUrl() const; void CompleteSave(); - void CompleteLoad( - AsyncDiagnostic diagnostic, std::uint32_t accountId, std::uint32_t characterId, std::string accountName, std::string response, CharacterConfigLoad& context - ); - void Load( - std::uint32_t accountId, std::uint32_t characterId, std::string accountName, const char* token16, CAsyncWorkMgr& workManager, CharacterConfigLoad& context - ); + void CompleteLoad(AsyncDiagnostic diagnostic, std::uint32_t accountId, std::uint32_t characterId, std::string accountName, std::string response); + void Load(std::uint32_t accountId, std::uint32_t characterId, std::string accountName); + void LoadUseSkillLevels(Json::Value& data); + void LoadHomunculusSkillLevels(Json::Value& data); + void LoadNormalItemSlots(Json::Value& data); void Save(CharacterConfigSave& context, const char* token16, CAsyncWorkMgr& workManager); void RefreshUrls(LuaScript& script, const char* host, const char* port, const char* overrideKey); void Reset(LuaScript& script, const char* host, const char* port, const char* overrideKey); @@ -41,6 +42,7 @@ protected: }; extern CCharacterLinkedUserDataMgr* g_characterLinkedUserDataMgr; +extern bool g_sortPrivateTab; #if defined(_WIN32) && !defined(_WIN64) static_assert(sizeof(CCharacterLinkedUserDataMgr) == 96); diff --git a/Source/UI/Shortcuts/NormalItemSlotLoad.cpp b/Source/UI/Shortcuts/NormalItemSlotLoad.cpp index e30ff5a6..ffec9cf7 100644 --- a/Source/UI/Shortcuts/NormalItemSlotLoad.cpp +++ b/Source/UI/Shortcuts/NormalItemSlotLoad.cpp @@ -1,23 +1,25 @@ -#include "UI/Shortcuts/NormalItemSlotLoad.h" +#include "Client/Session.h" +#include "Contents/UserData/CharacterLinkedUserDataMgr.h" +#include "UI/Window/UIWindowMgr.h" #include "UI/Window/UIWindowMgr.inl" #include "UI/Window/UIWindow.h" -#include "UI/Window/WindowManagerWindows.h" #include #include // OFFSET: 0x005E65E0 // FUNCTION: fn_03929 -void LoadNormalItemSlots( - Json::Value& data, NormalItemSlot* slots, NormalItemSlotWindow& saved, bool& itemSlotActive, WindowManagerWindows& windows -) { +void CCharacterLinkedUserDataMgr::LoadNormalItemSlots(Json::Value& data) { + NormalItemSlotWindow& saved = g_windowMgr.m_normalItemSlotWindow; + bool& itemSlotActive = g_session.ItemSlotActive(); + Json::Value& values = data["NormalItemSlot"]; if (values.isNull()) { return; } - std::memset(slots, 0, 9 * sizeof(NormalItemSlot)); + g_session.ClearNormalItemSlots(); for (auto entry = values.begin(); entry != values.end(); ++entry) { Json::Value& value = *entry; @@ -28,7 +30,7 @@ void LoadNormalItemSlots( const int item = value.get("ItemID", 0).asInt(); const int index = value.get("SlotNum", 0).asInt(); - slots[index].itemId = static_cast(item); + g_session.m_normalItemSlots[index].itemId = static_cast(item); } Json::Value& info = data["SlotInfo"]; @@ -52,7 +54,7 @@ void LoadNormalItemSlots( Json::Value& active = data["ItemSlotActive"]; itemSlotActive = active.isNull() ? true : active.asBool(); - UIWindow* window = windows.LookupWindow(36); + UIWindow* window = g_windowMgr.LookupWindow(36); if (!window) { return; diff --git a/Source/UI/Shortcuts/NormalItemSlotLoad.h b/Source/UI/Shortcuts/NormalItemSlotLoad.h deleted file mode 100644 index 28f4b9d2..00000000 --- a/Source/UI/Shortcuts/NormalItemSlotLoad.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef RAGNAROK_SOURCE_UI_SHORTCUTS_NORMALITEMSLOTLOAD_H -#define RAGNAROK_SOURCE_UI_SHORTCUTS_NORMALITEMSLOTLOAD_H - -#include "Contents/UserData/NormalItemSlots.h" - -#include "UI/Window/WindowManagerWindows.h" - -void LoadNormalItemSlots( - Json::Value& data, NormalItemSlot* slots, NormalItemSlotWindow& saved, bool& itemSlotActive, WindowManagerWindows& windows -); - -#endif diff --git a/Source/UI/Window/UIWindowMgr.cpp b/Source/UI/Window/UIWindowMgr.cpp index 578e5271..bc957da2 100644 --- a/Source/UI/Window/UIWindowMgr.cpp +++ b/Source/UI/Window/UIWindowMgr.cpp @@ -1299,7 +1299,7 @@ void UIWindowMgr::ApplyReplayOptions(const ReplayOptions& options) { this->unknown_077C = 0; this->unknown_05BC = 0; this->unknown_05D0 = 0; - this->unknown_0758 = options.unknown_0007; + this->m_normalItemSlotWindow.show = options.unknown_0007; this->unknown_003C = options.recordRestricted; } diff --git a/Source/UI/Window/UIWindowMgr.h b/Source/UI/Window/UIWindowMgr.h index 0294fb3c..64a13e5f 100644 --- a/Source/UI/Window/UIWindowMgr.h +++ b/Source/UI/Window/UIWindowMgr.h @@ -354,8 +354,8 @@ public: /* 05D0 */ int unknown_05D0; /* 05D4 */ unsigned char unknown_05D4[0x168]; /* 073C */ int unknown_073C; - /* 0740 */ unsigned char unknown_0740[0x18]; - /* 0758 */ int unknown_0758; + /* 0740 */ unsigned char unknown_0740[0x08]; + /* 0748 */ NormalItemSlotWindow m_normalItemSlotWindow; /* 075C */ unsigned char unknown_075C[0x20]; /* 077C */ int unknown_077C; /* 0780 */ unsigned char unknown_0780[0x10]; diff --git a/Source/UI/Window/UIWindowMgr.inl b/Source/UI/Window/UIWindowMgr.inl index 2d4ea8a3..ce520a1c 100644 --- a/Source/UI/Window/UIWindowMgr.inl +++ b/Source/UI/Window/UIWindowMgr.inl @@ -12,7 +12,7 @@ inline bool UIWindowMgr::ShowShortcutWindow(int value) { return false; } - this->unknown_0758 = value; + this->m_normalItemSlotWindow.show = value; g_windowMgr.EnsureWindow(36); this->window_01E8->Show(value);