From 36840f3fe0736d5aeea5f218a8eac81eb52ef787 Mon Sep 17 00:00:00 2001 From: Lomash Gupta Date: Sat, 5 Oct 2019 12:57:07 -0400 Subject: [PATCH] fixed gExitCode --- src/openrct2-cli/Cli.cpp | 6 ++++-- src/openrct2-ui/Ui.cpp | 13 +++++++------ src/openrct2/Context.cpp | 3 ++- src/openrct2/OpenRCT2.cpp | 1 - src/openrct2/OpenRCT2.h | 3 --- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/openrct2-cli/Cli.cpp b/src/openrct2-cli/Cli.cpp index a063be9185..cf6a55b04d 100644 --- a/src/openrct2-cli/Cli.cpp +++ b/src/openrct2-cli/Cli.cpp @@ -27,7 +27,9 @@ int main(int argc, const char** argv) // Run OpenRCT2 with a plain context auto context = CreateContext(); - context->RunOpenRCT2(argc, argv); + if((context->RunOpenRCT2(argc, argv)) == EXIT_SUCCESS) { + return EXIT_SUCCESS; + } } - return gExitCode; + return EXIT_FAILURE; } diff --git a/src/openrct2-ui/Ui.cpp b/src/openrct2-ui/Ui.cpp index 22ebaeada3..08bd347916 100644 --- a/src/openrct2-ui/Ui.cpp +++ b/src/openrct2-ui/Ui.cpp @@ -38,6 +38,7 @@ int NormalisedMain(int argc, const char** argv) int main(int argc, const char** argv) #endif { + std::unique_ptr context; int runGame = cmdline_run(argv, argc); core_init(); RegisterBitmapReader(); @@ -46,8 +47,7 @@ int main(int argc, const char** argv) if (gOpenRCT2Headless) { // Run OpenRCT2 with a plain context - auto context = CreateContext(); - context->RunOpenRCT2(argc, argv); + context = CreateContext(); } else { @@ -55,12 +55,13 @@ int main(int argc, const char** argv) auto env = to_shared(CreatePlatformEnvironment()); auto audioContext = to_shared(CreateAudioContext()); auto uiContext = to_shared(CreateUiContext(env)); - auto context = CreateContext(env, audioContext, uiContext); - - context->RunOpenRCT2(argc, argv); + context = CreateContext(env, audioContext, uiContext); + } + if (context->RunOpenRCT2(argc, argv) == EXIT_SUCCESS) { + return EXIT_SUCCESS; } } - return gExitCode; + return EXIT_FAILURE; } #ifdef __ANDROID__ diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 987a4a7249..34acc7788d 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -243,8 +243,9 @@ namespace OpenRCT2 if (Initialise()) { Launch(); + return EXIT_SUCCESS; } - return gExitCode; + return EXIT_FAILURE; } void WriteLine(const std::string& s) override diff --git a/src/openrct2/OpenRCT2.cpp b/src/openrct2/OpenRCT2.cpp index 30dd4abcae..a6212ef2e3 100644 --- a/src/openrct2/OpenRCT2.cpp +++ b/src/openrct2/OpenRCT2.cpp @@ -9,7 +9,6 @@ #include "OpenRCT2.h" -int32_t gExitCode; int32_t gOpenRCT2StartupAction = STARTUP_ACTION_TITLE; utf8 gOpenRCT2StartupActionPath[512] = { 0 }; utf8 gExePath[MAX_PATH]; diff --git a/src/openrct2/OpenRCT2.h b/src/openrct2/OpenRCT2.h index ac57ac4e17..fea147ec55 100644 --- a/src/openrct2/OpenRCT2.h +++ b/src/openrct2/OpenRCT2.h @@ -34,9 +34,6 @@ enum SCREEN_FLAGS_EDITOR = (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER), }; -/** The exit code for OpenRCT2 when it exits. */ -extern int32_t gExitCode; - extern int32_t gOpenRCT2StartupAction; extern utf8 gOpenRCT2StartupActionPath[512]; extern utf8 gExePath[MAX_PATH];