Skip to content

Commit

Permalink
fix(ros): launch order edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
blattersturm committed Jan 17, 2022
1 parent a9c3ec7 commit 5a81408
Showing 1 changed file with 35 additions and 31 deletions.
66 changes: 35 additions & 31 deletions code/components/ros-patches-five/src/ros/SubprocessTool.cpp
Expand Up @@ -186,7 +186,9 @@ struct MyListener : public IPC::Listener, public IPC::MessageReplyDeserializer
static bool verified;
static bool launched;
static bool verifying;
static bool launching;
static bool signInComplete;
static bool signInComplete2;
static bool launchDone;

auto checkVerify = [this, targetTitle]()
Expand All @@ -206,6 +208,35 @@ struct MyListener : public IPC::Listener, public IPC::MessageReplyDeserializer
}
};

auto checkLaunch = [this, targetTitle]()
{
if (signInComplete2 && !launched && launching)
{
launched = true;

for (int i = 0; i < 3; i++)
{
if (launchDone || g_launchDone)
{
break;
}

child->SendJSCallback("RGSC_SET_CLOUD_SAVE_ENABLED", json::object({ { "Enabled", false },
{ "RosTitleName", targetTitle } })
.dump());

child->SendJSCallback("RGSC_RAISE_UI_EVENT", json::object({ { "EventId", 2 }, // LauncherV3UiEvent

{ "Data", json::object({ { "Action", "Launch" },
{ "Parameter", json::object({ { "titleName", targetTitle },
{ "args", "" } }) } }) } })
.dump());

Sleep(10000);
}
}
};

for (json& cmd : j["Commands"])
{
auto c = cmd.value("Command", "");
Expand Down Expand Up @@ -239,7 +270,9 @@ struct MyListener : public IPC::Listener, public IPC::MessageReplyDeserializer
.dump());

signInComplete = true;
signInComplete2 = true;
checkVerify();
checkLaunch();
}
else if (c == "SetTitleInfo") {
if (p.value("titleName", "") == targetTitle) {
Expand All @@ -253,37 +286,8 @@ struct MyListener : public IPC::Listener, public IPC::MessageReplyDeserializer
p["status"].value("updateState", "") == "updateQueued" ||
p["status"].value("updateState", "") == "verifyQueued"))
{
if (!launched)
{
launched = true;

for (int i = 0; i < 3; i++)
{
if (launchDone || g_launchDone)
{
break;
}

child->SendJSCallback("RGSC_SET_CLOUD_SAVE_ENABLED", json::object({
{ "Enabled", false },
{ "RosTitleName", targetTitle }
}).dump());

child->SendJSCallback("RGSC_RAISE_UI_EVENT", json::object({
{ "EventId", 2 }, // LauncherV3UiEvent

{"Data", json::object({
{"Action", "Launch"},
{"Parameter", json::object({
{ "titleName", targetTitle },
{"args", ""}
})}
})}
}).dump());

Sleep(10000);
}
}
launching = true;
checkLaunch();
}
}
}
Expand Down

0 comments on commit 5a81408

Please sign in to comment.