From c015d9cbc97f857a60f1e2059424f960eb53f05d Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Fri, 25 Nov 2016 00:04:30 +0800 Subject: [PATCH] Cleaned up a bit OpenGL_Windows.cpp, avoid calling CleanUp twice after exceptions --- Source/OpenGL_Windows.cpp | 57 ++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/Source/OpenGL_Windows.cpp b/Source/OpenGL_Windows.cpp index 33ae0f8..d79162b 100644 --- a/Source/OpenGL_Windows.cpp +++ b/Source/OpenGL_Windows.cpp @@ -17,10 +17,16 @@ You should have received a copy of the GNU General Public License along with Lugaru. If not, see . */ - -#ifdef WIN32 -#include -#endif +#include +#include +#include +#include +#include +#include +#include +#include "gamegl.h" +#include "MacCompatibility.h" +#include "Settings.h" #include "Game.h" @@ -28,6 +34,12 @@ using namespace Game; #include "openal_wrapper.h" +#ifdef WIN32 +#include +#include +#include "win-res/resource.h" +#endif + extern float multiplier; extern float sps; extern float realmultiplier; @@ -44,33 +56,12 @@ extern float slomospeed; extern float slomofreq; extern bool visibleloading; -#include -#include -#include -#include -#include -#include -#include -#include "gamegl.h" -#include "MacCompatibility.h" -#include "Settings.h" - -#ifdef WIN32 -#include -#include "win-res/resource.h" -#endif - extern SDL_Window *sdlwindow; using namespace std; set> resolutions; -bool SetUp (); -void DoUpdate (); - -void CleanUp (void); - // statics/globals (internal only) ------------------------------------------ #ifdef _MSC_VER @@ -131,9 +122,6 @@ static void GLAPIENTRY glDeleteTextures_doNothing(GLsizei n, const GLuint *textu int kContextWidth; int kContextHeight; -bool gDone = false; -bool gameFocused; - static int _argc = 0; static char **_argv = NULL; @@ -684,7 +672,10 @@ int main(int argc, char **argv) if (!SetUp ()) return 42; - while (!gDone && !tryquit) { + bool gameDone = false; + bool gameFocused = true; + + while (!gameDone && !tryquit) { if (IsFocused()) { gameFocused = true; @@ -697,7 +688,7 @@ int main(int argc, char **argv) // message pump while ( SDL_PollEvent( &e ) ) { if (!sdlEventProc(e)) { - gDone = true; + gameDone = true; break; } } @@ -732,9 +723,7 @@ int main(int argc, char **argv) LOG(e); MessageBox(g_windowHandle, error.what(), "ERROR", MB_OK | MB_ICONEXCLAMATION); - } - CleanUp(); - - return -1; + return -1; + } } -- 2.39.5