mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Merge pull request #21965 from AaronVanGeffen/fix-cli-editor
Fix loading editor from command line
This commit is contained in:
@@ -902,22 +902,8 @@ namespace OpenRCT2
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
IScene* DetermineStartUpScene()
|
||||||
* Launches the game, after command line arguments have been parsed and processed.
|
|
||||||
*/
|
|
||||||
void Launch()
|
|
||||||
{
|
{
|
||||||
if (!_versionCheckFuture.valid())
|
|
||||||
{
|
|
||||||
_versionCheckFuture = std::async(std::launch::async, [this] {
|
|
||||||
_newVersionInfo = GetLatestVersion();
|
|
||||||
if (!String::StartsWith(gVersionInfoTag, _newVersionInfo.tag))
|
|
||||||
{
|
|
||||||
_hasNewVersionInfo = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gOpenRCT2Headless)
|
if (gOpenRCT2Headless)
|
||||||
{
|
{
|
||||||
// NONE or OPEN are the only allowed actions for headless mode
|
// NONE or OPEN are the only allowed actions for headless mode
|
||||||
@@ -937,11 +923,15 @@ namespace OpenRCT2
|
|||||||
switch (gOpenRCT2StartupAction)
|
switch (gOpenRCT2StartupAction)
|
||||||
{
|
{
|
||||||
case StartupAction::Intro:
|
case StartupAction::Intro:
|
||||||
SetActiveScene(GetIntroScene());
|
{
|
||||||
break;
|
return GetIntroScene();
|
||||||
|
}
|
||||||
|
|
||||||
case StartupAction::Title:
|
case StartupAction::Title:
|
||||||
SetActiveScene(GetTitleScene());
|
{
|
||||||
break;
|
return GetTitleScene();
|
||||||
|
}
|
||||||
|
|
||||||
case StartupAction::Open:
|
case StartupAction::Open:
|
||||||
{
|
{
|
||||||
// A path that includes "://" is illegal with all common filesystems, so it is almost certainly a URL
|
// A path that includes "://" is illegal with all common filesystems, so it is almost certainly a URL
|
||||||
@@ -953,16 +943,14 @@ namespace OpenRCT2
|
|||||||
auto data = DownloadPark(gOpenRCT2StartupActionPath);
|
auto data = DownloadPark(gOpenRCT2StartupActionPath);
|
||||||
if (data.empty())
|
if (data.empty())
|
||||||
{
|
{
|
||||||
SetActiveScene(GetTitleScene());
|
return GetTitleScene();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ms = MemoryStream(data.data(), data.size(), MEMORY_ACCESS::READ);
|
auto ms = MemoryStream(data.data(), data.size(), MEMORY_ACCESS::READ);
|
||||||
if (!LoadParkFromStream(&ms, gOpenRCT2StartupActionPath, true))
|
if (!LoadParkFromStream(&ms, gOpenRCT2StartupActionPath, true))
|
||||||
{
|
{
|
||||||
Console::Error::WriteLine("Failed to load '%s'", gOpenRCT2StartupActionPath);
|
Console::Error::WriteLine("Failed to load '%s'", gOpenRCT2StartupActionPath);
|
||||||
SetActiveScene(GetTitleScene());
|
return GetTitleScene();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -972,67 +960,94 @@ namespace OpenRCT2
|
|||||||
{
|
{
|
||||||
if (!LoadParkFromFile(gOpenRCT2StartupActionPath, true))
|
if (!LoadParkFromFile(gOpenRCT2StartupActionPath, true))
|
||||||
{
|
{
|
||||||
break;
|
return GetTitleScene();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception& ex)
|
catch (const std::exception& ex)
|
||||||
{
|
{
|
||||||
Console::Error::WriteLine("Failed to load '%s'", gOpenRCT2StartupActionPath);
|
Console::Error::WriteLine("Failed to load '%s'", gOpenRCT2StartupActionPath);
|
||||||
Console::Error::WriteLine("%s", ex.what());
|
Console::Error::WriteLine("%s", ex.what());
|
||||||
SetActiveScene(GetTitleScene());
|
return GetTitleScene();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetActiveScene(GetGameScene());
|
// Successfully loaded a file
|
||||||
|
return GetGameScene();
|
||||||
#ifndef DISABLE_NETWORK
|
|
||||||
if (gNetworkStart == NETWORK_MODE_SERVER)
|
|
||||||
{
|
|
||||||
if (gNetworkStartPort == 0)
|
|
||||||
{
|
|
||||||
gNetworkStartPort = gConfigNetwork.DefaultPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gNetworkStartAddress.empty())
|
|
||||||
{
|
|
||||||
gNetworkStartAddress = gConfigNetwork.ListenAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gCustomPassword.empty())
|
|
||||||
{
|
|
||||||
_network.SetPassword(gConfigNetwork.DefaultPassword.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_network.SetPassword(gCustomPassword);
|
|
||||||
}
|
|
||||||
_network.BeginServer(gNetworkStartPort, gNetworkStartAddress);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif // DISABLE_NETWORK
|
|
||||||
{
|
|
||||||
GameLoadScripts();
|
|
||||||
GameNotifyMapChanged();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case StartupAction::Edit:
|
case StartupAction::Edit:
|
||||||
|
{
|
||||||
if (String::SizeOf(gOpenRCT2StartupActionPath) == 0)
|
if (String::SizeOf(gOpenRCT2StartupActionPath) == 0)
|
||||||
{
|
{
|
||||||
Editor::Load();
|
Editor::Load();
|
||||||
|
return GetGameScene();
|
||||||
}
|
}
|
||||||
else if (!Editor::LoadLandscape(gOpenRCT2StartupActionPath))
|
else if (Editor::LoadLandscape(gOpenRCT2StartupActionPath))
|
||||||
{
|
{
|
||||||
SetActiveScene(GetTitleScene());
|
return GetGameScene();
|
||||||
}
|
}
|
||||||
break;
|
[[fallthrough]];
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
{
|
||||||
|
return GetTitleScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launches the game, after command line arguments have been parsed and processed.
|
||||||
|
*/
|
||||||
|
void Launch()
|
||||||
|
{
|
||||||
|
if (!_versionCheckFuture.valid())
|
||||||
|
{
|
||||||
|
_versionCheckFuture = std::async(std::launch::async, [this] {
|
||||||
|
_newVersionInfo = GetLatestVersion();
|
||||||
|
if (!String::StartsWith(gVersionInfoTag, _newVersionInfo.tag))
|
||||||
|
{
|
||||||
|
_hasNewVersionInfo = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
auto* scene = DetermineStartUpScene();
|
||||||
|
SetActiveScene(scene);
|
||||||
|
|
||||||
|
if (scene == GetGameScene())
|
||||||
|
{
|
||||||
|
#ifndef DISABLE_NETWORK
|
||||||
|
if (gNetworkStart == NETWORK_MODE_SERVER)
|
||||||
|
{
|
||||||
|
if (gNetworkStartPort == 0)
|
||||||
|
{
|
||||||
|
gNetworkStartPort = gConfigNetwork.DefaultPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gNetworkStartAddress.empty())
|
||||||
|
{
|
||||||
|
gNetworkStartAddress = gConfigNetwork.ListenAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gCustomPassword.empty())
|
||||||
|
{
|
||||||
|
_network.SetPassword(gConfigNetwork.DefaultPassword.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_network.SetPassword(gCustomPassword);
|
||||||
|
}
|
||||||
|
_network.BeginServer(gNetworkStartPort, gNetworkStartAddress);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // DISABLE_NETWORK
|
||||||
|
{
|
||||||
|
GameLoadScripts();
|
||||||
|
GameNotifyMapChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_NETWORK
|
#ifndef DISABLE_NETWORK
|
||||||
if (gNetworkStart == NETWORK_MODE_CLIENT)
|
else if (gNetworkStart == NETWORK_MODE_CLIENT)
|
||||||
{
|
{
|
||||||
if (gNetworkStartPort == 0)
|
if (gNetworkStartPort == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user