From ae1ea95d5e9c795beee6a16f4aae11d787350ffb Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Sun, 5 Feb 2017 09:24:52 +0100 Subject: [PATCH] Quit properly the game on the SDL_QUIT event --- blupi.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/blupi.cpp b/blupi.cpp index 550cf3d..b015c3c 100644 --- a/blupi.cpp +++ b/blupi.cpp @@ -657,8 +657,6 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { - MSG msg; - if (!DoInit(hInstance, lpCmdLine, nCmdShow)) return false; @@ -668,11 +666,13 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, return interval; }, nullptr); - while (SDL_TRUE) + SDL_Event event; + while (SDL_WaitEvent (&event)) { - SDL_Event event; - while (SDL_WaitEvent (&event)) - WindowProc2 (event); + WindowProc2 (event); + + if (event.type == SDL_QUIT) + break; } if (g_window) @@ -681,6 +681,6 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, SDL_RemoveTimer (updateTimer); FinishObjects (); SDL_Quit (); - return static_cast (msg.wParam); + return 0; }