diff --git a/Source/Client/Session.h b/Source/Client/Session.h index fb058652..9c7d5875 100644 --- a/Source/Client/Session.h +++ b/Source/Client/Session.h @@ -233,7 +233,8 @@ public: /* 52B8 */ std::vector m_accessoryNames; /* 52C4 */ std::vector m_robeNames; /* 52D0 */ std::vector m_navigationForbiddenMaps; - /* 52DC */ unsigned char unknown_52DC[0x16C]; + /* 52DC */ std::vector> m_commandOptions; + /* 52E8 */ unsigned char unknown_52E8[0x160]; /* 5448 */ int unknown_5448; /* 544C */ unsigned char unknown_544C[0x04]; /* 5450 */ int unknown_5450; @@ -794,6 +795,7 @@ static_assert(offsetof(CSession, unknown_3500) == 0x3500); static_assert(offsetof(CSession, m_accessoryNames) == 0x52B8); static_assert(offsetof(CSession, m_robeNames) == 0x52C4); static_assert(offsetof(CSession, m_navigationForbiddenMaps) == 0x52D0); +static_assert(offsetof(CSession, m_commandOptions) == 0x52DC); static_assert(offsetof(CSession, unknown_5558) == 0x5558); static_assert(offsetof(CSession, m_hotkeyScript) == 0x59D8); static_assert(offsetof(CSession, unknown_5C68) == 0x5C68); diff --git a/Source/Contents/Configuration/ServiceOptions.h b/Source/Contents/Configuration/ServiceOptions.h index d846d480..f5ada8ca 100644 --- a/Source/Contents/Configuration/ServiceOptions.h +++ b/Source/Contents/Configuration/ServiceOptions.h @@ -2,12 +2,18 @@ #define RAGNAROK_SOURCE_CONTENTS_CONFIGURATION_SERVICEOPTIONS_H #include "Contents/Skills/PlayerSkillBundle.h" +#include "Utility/Singleton.h" #include +#include enum ServiceOption : int { ConfineCursor = 271 }; +class CGameSettingsMgr; + bool IsServiceOption(int id); +std::pair FindServiceOption(const char* name); +int SetOption(const char* name, unsigned char value); struct ServiceOptions { /* 0000 */ std::unordered_map values; diff --git a/Source/Script/LuaScript.cpp b/Source/Script/LuaScript.cpp index ee8aa4b7..c867d9b8 100644 --- a/Source/Script/LuaScript.cpp +++ b/Source/Script/LuaScript.cpp @@ -1,6 +1,7 @@ #include "Script/LuaScript.h" #include "Archive/PakRegistry.h" #include "Client/Session.h" +#include "Contents/Configuration/ServiceOptions.h" #include "Contents/EntryQueueMgr.h" #include "Contents/Effects/EffectLists.h" #include "Contents/Effects/EffectTypes.h" @@ -11,6 +12,7 @@ #include "File/ResourcePath.h" #include "Script/LuaFileOperations.h" #include "UI/UICheckAttendanceWnd.h" +#include "UI/UILapineScrollBar.h" #include "UI/UILapineUpgradeBoxWnd.h" #include "UI/Window/UIWindowMgr.h" @@ -157,16 +159,27 @@ int SetSubChatWndOption(lua_State* state) { // OFFSET: 0x00AFF020 // FUNCTION: fn_18351 int SetCmdOnOffList(lua_State* state) { - luaL_checkstring(state, 1); - luaL_checknumber(state, 2); + const char* name = luaL_checkstring(state, 1); + const bool enabled = luaL_checknumber(state, 2) != 0.0; + Singleton::GetInstance(); + const int optionId = SetOption(name, enabled); + if (optionId != 3) { + if (optionId == 229) { + const int value = enabled; + std::memcpy(g_session.unknown_5454, &value, sizeof(value)); + } + g_session.m_commandOptions.emplace_back(name, optionId); + } return 0; } // OFFSET: 0x00AFEF50 // FUNCTION: fn_18350 int GetCmdOnOffValue(lua_State* state) { - luaL_checkstring(state, 1); - lua_pushnumber(state, 0.0); + const char* name = luaL_checkstring(state, 1); + Singleton::GetInstance(); + const auto option = FindServiceOption(name); + lua_pushnumber(state, option.first == 3 ? -1.0 : static_cast(option.second != 0)); return 1; } @@ -679,9 +692,11 @@ int AddEntryQueue(lua_State* state) { // OFFSET: 0x00AFFF60 // FUNCTION: fn_18358 int AddIngredient(lua_State* state) { - luaL_checknumber(state, 1); - luaL_checknumber(state, 2); - g_windowMgr.LookupWindow(0x122); + const int id = static_cast(luaL_checknumber(state, 1)); + const int quantity = static_cast(luaL_checknumber(state, 2)); + if (UIWindow* window = g_windowMgr.LookupWindow(0x122)) { + static_cast(window)->AddMaterial(id, quantity); + } return 0; }