diff --git a/Source/Client/Application/Launcher.cpp b/Source/Client/Application/Launcher.cpp index 069fcf06..8bc70094 100644 --- a/Source/Client/Application/Launcher.cpp +++ b/Source/Client/Application/Launcher.cpp @@ -1673,8 +1673,7 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR commandLine, in ResetTimer(); CoInitialize(nullptr); - SoundMgrContext sound{g_soundConfiguration, g_serviceOptions, ResourceMgr::Instance()}; - if (!CSoundMgr::Create(sound)) { + if (!CSoundMgr::Create()) { const std::uint8_t audioFailureSource[] = {0x68, 0xBA, 0x4D, 0x6E, 0x8C, 0x09, 0xA4, 0x12, 0x5A, 0xBB, 0x4C, 0x6A, 0xC3, 0x60, 0x99, 0x02, 0x5D, 0xEF, 0x6F, 0x66, 0x8A, 0x45, 0x92, 0x0F, 0x29}; thread_local EncryptedName audioFailure(audioFailureSource); diff --git a/Source/Client/Session.cpp b/Source/Client/Session.cpp index b63ee486..cd3a4ec7 100644 --- a/Source/Client/Session.cpp +++ b/Source/Client/Session.cpp @@ -2590,8 +2590,7 @@ int CSession::CountItems17F0() const { // OFFSET: 0x00DF9490 // FUNCTION: fn_23516 void CSession::RefreshSkillTree() { - JobInheritance inheritance{*this->m_hotkeyScript}; - inheritance.InitializeSkillTree(this->m_skillBundle, this->m_job); + this->InitializeSkillTree(); if (g_windowMgr.window_02C4) { g_windowMgr.window_02C4->SendMsg(nullptr, 0x3C, 0, 0, 0, 0); } diff --git a/Source/Client/Session.h b/Source/Client/Session.h index ddd7086a..f01de9c2 100644 --- a/Source/Client/Session.h +++ b/Source/Client/Session.h @@ -29,6 +29,7 @@ class UIWindowMgr; class CActRes; +class CFile; class CGameActor; class CRenderObject; class LuaScript; @@ -850,6 +851,12 @@ public: void RemoveSkill(std::uint32_t id); bool UpdateSkill(const CSkillInfo& value, unsigned char notify, unsigned char updateUnknown000C); bool UpdateAdditionalSkill(const CSkillInfo& value, int unused); + int InheritedJob(int job); + void WriteOptionFloat(CFile& file, const char* key, float value); + void WriteOptionInteger(CFile& file, const char* key, int value); + void WriteOptionString(CFile& file, const char* key, const char* value); + void WriteOptionGuid(CFile& file, const char* key, const GUID& value); + void InitializeSkillTree(); void NotifyHomunSkillWindows(); void NotifyMercSkillWindows(); int GetPetActionNumber(int hungerLevel, int friendlyLevel, int action); @@ -966,7 +973,7 @@ public: void InitResourceNameTables(); void InitJobSpriteNames(); const char* GetEFSTImgFileName(int efstId, int type); - int IsTreeGroupTwo(int job) const; + bool IsTreeGroupTwo(int job) const; bool IsTreeGroupThree(int job) const; bool IsThirdJobOrHigher(int job); std::string GetSexName(int sex); diff --git a/Source/Contents/Configuration/OptionWriter.cpp b/Source/Contents/Configuration/OptionWriter.cpp index 42567741..b0a4e19e 100644 --- a/Source/Contents/Configuration/OptionWriter.cpp +++ b/Source/Contents/Configuration/OptionWriter.cpp @@ -1,4 +1,4 @@ -#include "Contents/Configuration/OptionWriter.h" +#include "Client/Session.h" #include "File/File.h" #include @@ -7,23 +7,23 @@ // OFFSET: 0x00E26B10 // FUNCTION: fn_23917 -void OptionWriter::Float(const char* key, float value) { +void CSession::WriteOptionFloat(CFile& file, const char* key, float value) { char line[200]; std::sprintf(line, "OptionInfoList[\"%s\"] = %f\r\n", key, value); - this->file.Write(line, static_cast(std::strlen(line))); + file.Write(line, static_cast(std::strlen(line))); } // OFFSET: 0x00E26C00 // FUNCTION: fn_23919 -void OptionWriter::Integer(const char* key, int value) { +void CSession::WriteOptionInteger(CFile& file, const char* key, int value) { char line[204]; std::sprintf(line, "OptionInfoList[\"%s\"] = %d\r\n", key, value); - this->file.Write(line, static_cast(std::strlen(line))); + file.Write(line, static_cast(std::strlen(line))); } // OFFSET: 0x00E26C70 // FUNCTION: fn_23920 -void OptionWriter::String(const char* key, const char* value) { +void CSession::WriteOptionString(CFile& file, const char* key, const char* value) { std::string escaped(value); std::size_t offset = 0; @@ -36,13 +36,13 @@ void OptionWriter::String(const char* key, const char* value) { const int count = _snprintf_s(line, sizeof(line), _TRUNCATE, "OptionInfoList[\"%s\"] = \"%s\"\r\n", key, escaped.c_str()); if (count > 0) { - this->file.Write(line, count); + file.Write(line, count); } } // OFFSET: 0x00E26B90 // FUNCTION: fn_23918 -void OptionWriter::Guid(const char* key, const GUID& value) { +void CSession::WriteOptionGuid(CFile& file, const char* key, const GUID& value) { char text[40]; _snprintf_s( text, sizeof(text), _TRUNCATE, "{%08X-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}", value.Data1, value.Data2, value.Data3, @@ -52,6 +52,6 @@ void OptionWriter::Guid(const char* key, const GUID& value) { const int count = _snprintf_s(line, sizeof(line), _TRUNCATE, "OptionInfoList[\"%s\"] = \"%s\"\r\n", key, text); if (count > 0) { - this->file.Write(line, count); + file.Write(line, count); } } diff --git a/Source/Contents/Configuration/OptionWriter.h b/Source/Contents/Configuration/OptionWriter.h deleted file mode 100644 index 5f09cd82..00000000 --- a/Source/Contents/Configuration/OptionWriter.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef RAGNAROK_SOURCE_CONTENTS_CONFIGURATION_OPTIONWRITER_H -#define RAGNAROK_SOURCE_CONTENTS_CONFIGURATION_OPTIONWRITER_H - -#include - -class CFile; - -struct OptionWriter { - CFile& file; - - void Float(const char* key, float value); - void Integer(const char* key, int value); - void String(const char* key, const char* value); - void Guid(const char* key, const GUID& value); -}; - -#endif diff --git a/Source/Contents/Configuration/ServiceOptions.cpp b/Source/Contents/Configuration/ServiceOptions.cpp index 711b7ad8..456cc087 100644 --- a/Source/Contents/Configuration/ServiceOptions.cpp +++ b/Source/Contents/Configuration/ServiceOptions.cpp @@ -4,7 +4,6 @@ #include "Contents/Configuration/ServiceConfiguration.h" #include "Contents/MapSkyMgr.h" #include "Contents/MessageTable.h" -#include "Contents/Configuration/OptionWriter.h" #include "Contents/SkinMgr.h" #include "File/File.h" #include "Contents/Sound/SoundMgr.h" @@ -1682,63 +1681,62 @@ void CSession::SaveOptionInfo() { output.Write(buffer, size); delete[] buffer; - OptionWriter writer{output}; - writer.Integer("Trilinear", g_textureFiltering); - writer.Integer("Bgm_Volume", g_soundMgr->targetVolume); - writer.Integer("Effect_Volume", g_soundMgr->sampleVolume); - writer.Integer("AutoOpen1to1Window", this->m_autoOpenWhisperWindow); - writer.Integer("AutoOpen1to1Window_Friend", this->m_autoOpenFriendWhisperWindow); - writer.Integer("PlaySound_Open1to1Window", this->m_whisperOpenSound); - writer.Float("Outdoor_ViewLatitude", g_outdoorCameraPitch); - writer.Float("Outdoor_ViewDistance", g_outdoorCameraDistance); - writer.Float("Indoor_ViewLatitude", g_indoorCameraPitch); - writer.Float("Indoor_ViewDistance", g_indoorCameraDistance); - writer.String("SkinName", g_skinInfo.Name()); - writer.Integer("ChannelCopID", this->m_channelCopId); + this->WriteOptionInteger(output, "Trilinear", g_textureFiltering); + this->WriteOptionInteger(output, "Bgm_Volume", g_soundMgr->targetVolume); + this->WriteOptionInteger(output, "Effect_Volume", g_soundMgr->sampleVolume); + this->WriteOptionInteger(output, "AutoOpen1to1Window", this->m_autoOpenWhisperWindow); + this->WriteOptionInteger(output, "AutoOpen1to1Window_Friend", this->m_autoOpenFriendWhisperWindow); + this->WriteOptionInteger(output, "PlaySound_Open1to1Window", this->m_whisperOpenSound); + this->WriteOptionFloat(output, "Outdoor_ViewLatitude", g_outdoorCameraPitch); + this->WriteOptionFloat(output, "Outdoor_ViewDistance", g_outdoorCameraDistance); + this->WriteOptionFloat(output, "Indoor_ViewLatitude", g_indoorCameraPitch); + this->WriteOptionFloat(output, "Indoor_ViewDistance", g_indoorCameraDistance); + this->WriteOptionString(output, "SkinName", g_skinInfo.Name()); + this->WriteOptionInteger(output, "ChannelCopID", this->m_channelCopId); RECT rect; GetWindowRect(hWnd, &rect); - writer.Integer("Window_XPos", rect.left); - writer.Integer("Window_YPos", rect.top); - writer.Integer("Simplicity_SkillList", this->m_simplifiedSkillList); - writer.Integer("Show_SkillDescript", this->m_showSkillDescription); - writer.Integer("ChangeChatMode", g_windowCloseByte); - writer.Integer("LockMouse", this->m_lockMouse); - writer.Integer("ShowBattleFieldIcon", g_showBattleFieldIcon); - writer.Integer("MouseExclusive", g_serviceOptions.Get(ConfineCursor)); - writer.Integer("RenderSystemReset", g_renderSystemReset); - writer.Integer("RENDERSYSTEM", g_configuredRenderBackend); - writer.Guid("DX9DEVICEID", g_configuredDeviceGuid); - writer.String("DX9DEVICENAME", g_configuredDeviceName); - writer.Integer("ISFULLSCREENMODE", g_configuredFullscreen); - writer.Integer("WIDTH", g_configuredScreenWidth); - writer.Integer("HEIGHT", g_configuredScreenHeight); - writer.Integer("OLD_WIDTH", g_configuredScreenWidth); - writer.Integer("OLD_HEIGHT", g_configuredScreenHeight); - writer.Integer("BITPERPIXEL", g_configuredBitsPerPixel); - writer.Integer("DEVICECNT", g_configuredDeviceCount); - writer.Integer("MODECNT", g_configuredModeCount); - writer.Integer("SPRITEMODE", g_effectDetailLevel); - writer.Integer("TEXTUREMODE", g_textureDetailLevel); - writer.Integer("bLockItemDropFromItemWnd", this->m_lockItemDrop); - writer.Integer("bWarningPriceCheck", !this->m_skipPriceWarning); - writer.Integer("bSoundEffectInItemSellWnd", !this->m_muteSellSound); - writer.Integer("bGuildMemberListSort", this->m_guildMemberListSort != 0); - writer.Integer("bBlockPrivateTab", this->m_blockPrivateTab != 0); - writer.Integer("bShowMenuIcon", this->m_showMenuIcon != 0); - writer.Integer("bItemDefaultSort", this->m_itemDefaultSort != 0); - writer.Integer("bItemAscendingOrder", this->m_itemAscendingOrder != 0); - writer.Integer("bItemDescendingOrder", this->m_itemDescendingOrder != 0); - writer.Integer(LookupMessage(0xDC6), g_serviceOptions.Get(0xF3)); - writer.Integer("bExtendDamage", g_serviceOptions.Get(0x10B)); - writer.Integer("bShowMapName", g_serviceOptions.Get(0x10C)); - writer.Integer("bShowOnlyMineFootprint", g_serviceOptions.Get(0x10D)); - writer.Integer(LookupMessage(0xDB9), g_serviceOptions.Get(0xF1)); - writer.Integer("DamageSkin", this->m_damageSkinIndex); - writer.Integer("DamageDir", this->m_damageSkinMode); - writer.Integer("PriorityClass", this->m_priorityClass); - writer.Integer("bSummonTranslucent", g_serviceOptions.Get(0x10A)); - writer.Integer("bHidePlayer", g_serviceOptions.Get(0x109)); - writer.Integer("bQuickSlot", g_serviceOptions.Get(0x10E)); + this->WriteOptionInteger(output, "Window_XPos", rect.left); + this->WriteOptionInteger(output, "Window_YPos", rect.top); + this->WriteOptionInteger(output, "Simplicity_SkillList", this->m_simplifiedSkillList); + this->WriteOptionInteger(output, "Show_SkillDescript", this->m_showSkillDescription); + this->WriteOptionInteger(output, "ChangeChatMode", g_windowCloseByte); + this->WriteOptionInteger(output, "LockMouse", this->m_lockMouse); + this->WriteOptionInteger(output, "ShowBattleFieldIcon", g_showBattleFieldIcon); + this->WriteOptionInteger(output, "MouseExclusive", g_serviceOptions.Get(ConfineCursor)); + this->WriteOptionInteger(output, "RenderSystemReset", g_renderSystemReset); + this->WriteOptionInteger(output, "RENDERSYSTEM", g_configuredRenderBackend); + this->WriteOptionGuid(output, "DX9DEVICEID", g_configuredDeviceGuid); + this->WriteOptionString(output, "DX9DEVICENAME", g_configuredDeviceName); + this->WriteOptionInteger(output, "ISFULLSCREENMODE", g_configuredFullscreen); + this->WriteOptionInteger(output, "WIDTH", g_configuredScreenWidth); + this->WriteOptionInteger(output, "HEIGHT", g_configuredScreenHeight); + this->WriteOptionInteger(output, "OLD_WIDTH", g_configuredScreenWidth); + this->WriteOptionInteger(output, "OLD_HEIGHT", g_configuredScreenHeight); + this->WriteOptionInteger(output, "BITPERPIXEL", g_configuredBitsPerPixel); + this->WriteOptionInteger(output, "DEVICECNT", g_configuredDeviceCount); + this->WriteOptionInteger(output, "MODECNT", g_configuredModeCount); + this->WriteOptionInteger(output, "SPRITEMODE", g_effectDetailLevel); + this->WriteOptionInteger(output, "TEXTUREMODE", g_textureDetailLevel); + this->WriteOptionInteger(output, "bLockItemDropFromItemWnd", this->m_lockItemDrop); + this->WriteOptionInteger(output, "bWarningPriceCheck", !this->m_skipPriceWarning); + this->WriteOptionInteger(output, "bSoundEffectInItemSellWnd", !this->m_muteSellSound); + this->WriteOptionInteger(output, "bGuildMemberListSort", this->m_guildMemberListSort != 0); + this->WriteOptionInteger(output, "bBlockPrivateTab", this->m_blockPrivateTab != 0); + this->WriteOptionInteger(output, "bShowMenuIcon", this->m_showMenuIcon != 0); + this->WriteOptionInteger(output, "bItemDefaultSort", this->m_itemDefaultSort != 0); + this->WriteOptionInteger(output, "bItemAscendingOrder", this->m_itemAscendingOrder != 0); + this->WriteOptionInteger(output, "bItemDescendingOrder", this->m_itemDescendingOrder != 0); + this->WriteOptionInteger(output, LookupMessage(0xDC6), g_serviceOptions.Get(0xF3)); + this->WriteOptionInteger(output, "bExtendDamage", g_serviceOptions.Get(0x10B)); + this->WriteOptionInteger(output, "bShowMapName", g_serviceOptions.Get(0x10C)); + this->WriteOptionInteger(output, "bShowOnlyMineFootprint", g_serviceOptions.Get(0x10D)); + this->WriteOptionInteger(output, LookupMessage(0xDB9), g_serviceOptions.Get(0xF1)); + this->WriteOptionInteger(output, "DamageSkin", this->m_damageSkinIndex); + this->WriteOptionInteger(output, "DamageDir", this->m_damageSkinMode); + this->WriteOptionInteger(output, "PriorityClass", this->m_priorityClass); + this->WriteOptionInteger(output, "bSummonTranslucent", g_serviceOptions.Get(0x10A)); + this->WriteOptionInteger(output, "bHidePlayer", g_serviceOptions.Get(0x109)); + this->WriteOptionInteger(output, "bQuickSlot", g_serviceOptions.Get(0x10E)); output.Close(); } diff --git a/Source/Contents/Jobs/JobInheritance.cpp b/Source/Contents/Jobs/JobInheritance.cpp index 7dacfd10..aa6a89aa 100644 --- a/Source/Contents/Jobs/JobInheritance.cpp +++ b/Source/Contents/Jobs/JobInheritance.cpp @@ -51,56 +51,54 @@ const char g_playerNameKeyData[] = "가나다라마바사아자차카타파하 // GLOBAL: gl_24649 const char* g_playerNameKey = g_playerNameKeyData; -namespace { - // OFFSET: 0x00DFBC00 - // FUNCTION: fn_23585 - bool IsTreeGroupTwo(int job) { - if (job >= JT_RUNE_KNIGHT && job <= JT_MADOGEAR_B) { - return true; - } - - switch (job) { - case JT_PIG_GENETIC: - case JT_SHEEP_SURA: - case JT_SHEEP_ARCB: - case JT_FOX_SORCERER: - case JT_FOX_WARLOCK: - case JT_DOG_G_CROSS: - case JT_DOG_CHASER: - case JT_OSTRICH_MINSTREL: - case JT_OSTRICH_WANDER: - case JT_FOX_WARLOCK_B: - case JT_SHEEP_ARCB_B: - case JT_DOG_G_CROSS_B: - case JT_FOX_SORCERER_B: - case JT_OSTRICH_MINSTREL_B: - case JT_OSTRICH_WANDER_B: - case JT_SHEEP_SURA_B: - case JT_PIG_GENETIC_B: - case JT_DOG_CHASER_B: - case JT_PIG_MECHANIC: - case JT_OSTRICH_RANGER: - case JT_LION_ROYAL_GUARD: - case JT_LION_RUNE_KNIGHT: - case JT_PIG_MECHANIC_B: - case JT_OSTRICH_RANGER_B: - case JT_LION_ROYAL_GUARD_B: - case JT_LION_RUNE_KNIGHT_B: - return true; - default: - return false; - } +// OFFSET: 0x00DFBC00 +// FUNCTION: fn_23585 +__declspec(noinline) bool CSession::IsTreeGroupTwo(int job) const { + if (job >= JT_RUNE_KNIGHT && job <= JT_MADOGEAR_B) { + return true; } - // OFFSET: 0x00DFBCA0 - // FUNCTION: fn_23586 - bool IsTreeGroupThree(int job) { - const auto value = static_cast(job); - return value - JT_DRAGON_KNIGHT <= unsigned(JT_FOURTH_JOB_END - JT_DRAGON_KNIGHT) || - value - JT_SKY_EMPEROR <= unsigned(JT_UPPER_EXTENDED_JOB2_END - 1 - JT_SKY_EMPEROR) || job == JT_ALITEA || job == JT_ALITEA_RIDING; + switch (job) { + case JT_PIG_GENETIC: + case JT_SHEEP_SURA: + case JT_SHEEP_ARCB: + case JT_FOX_SORCERER: + case JT_FOX_WARLOCK: + case JT_DOG_G_CROSS: + case JT_DOG_CHASER: + case JT_OSTRICH_MINSTREL: + case JT_OSTRICH_WANDER: + case JT_FOX_WARLOCK_B: + case JT_SHEEP_ARCB_B: + case JT_DOG_G_CROSS_B: + case JT_FOX_SORCERER_B: + case JT_OSTRICH_MINSTREL_B: + case JT_OSTRICH_WANDER_B: + case JT_SHEEP_SURA_B: + case JT_PIG_GENETIC_B: + case JT_DOG_CHASER_B: + case JT_PIG_MECHANIC: + case JT_OSTRICH_RANGER: + case JT_LION_ROYAL_GUARD: + case JT_LION_RUNE_KNIGHT: + case JT_PIG_MECHANIC_B: + case JT_OSTRICH_RANGER_B: + case JT_LION_ROYAL_GUARD_B: + case JT_LION_RUNE_KNIGHT_B: + return true; + default: + return false; } } +// OFFSET: 0x00DFBCA0 +// FUNCTION: fn_23586 +__declspec(noinline) bool CSession::IsTreeGroupThree(int job) const { + const auto value = static_cast(job); + return value - JT_DRAGON_KNIGHT <= unsigned(JT_FOURTH_JOB_END - JT_DRAGON_KNIGHT) || + value - JT_SKY_EMPEROR <= unsigned(JT_UPPER_EXTENDED_JOB2_END - 1 - JT_SKY_EMPEROR) || job == JT_ALITEA || job == JT_ALITEA_RIDING; +} + // OFFSET: 0x00DFA600 // FUNCTION: fn_23576 bool CSession::IsNpcJob(int job) const { @@ -664,33 +662,33 @@ bool __stdcall IsPlayerJob(int job) { // OFFSET: 0x00E19110 // FUNCTION: fn_23835 -int JobInheritance::Lookup(int job) { - const int inherited = this->script.TableInteger("JobInheritTable", 0, job); - const int replacement = this->script.TableInteger("JOB_INHERIT_LIST2", 0, inherited); +int CSession::InheritedJob(int job) { + const int inherited = this->m_hotkeyScript->TableInteger("JobInheritTable", 0, job); + const int replacement = this->m_hotkeyScript->TableInteger("JOB_INHERIT_LIST2", 0, inherited); return replacement == -1 ? inherited : replacement; } // OFFSET: 0x00E25B70 // FUNCTION: fn_23907 -void JobInheritance::InitializeSkillTree(CPlayerSkillBundle& bundle, int job) { +void CSession::InitializeSkillTree() { int count = 0; - if (!this->script.Call("GetInheritJob", "d>d", job, &count) || count == -1) { + if (!this->m_hotkeyScript->Call("GetInheritJob", "d>d", this->m_job, &count) || count == -1) { return; } - bundle.ClearGroups(); - bundle.ClearExtra(); - bundle.ClearLevelChanges(); + this->m_skillBundle.ClearGroups(); + this->m_skillBundle.ClearExtra(); + this->m_skillBundle.ClearLevelChanges(); for (int index = count; index > 0; --index) { - const int inherited = this->Lookup(index); + const int inherited = this->InheritedJob(index); int group = 1; - if (inherited == JT_NOVICE || this->Lookup(index + 1) == JT_NOVICE || inherited == JT_DO_SUMMONER || inherited == JT_DO_SUMMONER_B) { + if (inherited == JT_NOVICE || this->InheritedJob(index + 1) == JT_NOVICE || inherited == JT_DO_SUMMONER || inherited == JT_DO_SUMMONER_B) { group = 0; - } else if (IsTreeGroupTwo(inherited) || inherited == JT_STAR_EMPEROR || inherited == JT_SOUL_REAPER || inherited == JT_STAR_EMPEROR_B || + } else if (this->IsTreeGroupTwo(inherited) || inherited == JT_STAR_EMPEROR || inherited == JT_SOUL_REAPER || inherited == JT_STAR_EMPEROR_B || inherited == JT_SOUL_REAPER_B) { group = 2; - } else if (IsTreeGroupThree(inherited)) { + } else if (this->IsTreeGroupThree(inherited)) { group = 3; } @@ -713,7 +711,7 @@ void JobInheritance::InitializeSkillTree(CPlayerSkillBundle& bundle, int job) { break; } - this->script.Call("InitSkillTreeView", "dd", inherited, group); + this->m_hotkeyScript->Call("InitSkillTreeView", "dd", inherited, group); } } @@ -1833,10 +1831,10 @@ bool CSession::PlaySkillGroundEffect(int skillId, vector3d position) { // OFFSET: 0x00E2F9F0 // FUNCTION: fn_24162 int CSession::GetMaxBaseLevel(int job) const { - if (IsTreeGroupThree(job) == true) { + if (g_session.IsTreeGroupThree(job) == true) { return *reinterpret_cast(&g_session.unknown_7EF0[0x74]); } - if (IsTreeGroupTwo(job)) { + if (g_session.IsTreeGroupTwo(job)) { return g_session.m_maxLevel; } if (g_session.IsSuperNovice2Job(job)) { @@ -1862,10 +1860,10 @@ int CSession::GetMaxJobLevel(int job) const { if (job == JT_NOVICE || job == JT_NOVICE_B || job == JT_NOVICE_H) { return *reinterpret_cast(&g_session.unknown_7EF0[0x0C]); } - if (IsTreeGroupThree(job) == true) { + if (g_session.IsTreeGroupThree(job) == true) { return *reinterpret_cast(&g_session.unknown_7EF0[0x78]); } - if (IsTreeGroupTwo(job)) { + if (g_session.IsTreeGroupTwo(job)) { return *reinterpret_cast(&g_session.unknown_7EF0[0x1C]); } if (!g_session.IsExpandedJob(job)) { diff --git a/Source/Contents/Jobs/JobInheritance.h b/Source/Contents/Jobs/JobInheritance.h index 97b0a089..ce9d88a6 100644 --- a/Source/Contents/Jobs/JobInheritance.h +++ b/Source/Contents/Jobs/JobInheritance.h @@ -1,17 +1,6 @@ #ifndef RAGNAROK_SOURCE_CONTENTS_JOBS_JOBINHERITANCE_H #define RAGNAROK_SOURCE_CONTENTS_JOBS_JOBINHERITANCE_H -class LuaScript; -class CPlayerSkillBundle; - -struct JobInheritance { - LuaScript& script; - - int Lookup(int job); - - void InitializeSkillTree(CPlayerSkillBundle& bundle, int job); -}; - #include #include diff --git a/Source/Contents/Sound/SoundMgr.cpp b/Source/Contents/Sound/SoundMgr.cpp index 905201c1..dc1e11c7 100644 --- a/Source/Contents/Sound/SoundMgr.cpp +++ b/Source/Contents/Sound/SoundMgr.cpp @@ -26,7 +26,7 @@ namespace { // OFFSET: 0x00638A90 // FUNCTION: fn_45421 -CSoundMgr::CSoundMgr(SoundMgrContext& context) : m_context(&context) { +CSoundMgr::CSoundMgr() { if (this->Initialize()) { this->initialized = 1; } @@ -101,7 +101,7 @@ bool CSoundMgr::Initialize() { this->providers[i] = 0; } - SoundConfiguration& configuration = this->m_context->configuration; + SoundConfiguration& configuration = g_soundConfiguration; if (configuration.mode == 0) { return true; @@ -204,12 +204,12 @@ bool CSoundMgr::Initialize() { // OFFSET: 0x00639350 // FUNCTION: fn_04751 -bool CSoundMgr::Create(SoundMgrContext& context) { +bool CSoundMgr::Create() { if (g_soundMgr) { return false; } - g_soundMgr = new (std::nothrow) CSoundMgr(context); + g_soundMgr = new (std::nothrow) CSoundMgr(); if (!g_soundMgr) { return false; @@ -249,7 +249,7 @@ void CSoundMgr::Update() { // OFFSET: 0x006396B0 // FUNCTION: fn_45423 void CSoundMgr::Shutdown() { - if (this->m_context->configuration.mode == 0) { + if (g_soundConfiguration.mode == 0) { return; } @@ -364,7 +364,7 @@ int CSoundMgr::Volume(const CSoundMgr* sound) { // OFFSET: 0x00639A70 // FUNCTION: fn_04757 bool CSoundMgr::IsComplete() const { - if (this->m_context->configuration.mode == 0 || !this->stream || !this->secondaryStream || this->fadeExit != 0) { + if (g_soundConfiguration.mode == 0 || !this->stream || !this->secondaryStream || this->fadeExit != 0) { return false; } @@ -447,7 +447,7 @@ bool CSoundMgr::PlayData3D(const void* data, const float& x, const float& y, con void CSoundMgr::SetDefaultName(std::string name) { this->defaultName = name; - if (this->m_context->serviceOptions.Get(7)) { + if (g_serviceOptions.Get(7)) { this->PlayStream(nullptr, 0, false); } @@ -507,7 +507,7 @@ bool CSoundMgr::PlayData2D(const void* data, const float& x, const float& y, con // OFFSET: 0x00639F00 // FUNCTION: fn_04763 void CSoundMgr::PlayStream(const char* name, int loopCount, bool fade) { - if (this->m_context->configuration.mode == 0) { + if (g_soundConfiguration.mode == 0) { return; } @@ -551,9 +551,9 @@ void CSoundMgr::PlayStream(const char* name, int loopCount, bool fade) { // OFFSET: 0x0063A130 // FUNCTION: fn_04764 void CSoundMgr::PlayWave(const char* name, float x, float y, float z, int maximumDistance, int minimumDistance, float scale, int unused) { - const unsigned char enabled = this->m_context->serviceOptions.Get(11); + const unsigned char enabled = g_serviceOptions.Get(11); - if (this->m_context->configuration.mode == 0 || !enabled) { + if (g_soundConfiguration.mode == 0 || !enabled) { return; } @@ -563,15 +563,15 @@ void CSoundMgr::PlayWave(const char* name, float x, float y, float z, int maximu return; } - CWave* wave = static_cast(this->m_context->resources.Load(name)); + CWave* wave = static_cast(ResourceMgr::Instance().Load(name)); if (!wave) { return; } - if (this->m_context->configuration.mode == 1) { + if (g_soundConfiguration.mode == 1) { this->PlayData2D(wave->data, x, y, z, maximumDistance, minimumDistance, scale); - } else if (this->m_context->configuration.mode == 2) { + } else if (g_soundConfiguration.mode == 2) { this->PlayData3D(wave->data, x, y, z, maximumDistance, minimumDistance, scale); } } diff --git a/Source/Contents/Sound/SoundMgr.h b/Source/Contents/Sound/SoundMgr.h index 859b13f3..d0270a9e 100644 --- a/Source/Contents/Sound/SoundMgr.h +++ b/Source/Contents/Sound/SoundMgr.h @@ -12,18 +12,12 @@ class ResourceMgr; struct ServiceOptions; struct SoundConfiguration; -struct SoundMgrContext { - SoundConfiguration& configuration; - const ServiceOptions& serviceOptions; - ResourceMgr& resources; -}; - class CSoundMgr { public: - explicit CSoundMgr(SoundMgrContext& context); + CSoundMgr(); virtual ~CSoundMgr(); - static bool Create(SoundMgrContext& context); + static bool Create(); static void Destroy(); void FadeIn(); @@ -91,8 +85,6 @@ public: private: static unsigned __stdcall FadeThread(void* direction); - - SoundMgrContext* m_context; }; extern CSoundMgr* g_soundMgr; @@ -134,7 +126,7 @@ static_assert(offsetof(CSoundMgr, fadePending) == 0x414); static_assert(offsetof(CSoundMgr, reopenPending) == 0x415); static_assert(offsetof(CSoundMgr, unknown_0416) == 0x0416); static_assert(offsetof(CSoundMgr, fadeExit) == 0x418); -static_assert(sizeof(CSoundMgr) == 0x420); +static_assert(sizeof(CSoundMgr) == 0x41C); #endif #endif diff --git a/Source/Contents/Store/MCStoreInfoBackup.cpp b/Source/Contents/Store/MCStoreInfoBackup.cpp index 88748081..dfc2a264 100644 --- a/Source/Contents/Store/MCStoreInfoBackup.cpp +++ b/Source/Contents/Store/MCStoreInfoBackup.cpp @@ -2,7 +2,6 @@ #include "Contents/Async/AsyncWorkMgr.h" #include "Contents/Store/MCStoreInfoBackup.h" #include "Contents/MessageTable.h" -#include "Contents/Store/StoreBackupData.h" #include "Client/Session.h" #include "UI/Window/UIWindowMgr.h" #include "Utility/Async/AsyncDiagnostic.h" @@ -138,7 +137,7 @@ void CMCStoreInfoBackup::CompleteLoad( if (type == 1) { Json::Value& data = root["data"]; - StoreBackupData{this->title, this->items}.Import(data); + this->ImportData(data); if (!data["Item"].isNull() || !this->title.empty()) { context.RefreshShop(); @@ -196,7 +195,7 @@ void CMCStoreInfoBackup::Save(int type) { this->type = type; Json::Value root; Json::Value data; - StoreBackupData{this->title, this->items}.Export(data, g_session.unknown_1758); + this->ExportData(data); if (!data.isNull()) { root["data"] = data; diff --git a/Source/Contents/Store/MCStoreInfoBackup.h b/Source/Contents/Store/MCStoreInfoBackup.h index e06f89f1..aec39cc4 100644 --- a/Source/Contents/Store/MCStoreInfoBackup.h +++ b/Source/Contents/Store/MCStoreInfoBackup.h @@ -43,6 +43,8 @@ public: StoreBackupContext& context ); void Save(int type); + void ImportData(Json::Value& data); + void ExportData(Json::Value& data) const; /* 0004 */ bool enabled; /* 0005 */ bool loaded; diff --git a/Source/Contents/Store/StoreBackupData.cpp b/Source/Contents/Store/StoreBackupData.cpp index 3a58d514..b49b0804 100644 --- a/Source/Contents/Store/StoreBackupData.cpp +++ b/Source/Contents/Store/StoreBackupData.cpp @@ -1,4 +1,5 @@ -#include "Contents/Store/StoreBackupData.h" +#include "Contents/Store/MCStoreInfoBackup.h" +#include "Client/Session.h" #include "Network/TextEncoding.h" #include @@ -8,7 +9,7 @@ // OFFSET: 0x00606190 // FUNCTION: fn_04233 -void StoreBackupData::Import(Json::Value& data) { +void CMCStoreInfoBackup::ImportData(Json::Value& data) { this->items.clear(); this->title = FromUtf8(data.get("Title", "").asString(), g_textCodePage); Json::Value values = data["Item"]; @@ -56,11 +57,11 @@ void StoreBackupData::Import(Json::Value& data) { // OFFSET: 0x00607240 // FUNCTION: fn_04238 -void StoreBackupData::Export(Json::Value& data, const std::list& storeItems) const { +void CMCStoreInfoBackup::ExportData(Json::Value& data) const { data["Title"] = ToUtf8(this->title, g_textCodePage); Json::Value values; - for (const ITEM_INFO& item : storeItems) { + for (const ITEM_INFO& item : g_session.unknown_1758) { Json::Value value; value["ID"] = std::atoi(item.itemId.c_str()); value["Count"] = item.quantity; diff --git a/Source/Contents/Store/StoreBackupData.h b/Source/Contents/Store/StoreBackupData.h deleted file mode 100644 index c408dacc..00000000 --- a/Source/Contents/Store/StoreBackupData.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef RAGNAROK_SOURCE_CONTENTS_STORE_STOREBACKUPDATA_H -#define RAGNAROK_SOURCE_CONTENTS_STORE_STOREBACKUPDATA_H - -#include "Contents/Items/ItemInfo.h" - -#include -#include - -namespace Json { - class Value; -} - -struct StoreBackupData { - std::string& title; - std::vector& items; - - void Import(Json::Value& data); - void Export(Json::Value& data, const std::list& storeItems) const; -}; - -#endif diff --git a/Source/UI/Chat/ChatSuggestions.cpp b/Source/UI/Chat/ChatSuggestions.cpp index 4ff21218..8668a97b 100644 --- a/Source/UI/Chat/ChatSuggestions.cpp +++ b/Source/UI/Chat/ChatSuggestions.cpp @@ -2,7 +2,7 @@ #include "UI/Chat/UINewChatWnd.h" #include "UI/Chat/UISubChatHisWnd.h" #include "UI/Window/InputFocus.h" -#include "UI/Edit/ItemTagRetirement.h" +#include "UI/Edit/UIItemTagCtrl.h" #include "UI/Edit/UIEditCtrl.h" #include "UI/Window/UIWindow.h" #include "UI/Lists/UIChatHisBox.h" @@ -207,6 +207,6 @@ void UINewChatWnd::ToggleInput() { } if (UIItemTagOnChat* tags = static_cast(this->m_chatEdit)->unknown_0144) { - reinterpret_cast(tags)->Clear(); + tags->ClearTags(); } } diff --git a/Source/UI/Edit/ItemTagRetirement.cpp b/Source/UI/Edit/ItemTagRetirement.cpp index 2de1a931..a2eaecbe 100644 --- a/Source/UI/Edit/ItemTagRetirement.cpp +++ b/Source/UI/Edit/ItemTagRetirement.cpp @@ -76,7 +76,7 @@ UIItemTagOnMegaPhone::UIItemTagOnMegaPhone() { // OFFSET: 0x00870DF0 // FUNCTION: fn_11104 UIItemTagCtrl::~UIItemTagCtrl() { - reinterpret_cast(this)->Clear(); + this->ClearTags(); } // OFFSET: 0x00879830 @@ -84,7 +84,7 @@ UIItemTagCtrl::~UIItemTagCtrl() { bool UIItemTagOnChat::CanInsertTag(const std::string& name, int width) { if (g_windowMgr.GetHoverWindow()->geometry.id != 490 && g_windowMgr.GetHoverWindow()->geometry.id != 494 && !g_windowMgr.unknown_0024) { - reinterpret_cast(this)->Clear(); + this->ClearTags(); return false; } @@ -150,7 +150,7 @@ bool UIItemTagCtrl::SyncTagsWithText() { } } - reinterpret_cast(this)->Clear(); + this->ClearTags(); this->tags.swap(kept); return true; } @@ -173,11 +173,13 @@ void UIItemTagOnMegaPhone::RemoveTagChild(UIWindow* child) { // OFFSET: 0x0087A2F0 // FUNCTION: fn_11231 -void ItemTagRetirement::Clear() { - for (auto entry = this->records.begin(); entry != this->records.end();) { - this->removal.Remove(entry->child); - entry = this->records.erase(entry); +void UIItemTagCtrl::ClearTags() { + for (auto entry = this->tags.begin(); entry != this->tags.end();) { + this->RemoveTagChild(entry->child); + entry = this->tags.erase(entry); } + + this->tags.clear(); } // OFFSET: 0x00879820 diff --git a/Source/UI/Edit/ItemTagRetirement.h b/Source/UI/Edit/ItemTagRetirement.h index 655b48b6..6a15369d 100644 --- a/Source/UI/Edit/ItemTagRetirement.h +++ b/Source/UI/Edit/ItemTagRetirement.h @@ -15,21 +15,6 @@ struct ItemTagRecord { /* 01C4 */ int index; }; -class ItemTagRemoval { -public: - virtual void Remove(UIWindow* child) = 0; - -protected: - ~ItemTagRemoval() = default; -}; - -struct ItemTagRetirement { - std::list& records; - ItemTagRemoval& removal; - - void Clear(); -}; - #if defined(_WIN32) && !defined(_WIN64) static_assert(sizeof(ItemTagRecord) == 456); static_assert(offsetof(ItemTagRecord, child) == 0x0000); diff --git a/Source/UI/Edit/UIItemTagCtrl.h b/Source/UI/Edit/UIItemTagCtrl.h index 989c292c..16b0ec8f 100644 --- a/Source/UI/Edit/UIItemTagCtrl.h +++ b/Source/UI/Edit/UIItemTagCtrl.h @@ -20,6 +20,7 @@ public: virtual void RemoveTagChild(UIWindow* child); virtual void PlaceTagButton(UIWindow* button, const std::string& name, const int& x, int unused) = 0; + void ClearTags(); std::string AppendTag(const std::string& name); int MeasureText(const std::string& text, const unsigned& bytes); bool SyncTagsWithText(); diff --git a/Source/UI/Rodex/UIRodexComposeWnd.cpp b/Source/UI/Rodex/UIRodexComposeWnd.cpp index 2260a0e1..63dd5d19 100644 --- a/Source/UI/Rodex/UIRodexComposeWnd.cpp +++ b/Source/UI/Rodex/UIRodexComposeWnd.cpp @@ -9,7 +9,7 @@ #include "Client/Session.h" #include "File/ShortcutFilename.h" #include "UI/Buttons/UIBmpTextButton.h" -#include "UI/Edit/ItemTagRetirement.h" +#include "UI/Edit/UIItemTagCtrl.h" #include "UI/Edit/UIItemTagCtrl.h" #include "UI/Text/UIStaticText.h" #include "Utility/Text/FormatString.h" @@ -246,7 +246,7 @@ UIRodexComposeWnd::UIRodexComposeWnd() // INLINED UIRodexComposeWnd::~UIRodexComposeWnd() { if (this->unknown_0100) { - reinterpret_cast(this->unknown_0100)->Clear(); + static_cast(this->unknown_0100)->ClearTags(); delete this->unknown_0100; } } diff --git a/Source/UI/Shortcuts/ShortcutPainting.h b/Source/UI/Shortcuts/ShortcutPainting.h index 7e47cb22..466636fe 100644 --- a/Source/UI/Shortcuts/ShortcutPainting.h +++ b/Source/UI/Shortcuts/ShortcutPainting.h @@ -10,8 +10,6 @@ class UIWindow; class ResourceMgr; -class FontCache; -struct TextLocale; struct ShortcutPainting { RenderCommandPool& commands; diff --git a/Source/UI/Shortcuts/UIQuickSlotWnd.h b/Source/UI/Shortcuts/UIQuickSlotWnd.h index 65be161a..e6917510 100644 --- a/Source/UI/Shortcuts/UIQuickSlotWnd.h +++ b/Source/UI/Shortcuts/UIQuickSlotWnd.h @@ -7,8 +7,6 @@ #include #include -class FontCache; -struct TextLocale; struct ITEM_INFO; class AutomaticSkills;