From 26376c652d59de271147027bb5c365b22c2765c2 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 25 Oct 2014 18:34:29 +0200 Subject: Nothing else works, so restart the game on resolution change Fixes #339 for now, but we'll need alternative solution later --- src/app/main.cpp | 62 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) (limited to 'src/app/main.cpp') diff --git a/src/app/main.cpp b/src/app/main.cpp index e30a83d..88a7a73 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -86,42 +86,46 @@ int SDL_MAIN_FUNC(int argc, char *argv[]) InitializeRestext(); InitializeEventTypeTexts(); - CSystemUtils* systemUtils = CSystemUtils::Create(); // platform-specific utils - systemUtils->Init(); - logger.Info("Colobot starting\n"); - - CApplication* app = new CApplication(); // single instance of the application - - ParseArgsStatus status = app->ParseArguments(argc, argv); - if (status == PARSE_ARGS_FAIL) - { - systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", "Invalid commandline arguments!\n"); - return app->GetExitCode(); - } - else if (status == PARSE_ARGS_HELP) - { - return app->GetExitCode(); - } - + int code = 0; + while(true) { + CSystemUtils* systemUtils = CSystemUtils::Create(); // platform-specific utils + systemUtils->Init(); + + CApplication* app = new CApplication(); // single instance of the application + + ParseArgsStatus status = app->ParseArguments(argc, argv); + if (status == PARSE_ARGS_FAIL) + { + systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", "Invalid commandline arguments!\n"); + return app->GetExitCode(); + } + else if (status == PARSE_ARGS_HELP) + { + return app->GetExitCode(); + } - if (! app->Create()) - { - app->Destroy(); // ensure a clean exit - code = app->GetExitCode(); - if ( code != 0 && !app->GetErrorMessage().empty() ) + + if (! app->Create()) { - systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", app->GetErrorMessage()); + app->Destroy(); // ensure a clean exit + code = app->GetExitCode(); + if ( code != 0 && !app->GetErrorMessage().empty() ) + { + systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", app->GetErrorMessage()); + } + logger.Info("Didn't run main loop. Exiting with code %d\n", code); + return code; } - logger.Info("Didn't run main loop. Exiting with code %d\n", code); - return code; - } - code = app->Run(); + code = app->Run(); + bool restarting = app->IsRestarting(); - delete app; - delete systemUtils; + delete app; + delete systemUtils; + if(!restarting) break; + } logger.Info("Exiting with code %d\n", code); return code; -- cgit v1.2.3-1-g7c22