Maintenance: [forced, user-approved] Family G15: remove ScriptOptions (reference view over g_session.m_hotkeyScript) and the unused G

Batch #10221 by ragnarok-clanker: forced by an admin (3 lower score(s), 7 changed function(s)); checked with 230 compiled unit(s), including every includer of Source/Client/Session.h, Source/Contents/Configuration/GameSettingsMgr.h, Source/Contents/Configuration/GraphicsConfiguration.h.
Deletes: Source/Contents/Configuration/GraphicsConfiguration.h
This commit is contained in:
ragnarok-clanker 2026-11-03 00:44:20 +00:00
commit e757db50e0
7 changed files with 70 additions and 165 deletions

View file

@ -936,7 +936,6 @@ void IgnoreNull();
LSTATUS SaveDisplayDeviceSettings();
#include "Render/DX7/RenderSystemDX7.h"
#include "Contents/Configuration/ScriptOptions.h"
// OFFSET: 0x00E58100
// FUNCTION: fn_24362
@ -972,12 +971,12 @@ int sub_E58100(HINSTANCE instance, int showCommand) {
int defaultX = (GetSystemMetrics(SM_CXSCREEN) - g_viewportWidth) / 2;
const std::uint8_t xSource[] = {0x78, 0xF6, 0xDD, 0xBF, 0x80, 0xBE, 0x48, 0xC3, 0x7F, 0xF0, 0xC0, 0xDB};
thread_local EncryptedName<sizeof(xSource), 0x9B17C9EFDBB39F2FULL> xName(xSource);
x = ScriptOptions{*g_session.m_hotkeyScript}.Integer(xName.Text(), defaultX);
x = g_session.GetOptionInteger(xName.Text(), defaultX);
int defaultY = (GetSystemMetrics(SM_CYSCREEN) - g_viewportHeight) / 2;
const std::uint8_t ySource[] = {0x3A, 0x5A, 0x61, 0xF1, 0xB4, 0x32, 0x8C, 0x30, 0x3D, 0x5C, 0x7C, 0x95};
thread_local EncryptedName<sizeof(ySource), 0x69D345DB950F336DULL> yName(ySource);
y = ScriptOptions{*g_session.m_hotkeyScript}.Integer(yName.Text(), defaultY);
y = g_session.GetOptionInteger(yName.Text(), defaultY);
} else {
x = (GetSystemMetrics(SM_CXSCREEN) - g_viewportWidth) / 2;
y = (GetSystemMetrics(SM_CYSCREEN) - g_viewportHeight) / 2;

View file

@ -13,6 +13,8 @@
#include "UI/Cooldowns/CooldownState.h"
#include "UI/Shortcuts/ShortcutCooldowns.h"
#include <windows.h>
#include <cstddef>
#include <cstdint>
#include <cstring>
@ -860,6 +862,9 @@ public:
void LoadExternalSettings();
void ReloadLanguageTables();
float GetOptionFloat(const char* key, float fallback);
int GetOptionInteger(const char* key, int fallback);
std::string GetOptionString(const char* key, const char* fallback);
GUID GetOptionGuid(const char* key, const GUID& fallback);
std::string GetAccessoryName(int id);
std::string GetWeaponName(int weapon);
const char* GetWeaponClassName(int item);

View file

@ -14,8 +14,6 @@
#include <unordered_map>
#include <vector>
struct ScriptOptions;
struct GameSettingsOption {
/* 0000 */ int id = 300;
/* 0004 */ int tab;
@ -45,7 +43,7 @@ public:
void ResetToDefaults();
void ToggleOption(int id);
void sub_6C0C40(int id, unsigned char value, bool notify);
void ApplyScriptOption(int id, const char* key, ScriptOptions& script);
void ApplyScriptOption(int id, const char* key);
bool RunFunction(int id);
std::optional<GameSettingsOption*> FindOption(int id);
std::list<int> GetOptionIds(int tab);

View file

@ -1,92 +0,0 @@
#ifndef RAGNAROK_SOURCE_CONTENTS_CONFIGURATION_GRAPHICSCONFIGURATION_H
#define RAGNAROK_SOURCE_CONTENTS_CONFIGURATION_GRAPHICSCONFIGURATION_H
#include "Contents/Configuration/OptionWriter.h"
#include "Contents/Configuration/ScriptOptions.h"
#include "Render/RenderAdapter.h"
#include "Script/LuaScript.h"
#include <algorithm>
#include <windows.h>
struct GraphicsConfiguration {
GUID drawGuid;
GUID renderGuid;
int fullscreen;
int width;
int height;
int bitsPerPixel;
int oldWidth;
int oldHeight;
int reset;
int backend;
GUID deviceGuid;
char deviceName[32];
void Load(LuaScript& script, ScriptOptions& options, int& screenWidth, int& screenHeight);
AdapterConfiguration Adapter() const;
void Save(OptionWriter& output) const;
};
// INLINED
inline void GraphicsConfiguration::Load(LuaScript& script, ScriptOptions& options, int& screenWidth, int& screenHeight) {
const int resetPolicy = std::max(script.GlobalInteger("RenderSystemReset"), 0);
const int backendPolicy = std::max(script.GlobalInteger("RenderSystemDefault"), 0);
this->reset = options.Integer("RenderSystemReset", 1);
if (this->reset != resetPolicy) {
this->backend = backendPolicy;
this->reset = resetPolicy;
} else {
this->backend = options.Integer("RENDERSYSTEM", backendPolicy);
}
this->deviceGuid = options.Guid("DX9DEVICEID", GUID{});
const std::string name = options.String("DX9DEVICENAME", "");
strncpy_s(this->deviceName, sizeof(this->deviceName), name.c_str(), _TRUNCATE);
this->fullscreen = options.Integer("ISFULLSCREENMODE", 0);
this->width = options.Integer("WIDTH", 1024);
this->height = options.Integer("HEIGHT", 768);
this->oldWidth = options.Integer("OLD_WIDTH", 0);
this->oldHeight = options.Integer("OLD_HEIGHT", 0);
if (static_cast<unsigned>(this->height) < 664) {
this->width = 1024;
this->height = 768;
}
screenWidth = this->width;
screenHeight = this->height;
this->bitsPerPixel = options.Integer("BITPERPIXEL", 16);
OSVERSIONINFOA version{};
version.dwOSVersionInfoSize = sizeof(version);
GetVersionExA(&version);
if (version.dwMajorVersion >= 6 && version.dwMinorVersion >= 2) {
this->bitsPerPixel = 32;
}
}
// INLINED
inline AdapterConfiguration GraphicsConfiguration::Adapter() const {
return {this->backend, this->drawGuid, this->renderGuid, this->deviceGuid, this->deviceName};
}
// INLINED
inline void GraphicsConfiguration::Save(OptionWriter& output) const {
output.Integer("RenderSystemReset", this->reset);
output.Integer("RENDERSYSTEM", this->backend);
output.Guid("DX9DEVICEID", this->deviceGuid);
output.String("DX9DEVICENAME", this->deviceName);
output.Integer("ISFULLSCREENMODE", this->fullscreen);
output.Integer("WIDTH", this->width);
output.Integer("HEIGHT", this->height);
output.Integer("OLD_WIDTH", this->width);
output.Integer("OLD_HEIGHT", this->height);
output.Integer("BITPERPIXEL", this->bitsPerPixel);
}
#endif

View file

@ -1,4 +1,3 @@
#include "Contents/Configuration/ScriptOptions.h"
#include "Script/LuaScript.h"
#include "Utility/GuidParse.h"
#include "Client/Session.h"
@ -6,25 +5,25 @@
// OFFSET: 0x00E0A890
// FUNCTION: fn_23800
int ScriptOptions::Integer(const char* key, int fallback) {
int CSession::GetOptionInteger(const char* key, int fallback) {
int value = -1;
this->script.Call("l_GetOptionValue", "s>d", key, &value);
this->m_hotkeyScript->Call("l_GetOptionValue", "s>d", key, &value);
return value == -1 ? fallback : value;
}
// OFFSET: 0x00E0A950
// FUNCTION: fn_23801
std::string ScriptOptions::String(const char* key, const char* fallback) {
std::string CSession::GetOptionString(const char* key, const char* fallback) {
const char* value = nullptr;
this->script.Call("l_GetOptionValue", "s>s", key, &value);
this->m_hotkeyScript->Call("l_GetOptionValue", "s>s", key, &value);
return !value || std::strcmp(value, "-1") == 0 ? fallback : value;
}
// OFFSET: 0x00E0A760
// FUNCTION: fn_23799
GUID ScriptOptions::Guid(const char* key, const GUID& fallback) {
GUID CSession::GetOptionGuid(const char* key, const GUID& fallback) {
const char* value = nullptr;
this->script.Call("l_GetOptionValue", "s>s", key, &value);
this->m_hotkeyScript->Call("l_GetOptionValue", "s>s", key, &value);
if (value && std::strcmp(value, "-1") != 0) {
GUID parsed;

View file

@ -1,5 +1,4 @@
#include "Contents/Configuration/ServiceOptions.h"
#include "Contents/Configuration/ScriptOptions.h"
#include "Contents/Actors/Pc.h"
#include "Contents/Camera/Camera.h"
#include "Contents/Configuration/ServiceConfiguration.h"
@ -82,7 +81,7 @@ public:
void ResetToDefaults();
void ToggleOption(int id);
void sub_6C0C40(int id, unsigned char value, bool notify);
void ApplyScriptOption(int id, const char* key, ScriptOptions& script);
void ApplyScriptOption(int id, const char* key);
bool RunFunction(int id);
std::optional<GameSettingsOption*> FindOption(int id);
std::list<int> GetOptionIds(int tab);
@ -801,13 +800,13 @@ bool ServiceOptions::Set(int id, unsigned char value) {
// OFFSET: 0x006C1900
// FUNCTION: fn_06320
void GameSettings::ApplyScriptOption(int id, const char* key, ScriptOptions& script) {
void GameSettings::ApplyScriptOption(int id, const char* key) {
for (const GameSettingsOption& option : this->options) {
if (option.id != id) {
continue;
}
g_serviceOptions.Set(id, script.Integer(key, option.defaultValue) != 0);
g_serviceOptions.Set(id, g_session.GetOptionInteger(key, option.defaultValue) != 0);
return;
}
}
@ -1508,26 +1507,24 @@ extern const GUID g_defaultDrawGuidDX7 = {};
// OFFSET: 0x00DFE4E0
// FUNCTION: fn_23604
void CSession::LoadOptionInfo() {
ScriptOptions& options = reinterpret_cast<ScriptOptions&>(*this);
g_luaScript->Call("SetCmdOnOffList", "");
ResourceExists("OptionInfo.lua", 1);
g_textureFiltering = options.Integer("Trilinear", 0);
g_textureFiltering = this->GetOptionInteger("Trilinear", 0);
const int effectVolume = options.Integer("Effect_Volume", 100);
CSoundMgr::SetVolume(g_soundMgr, options.Integer("Bgm_Volume", 100));
const int effectVolume = this->GetOptionInteger("Effect_Volume", 100);
CSoundMgr::SetVolume(g_soundMgr, this->GetOptionInteger("Bgm_Volume", 100));
g_soundMgr->SetTargetVolume(CSoundMgr::Volume(g_soundMgr));
g_soundMgr->SetSampleVolume(effectVolume);
g_soundMgr->Set3DVolume(effectVolume);
this->m_autoOpenWhisperWindow = options.Integer("AutoOpen1to1Window", 1);
this->m_autoOpenFriendWhisperWindow = options.Integer("AutoOpen1to1Window_Friend", 1);
this->m_whisperOpenSound = options.Integer("PlaySound_Open1to1Window", 1);
this->m_simplifiedSkillList = options.Integer("Simplicity_SkillList", 0);
this->m_showSkillDescription = options.Integer("Show_SkillDescript", 0);
g_windowCloseByte = options.Integer("ChangeChatMode", 1) != 0;
this->m_lockMouse = options.Integer("LockMouse", 0) != 0;
this->m_channelCopId = options.Integer("ChannelCopID", 0);
this->m_autoOpenWhisperWindow = this->GetOptionInteger("AutoOpen1to1Window", 1);
this->m_autoOpenFriendWhisperWindow = this->GetOptionInteger("AutoOpen1to1Window_Friend", 1);
this->m_whisperOpenSound = this->GetOptionInteger("PlaySound_Open1to1Window", 1);
this->m_simplifiedSkillList = this->GetOptionInteger("Simplicity_SkillList", 0);
this->m_showSkillDescription = this->GetOptionInteger("Show_SkillDescript", 0);
g_windowCloseByte = this->GetOptionInteger("ChangeChatMode", 1) != 0;
this->m_lockMouse = this->GetOptionInteger("LockMouse", 0) != 0;
this->m_channelCopId = this->GetOptionInteger("ChannelCopID", 0);
g_outdoorCameraPitch = this->GetOptionFloat("Outdoor_ViewLatitude", -45.0f);
g_outdoorCameraDistance = this->GetOptionFloat("Outdoor_ViewDistance", 300.0f);
@ -1549,7 +1546,7 @@ void CSession::LoadOptionInfo() {
}
Singleton<CGameSettingsMgr>::GetInstance();
::SetOption(LookupMessage(0xDB9), options.Integer(LookupMessage(0xDB9), 0) != 0);
::SetOption(LookupMessage(0xDB9), this->GetOptionInteger(LookupMessage(0xDB9), 0) != 0);
g_serviceOptionJitterScale = g_serviceOptions.Get(0xF1) ? 730.0f : g_jitterDistanceScale;
if (g_outdoorCameraPitch < -65.0f) {
@ -1566,30 +1563,30 @@ void CSession::LoadOptionInfo() {
g_outdoorCameraDistance = g_serviceOptionJitterScale;
}
g_skinInfo.m_name = options.String("SkinName", "<Basic Skin>");
g_skinInfo.m_name = this->GetOptionString("SkinName", "<Basic Skin>");
this->unknown_1708 = g_serviceOptions.Get(0x2E);
g_showBattleFieldIcon = options.Integer("ShowBattleFieldIcon", 1) != 0;
Singleton<CGameSettingsMgr>::GetInstance()->ApplyScriptOption(ConfineCursor, "MouseExclusive", options);
g_showBattleFieldIcon = this->GetOptionInteger("ShowBattleFieldIcon", 1) != 0;
Singleton<CGameSettingsMgr>::GetInstance()->ApplyScriptOption(ConfineCursor, "MouseExclusive");
const int resetPolicy = this->RenderSystemResetPolicy();
const int defaultBackend = this->DefaultRenderBackend();
g_renderSystemReset = options.Integer("RenderSystemReset", 1);
g_renderSystemReset = this->GetOptionInteger("RenderSystemReset", 1);
if (resetPolicy != g_renderSystemReset) {
g_configuredRenderBackend = defaultBackend;
g_renderSystemReset = resetPolicy;
} else {
g_configuredRenderBackend = options.Integer("RENDERSYSTEM", defaultBackend);
g_configuredRenderBackend = this->GetOptionInteger("RENDERSYSTEM", defaultBackend);
}
g_configuredDeviceGuid = options.Guid("DX9DEVICEID", g_defaultDrawGuidDX7);
strncpy_s(g_configuredDeviceName, sizeof(g_configuredDeviceName), options.String("DX9DEVICENAME", "").c_str(), _TRUNCATE);
g_configuredDeviceGuid = this->GetOptionGuid("DX9DEVICEID", g_defaultDrawGuidDX7);
strncpy_s(g_configuredDeviceName, sizeof(g_configuredDeviceName), this->GetOptionString("DX9DEVICENAME", "").c_str(), _TRUNCATE);
g_configuredFullscreen = options.Integer("ISFULLSCREENMODE", 0);
g_configuredScreenWidth = options.Integer("WIDTH", 1024);
g_configuredScreenHeight = options.Integer("HEIGHT", 768);
g_configuredOldWidth = options.Integer("OLD_WIDTH", 0);
g_configuredOldHeight = options.Integer("OLD_HEIGHT", 0);
g_configuredFullscreen = this->GetOptionInteger("ISFULLSCREENMODE", 0);
g_configuredScreenWidth = this->GetOptionInteger("WIDTH", 1024);
g_configuredScreenHeight = this->GetOptionInteger("HEIGHT", 768);
g_configuredOldWidth = this->GetOptionInteger("OLD_WIDTH", 0);
g_configuredOldHeight = this->GetOptionInteger("OLD_HEIGHT", 0);
if (static_cast<unsigned int>(g_configuredScreenHeight) < 664) {
g_configuredScreenWidth = 1024;
@ -1598,7 +1595,7 @@ void CSession::LoadOptionInfo() {
g_viewportWidth = g_configuredScreenWidth;
g_viewportHeight = g_configuredScreenHeight;
g_configuredBitsPerPixel = options.Integer("BITPERPIXEL", 16);
g_configuredBitsPerPixel = this->GetOptionInteger("BITPERPIXEL", 16);
OSVERSIONINFOA version = {sizeof(version)};
GetVersionExA(&version);
@ -1607,10 +1604,10 @@ void CSession::LoadOptionInfo() {
g_configuredBitsPerPixel = 32;
}
g_configuredDeviceCount = options.Integer("DEVICECNT", 0);
g_configuredModeCount = options.Integer("MODECNT", 0);
g_configuredDeviceCount = this->GetOptionInteger("DEVICECNT", 0);
g_configuredModeCount = this->GetOptionInteger("MODECNT", 0);
g_effectDetailLevel = options.Integer("SPRITEMODE", 2);
g_effectDetailLevel = this->GetOptionInteger("SPRITEMODE", 2);
switch (g_effectDetailLevel) {
case 0:
g_spriteHalfWidth = 1;
@ -1624,7 +1621,7 @@ void CSession::LoadOptionInfo() {
break;
}
g_textureDetailLevel = options.Integer("TEXTUREMODE", 2);
g_textureDetailLevel = this->GetOptionInteger("TEXTUREMODE", 2);
switch (g_textureDetailLevel) {
case 0:
g_textureReduction = 4;
@ -1637,28 +1634,28 @@ void CSession::LoadOptionInfo() {
break;
}
this->m_lockItemDrop = options.Integer("bLockItemDropFromItemWnd", 0) != 0;
this->m_skipPriceWarning = options.Integer("bWarningPriceCheck", 0) == 0;
this->m_muteSellSound = options.Integer("bSoundEffectInItemSellWnd", 0) == 0;
this->m_guildMemberListSort = options.Integer("bGuildMemberListSort", 1) != 0;
this->m_blockPrivateTab = options.Integer("bBlockPrivateTab", 0) != 0;
this->m_itemDefaultSort = options.Integer("bItemDefaultSort", 0) != 0;
this->m_itemAscendingOrder = options.Integer("bItemAscendingOrder", 0) != 0;
this->m_itemDescendingOrder = options.Integer("bItemDescendingOrder", 0) != 0;
this->m_showMenuIcon = options.Integer("bShowMenuIcon", 1) != 0;
this->m_lockItemDrop = this->GetOptionInteger("bLockItemDropFromItemWnd", 0) != 0;
this->m_skipPriceWarning = this->GetOptionInteger("bWarningPriceCheck", 0) == 0;
this->m_muteSellSound = this->GetOptionInteger("bSoundEffectInItemSellWnd", 0) == 0;
this->m_guildMemberListSort = this->GetOptionInteger("bGuildMemberListSort", 1) != 0;
this->m_blockPrivateTab = this->GetOptionInteger("bBlockPrivateTab", 0) != 0;
this->m_itemDefaultSort = this->GetOptionInteger("bItemDefaultSort", 0) != 0;
this->m_itemAscendingOrder = this->GetOptionInteger("bItemAscendingOrder", 0) != 0;
this->m_itemDescendingOrder = this->GetOptionInteger("bItemDescendingOrder", 0) != 0;
this->m_showMenuIcon = this->GetOptionInteger("bShowMenuIcon", 1) != 0;
Singleton<CGameSettingsMgr>::GetInstance()->ApplyScriptOption(0xF3, LookupMessage(0xDC6), options);
Singleton<CGameSettingsMgr>::GetInstance()->ApplyScriptOption(0x10B, "bExtendDamage", options);
Singleton<CGameSettingsMgr>::GetInstance()->ApplyScriptOption(0x10C, "bShowMapName", options);
Singleton<CGameSettingsMgr>::GetInstance()->ApplyScriptOption(0x10D, "bShowOnlyMineFootprint", options);
Singleton<CGameSettingsMgr>::GetInstance()->ApplyScriptOption(0xF3, LookupMessage(0xDC6));
Singleton<CGameSettingsMgr>::GetInstance()->ApplyScriptOption(0x10B, "bExtendDamage");
Singleton<CGameSettingsMgr>::GetInstance()->ApplyScriptOption(0x10C, "bShowMapName");
Singleton<CGameSettingsMgr>::GetInstance()->ApplyScriptOption(0x10D, "bShowOnlyMineFootprint");
this->m_damageSkinIndex = options.Integer("DamageSkin", 0);
this->m_damageSkinMode = options.Integer("DamageDir", 0);
this->m_priorityClass = options.Integer("PriorityClass", 32);
this->m_damageSkinIndex = this->GetOptionInteger("DamageSkin", 0);
this->m_damageSkinMode = this->GetOptionInteger("DamageDir", 0);
this->m_priorityClass = this->GetOptionInteger("PriorityClass", 32);
Singleton<CGameSettingsMgr>::GetInstance()->ApplyScriptOption(0x10A, "bSummonTranslucent", options);
Singleton<CGameSettingsMgr>::GetInstance()->ApplyScriptOption(0x109, "bHidePlayer", options);
Singleton<CGameSettingsMgr>::GetInstance()->ApplyScriptOption(0x10E, "bQuickSlot", options);
Singleton<CGameSettingsMgr>::GetInstance()->ApplyScriptOption(0x10A, "bSummonTranslucent");
Singleton<CGameSettingsMgr>::GetInstance()->ApplyScriptOption(0x109, "bHidePlayer");
Singleton<CGameSettingsMgr>::GetInstance()->ApplyScriptOption(0x10E, "bQuickSlot");
}
// OFFSET: 0x00E01770

View file

@ -1,7 +1,6 @@
#include "UI/Window/UIWindowFactory.h"
#include "Client/Session.h"
#include "Contents/Configuration/ScriptOptions.h"
#include "Render/Renderer.h"
#include "Script/LuaScript.h"
#include "UI/EntryQueue/UIEntryQueueWnd.h"
@ -67,8 +66,8 @@ UIWindow* UIWindowMgr::CreateLayoutWindow(int id) {
savedX = saved->second->x;
savedY = saved->second->y;
} else {
savedX = reinterpret_cast<ScriptOptions&>(g_session).Integer(xKey.c_str(), x);
savedY = reinterpret_cast<ScriptOptions&>(g_session).Integer(yKey.c_str(), y);
savedX = g_session.GetOptionInteger(xKey.c_str(), x);
savedY = g_session.GetOptionInteger(yKey.c_str(), y);
}
window->SetId(id);