mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 19:13:07 +01:00
Merge pull request #10593 from tupaschoal/pr-10048
Fix #9477: Process exit code is always 0
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
#include <openrct2/cmdline/CommandLine.hpp>
|
||||
#include <openrct2/platform/platform.h>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
@@ -18,16 +19,21 @@ using namespace OpenRCT2;
|
||||
*/
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
int32_t rc = EXIT_SUCCESS;
|
||||
int runGame = cmdline_run(argv, argc);
|
||||
core_init();
|
||||
if (runGame == 1)
|
||||
if (runGame == EXITCODE_CONTINUE)
|
||||
{
|
||||
gOpenRCT2Headless = true;
|
||||
gOpenRCT2NoGraphics = true;
|
||||
|
||||
// Run OpenRCT2 with a plain context
|
||||
auto context = CreateContext();
|
||||
context->RunOpenRCT2(argc, argv);
|
||||
rc = context->RunOpenRCT2(argc, argv);
|
||||
}
|
||||
return gExitCode;
|
||||
else if (runGame == EXITCODE_FAIL)
|
||||
{
|
||||
rc = EXIT_FAILURE;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
#include <openrct2/PlatformEnvironment.h>
|
||||
#include <openrct2/audio/AudioContext.h>
|
||||
#include <openrct2/cmdline/CommandLine.hpp>
|
||||
#include <openrct2/platform/platform.h>
|
||||
#include <openrct2/ui/UiContext.h>
|
||||
|
||||
@@ -38,16 +39,17 @@ int NormalisedMain(int argc, const char** argv)
|
||||
int main(int argc, const char** argv)
|
||||
#endif
|
||||
{
|
||||
std::unique_ptr<IContext> context;
|
||||
int32_t rc = EXIT_SUCCESS;
|
||||
int runGame = cmdline_run(argv, argc);
|
||||
core_init();
|
||||
RegisterBitmapReader();
|
||||
if (runGame == 1)
|
||||
if (runGame == EXITCODE_CONTINUE)
|
||||
{
|
||||
if (gOpenRCT2Headless)
|
||||
{
|
||||
// Run OpenRCT2 with a plain context
|
||||
auto context = CreateContext();
|
||||
context->RunOpenRCT2(argc, argv);
|
||||
context = CreateContext();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -55,12 +57,15 @@ 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);
|
||||
}
|
||||
rc = context->RunOpenRCT2(argc, argv);
|
||||
}
|
||||
return gExitCode;
|
||||
else if (runGame == EXITCODE_FAIL)
|
||||
{
|
||||
rc = EXIT_FAILURE;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
||||
@@ -243,8 +243,9 @@ namespace OpenRCT2
|
||||
if (Initialise())
|
||||
{
|
||||
Launch();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
return gExitCode;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
void WriteLine(const std::string& s) override
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "OpenRCT2.h"
|
||||
|
||||
int32_t gExitCode;
|
||||
int32_t gOpenRCT2StartupAction = STARTUP_ACTION_TITLE;
|
||||
utf8 gOpenRCT2StartupActionPath[512] = { 0 };
|
||||
utf8 gExePath[MAX_PATH];
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user