From 9d12682fb57839c9ebc9ed5aa9471e3ec09a745e Mon Sep 17 00:00:00 2001 From: titiger Date: Tue, 29 Aug 2017 01:27:53 +0200 Subject: [PATCH] fix for #173 fix a crash with unknown screen resolution in .megaglest --- source/glest_game/menu/menu_state_options_graphics.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/glest_game/menu/menu_state_options_graphics.cpp b/source/glest_game/menu/menu_state_options_graphics.cpp index fd2d50bc..71d5c6e6 100644 --- a/source/glest_game/menu/menu_state_options_graphics.cpp +++ b/source/glest_game/menu/menu_state_options_graphics.cpp @@ -598,6 +598,16 @@ void MenuStateOptionsGraphics::mouseClick(int x, int y, MouseButton mouseButton) selectedMode = &(*it); } } + if(selectedMode == NULL) { // if we cannot find the selectedResolution we try it with current one + for(vector::const_iterator it= modeInfos.begin(); it!=modeInfos.end(); ++it) { + if((*it).getString() == currentResolution) { + //config.setInt("ScreenWidth",(*it).width); + //config.setInt("ScreenHeight",(*it).height); + //config.setInt("ColorBits",(*it).depth); + selectedMode = &(*it); + } + } + } if(selectedMode == NULL) { throw megaglest_runtime_error("selectedMode == NULL"); }