diff --git a/src/cdogs/config.h b/src/cdogs/config.h index f8fd7d737..95ec56eba 100644 --- a/src/cdogs/config.h +++ b/src/cdogs/config.h @@ -91,7 +91,7 @@ extern Config gConfig; void ConfigLoad(Config *config, const char *filename); void ConfigSave(Config *config, const char *filename); -void ConfigApply(Config *config); +int ConfigApply(Config *config); void ConfigLoadDefault(Config *config); int ConfigGetVersion(FILE *f); diff --git a/src/cdogs/config_apply.c b/src/cdogs/config_apply.c index 903a3596f..634ccd3d2 100644 --- a/src/cdogs/config_apply.c +++ b/src/cdogs/config_apply.c @@ -32,10 +32,11 @@ #include "gamedata.h" -void ConfigApply(Config *config) +int ConfigApply(Config *config) { BlitSetBrightness(config->Graphics.Brightness); SoundReconfigure(&gSoundDevice, &config->Sound); gCampaign.seed = config->Game.RandomSeed; GraphicsInitialize(&gGraphicsDevice, &config->Graphics, 0); + return gGraphicsDevice.IsInitialized; } diff --git a/src/menu.c b/src/menu.c index 9bbd0055a..2f25a7ee8 100644 --- a/src/menu.c +++ b/src/menu.c @@ -799,6 +799,7 @@ void MenuChangeIndex(menu_t *menu, int cmd) void MenuActivate(menu_t *menu, int cmd) { + Config lastConfig = gConfig; SoundPlay(&gSoundDevice, SND_SWITCH); switch (menu->type) { @@ -927,5 +928,14 @@ void MenuActivate(menu_t *menu, int cmd) assert(0); break; } - ConfigApply(&gConfig); + if (!ConfigApply(&gConfig)) + { + printf("Error: cannot apply new config; applying last config\n"); + gConfig = lastConfig; + if (!ConfigApply(&gConfig)) + { + printf("Error: cannot apply last config!\n"); + exit(1); + } + } }