mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Prevent SDL_INIT when the game does not need to launch
This commit is contained in:
@@ -37,6 +37,25 @@ static char * * GetCommandLineArgs(int argc, wchar_t * * argvW);
|
||||
static void FreeCommandLineArgs(int argc, char * * argv);
|
||||
static char * ConvertUTF16toUTF8(const wchar_t * src);
|
||||
|
||||
static int NormalisedMain(int argc, char * * argv)
|
||||
{
|
||||
core_init();
|
||||
int runGame = cmdline_run((const char * *)argv, argc);
|
||||
if (runGame == 1)
|
||||
{
|
||||
IAudioContext * audioContext = CreateAudioContext();
|
||||
IUiContext * uiContext = CreateUiContext();
|
||||
IContext * context = CreateContext(audioContext, uiContext);
|
||||
|
||||
context->RunOpenRCT2(argc, argv);
|
||||
|
||||
delete context;
|
||||
delete uiContext;
|
||||
delete audioContext;
|
||||
}
|
||||
return gExitCode;
|
||||
}
|
||||
|
||||
DLLEXPORT int LaunchOpenRCT2(int argc, wchar_t * * argvW)
|
||||
{
|
||||
char * * argv = GetCommandLineArgs(argc, argvW);
|
||||
@@ -46,15 +65,7 @@ DLLEXPORT int LaunchOpenRCT2(int argc, wchar_t * * argvW)
|
||||
return -1;
|
||||
}
|
||||
|
||||
IAudioContext * audioContext = CreateAudioContext();
|
||||
IUiContext * uiContext = CreateUiContext();
|
||||
IContext * context = CreateContext(audioContext, uiContext);
|
||||
|
||||
int exitCode = context->RunOpenRCT2(argc, argv);
|
||||
|
||||
delete context;
|
||||
delete uiContext;
|
||||
delete audioContext;
|
||||
int exitCode = NormalisedMain(argc, argv);
|
||||
|
||||
FreeCommandLineArgs(argc, argv);
|
||||
return exitCode;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <openrct2/audio/AudioContext.h>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
#include <openrct2/ui/UiContext.h>
|
||||
#include "audio/AudioContext.h"
|
||||
#include "UiContext.h"
|
||||
@@ -30,16 +31,23 @@ using namespace OpenRCT2::Ui;
|
||||
* Main entry point for non-Windows sytems. Windows instead uses its own DLL proxy.
|
||||
*/
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
core_init();
|
||||
int runGame = cmdline_run((const char * *)argv, argc);
|
||||
if (runGame == 1)
|
||||
{
|
||||
// Run OpenRCT2 with a UI context
|
||||
|
||||
IAudioContext * audioContext = CreateAudioContext();
|
||||
IUiContext * uiContext = CreateUiContext();
|
||||
IContext * context = CreateContext(audioContext, uiContext);
|
||||
int exitCode = context->RunOpenRCT2(argc, argv);
|
||||
delete uiContext;
|
||||
|
||||
context->RunOpenRCT2(argc, argv);
|
||||
|
||||
delete context;
|
||||
return exitCode;
|
||||
delete uiContext;
|
||||
delete audioContext;
|
||||
}
|
||||
return gExitCode;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -123,14 +123,9 @@ namespace OpenRCT2
|
||||
}
|
||||
|
||||
sint32 RunOpenRCT2(int argc, char * * argv) override
|
||||
{
|
||||
core_init();
|
||||
int runGame = cmdline_run((const char * *)argv, argc);
|
||||
if (runGame == 1)
|
||||
{
|
||||
Initialise();
|
||||
Launch();
|
||||
}
|
||||
return gExitCode;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user