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 void FreeCommandLineArgs(int argc, char * * argv);
|
||||||
static char * ConvertUTF16toUTF8(const wchar_t * src);
|
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)
|
DLLEXPORT int LaunchOpenRCT2(int argc, wchar_t * * argvW)
|
||||||
{
|
{
|
||||||
char * * argv = GetCommandLineArgs(argc, argvW);
|
char * * argv = GetCommandLineArgs(argc, argvW);
|
||||||
@@ -46,15 +65,7 @@ DLLEXPORT int LaunchOpenRCT2(int argc, wchar_t * * argvW)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
IAudioContext * audioContext = CreateAudioContext();
|
int exitCode = NormalisedMain(argc, argv);
|
||||||
IUiContext * uiContext = CreateUiContext();
|
|
||||||
IContext * context = CreateContext(audioContext, uiContext);
|
|
||||||
|
|
||||||
int exitCode = context->RunOpenRCT2(argc, argv);
|
|
||||||
|
|
||||||
delete context;
|
|
||||||
delete uiContext;
|
|
||||||
delete audioContext;
|
|
||||||
|
|
||||||
FreeCommandLineArgs(argc, argv);
|
FreeCommandLineArgs(argc, argv);
|
||||||
return exitCode;
|
return exitCode;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <openrct2/audio/AudioContext.h>
|
#include <openrct2/audio/AudioContext.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
|
#include <openrct2/OpenRCT2.h>
|
||||||
#include <openrct2/ui/UiContext.h>
|
#include <openrct2/ui/UiContext.h>
|
||||||
#include "audio/AudioContext.h"
|
#include "audio/AudioContext.h"
|
||||||
#include "UiContext.h"
|
#include "UiContext.h"
|
||||||
@@ -31,15 +32,22 @@ using namespace OpenRCT2::Ui;
|
|||||||
*/
|
*/
|
||||||
int main(int argc, char * * argv)
|
int main(int argc, char * * argv)
|
||||||
{
|
{
|
||||||
// Run OpenRCT2 with a UI context
|
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);
|
||||||
|
|
||||||
IAudioContext * audioContext = CreateAudioContext();
|
context->RunOpenRCT2(argc, argv);
|
||||||
IUiContext * uiContext = CreateUiContext();
|
|
||||||
IContext * context = CreateContext(audioContext, uiContext);
|
delete context;
|
||||||
int exitCode = context->RunOpenRCT2(argc, argv);
|
delete uiContext;
|
||||||
delete uiContext;
|
delete audioContext;
|
||||||
delete context;
|
}
|
||||||
return exitCode;
|
return gExitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -124,13 +124,8 @@ namespace OpenRCT2
|
|||||||
|
|
||||||
sint32 RunOpenRCT2(int argc, char * * argv) override
|
sint32 RunOpenRCT2(int argc, char * * argv) override
|
||||||
{
|
{
|
||||||
core_init();
|
Initialise();
|
||||||
int runGame = cmdline_run((const char * *)argv, argc);
|
Launch();
|
||||||
if (runGame == 1)
|
|
||||||
{
|
|
||||||
Initialise();
|
|
||||||
Launch();
|
|
||||||
}
|
|
||||||
return gExitCode;
|
return gExitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user