summaryrefslogtreecommitdiffstats
path: root/src/app/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/main.cpp')
-rw-r--r--src/app/main.cpp62
1 files changed, 33 insertions, 29 deletions
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;