diff --git a/Source/Contents/Configuration/ServiceOptions.cpp b/Source/Contents/Configuration/ServiceOptions.cpp index e5b9780..7fb2f2b 100644 --- a/Source/Contents/Configuration/ServiceOptions.cpp +++ b/Source/Contents/Configuration/ServiceOptions.cpp @@ -1,4 +1,28 @@ #include "Contents/Configuration/ServiceOptions.h" +#include "Contents/Configuration/ScriptOptions.h" + +#include +#include + +struct GameSettingsOption { + /* 0000 */ int id; + /* 0004 */ unsigned char unknown_0004[0x54]; + /* 0058 */ unsigned char defaultValue; + /* 0059 */ unsigned char unknown_0059[0xB]; +}; + +struct GameSettings { + /* 0000 */ unsigned char unknown_0000[0xC]; + /* 000C */ std::vector options; + + void ApplyScriptOption(int id, const char* key, ScriptOptions& script); +}; + +#if defined(_WIN32) && !defined(_WIN64) +static_assert(sizeof(GameSettingsOption) == 0x64); +static_assert(offsetof(GameSettingsOption, defaultValue) == 0x58); +static_assert(offsetof(GameSettings, options) == 0x0C); +#endif // GLOBAL: gl_24579 ServiceOptions g_serviceOptions; @@ -37,3 +61,16 @@ bool ServiceOptions::Set(int id, unsigned char value) { entry->second = value; return true; } + +// OFFSET: 0x006C1900 +// FUNCTION: fn_06320 +void GameSettings::ApplyScriptOption(int id, const char* key, ScriptOptions& script) { + for (const GameSettingsOption& option : this->options) { + if (option.id != id) { + continue; + } + + g_serviceOptions.Set(id, script.Integer(key, option.defaultValue) != 0); + return; + } +}