From c321a71241a4d01038d404be3eb2ce3a30f42bf0 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 17 Jan 2016 02:15:03 +0100 Subject: BASE: Initialize default GUI option values before engine instantiation. This fixes engines (like AGI) which query the configuration options inside their constructor. --- base/main.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'base/main.cpp') diff --git a/base/main.cpp b/base/main.cpp index 3ea38b547a..ff441df49c 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -152,8 +152,17 @@ static Common::Error runGame(const EnginePlugin *plugin, OSystem &system, const err = Common::kPathNotDirectory; // Create the game engine - if (err.getCode() == Common::kNoError) + if (err.getCode() == Common::kNoError) { + // Set default values for all of the custom engine options + // Appareantly some engines query them in their constructor, thus we + // need to set this up before instance creation. + const ExtraGuiOptions engineOptions = (*plugin)->getExtraGuiOptions(Common::String()); + for (uint i = 0; i < engineOptions.size(); i++) { + ConfMan.registerDefault(engineOptions[i].configOption, engineOptions[i].defaultState); + } + err = (*plugin)->createInstance(&system, &engine); + } // Check for errors if (!engine || err.getCode() != Common::kNoError) { @@ -231,12 +240,6 @@ static Common::Error runGame(const EnginePlugin *plugin, OSystem &system, const // Initialize any game-specific keymaps engine->initKeymap(); - // Set default values for all of the custom engine options - const ExtraGuiOptions engineOptions = (*plugin)->getExtraGuiOptions(Common::String()); - for (uint i = 0; i < engineOptions.size(); i++) { - ConfMan.registerDefault(engineOptions[i].configOption, engineOptions[i].defaultState); - } - // Inform backend that the engine is about to be run system.engineInit(); -- cgit v1.2.3