diff --git a/mods/src/options/options.cpp b/mods/src/options/options.cpp index 7bf1bdbc4c..8e4019bd28 100644 --- a/mods/src/options/options.cpp +++ b/mods/src/options/options.cpp @@ -127,6 +127,12 @@ static void OptionsPane_unknown_toggle_creating_function_injection(OptionsPane * std::string cpp_string = "3D Anaglyph"; OptionsPane_unknown_toggle_creating_function(options_pane, group_id, &cpp_string, &Options_Option_ANAGLYPH); } + + // Add Peaceful Mode + if (option == &Options_Option_SERVER_VISIBLE) { + std::string cpp_string = "Peaceful mode"; + OptionsPane_unknown_toggle_creating_function(options_pane, group_id, &cpp_string, &Options_Option_DIFFICULTY); + } } // Add Missing Options To Options::getBooleanValue @@ -134,12 +140,28 @@ static bool Options_getBooleanValue_injection(Options *options, Options_Option * // Check if (option == &Options_Option_GRAPHICS) { return options->fancy_graphics; + } else if (option == &Options_Option_DIFFICULTY) { + return options->game_difficulty == 0; } else { // Call Original Method return Options_getBooleanValue(options, option); } } +// Fix Difficulty When Toggling +static void OptionButton_toggle_Options_save_injection(Options *self) { + // Fix Value + if (self->game_difficulty == 1) { + // Disable Peaceful + self->game_difficulty = 2; + } else if (self->game_difficulty == 3) { + // Switch To Peaceful + self->game_difficulty = 0; + } + // Call Original Method + Options_save(self); +} + // Init C++ void _init_options_cpp() { // NOP @@ -164,6 +186,9 @@ void _init_options_cpp() { // Add Missing Options To Options::getBooleanValue overwrite_calls((void *) Options_getBooleanValue, (void *) Options_getBooleanValue_injection); + + // Fix Difficulty When Toggling + overwrite_call((void *) 0x1cd00, (void *) OptionButton_toggle_Options_save_injection); } // Actually Save options.txt diff --git a/symbols/src/game/options/Options.def b/symbols/src/game/options/Options.def index f9027e82c3..556ba567a0 100644 --- a/symbols/src/game/options/Options.def +++ b/symbols/src/game/options/Options.def @@ -3,6 +3,7 @@ size 0x110; method void initDefaultValue() = 0x18a54; method bool getBooleanValue(Options_Option *option) = 0x1cd74; method void addOptionToSaveOutput(std::vector *data, std::string option, int value) = 0x195e4; +method void save() = 0x1966c; property OptionsFile options_file = 0x10c; property bool fancy_graphics = 0x17; diff --git a/symbols/src/game/options/Options_Option.def b/symbols/src/game/options/Options_Option.def index 230cd17b3d..64eb732f39 100644 --- a/symbols/src/game/options/Options_Option.def +++ b/symbols/src/game/options/Options_Option.def @@ -1,3 +1,5 @@ static-property Options_Option GRAPHICS = 0x136c2c; static-property Options_Option AMBIENT_OCCLUSION = 0x136c38; static-property Options_Option ANAGLYPH = 0x136c08; +static-property Options_Option DIFFICULTY = 0x136c20; +static-property Options_Option SERVER_VISIBLE = 0x136c68;