From 5a814085fa888d3fa7d1523b84abfe37aca2e3ee Mon Sep 17 00:00:00 2001 From: blattersturm Date: Mon, 17 Jan 2022 16:10:47 +0100 Subject: [PATCH] fix(ros): launch order edge case --- .../src/ros/SubprocessTool.cpp | 66 ++++++++++--------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/code/components/ros-patches-five/src/ros/SubprocessTool.cpp b/code/components/ros-patches-five/src/ros/SubprocessTool.cpp index 53089afed6..d34454e5d4 100644 --- a/code/components/ros-patches-five/src/ros/SubprocessTool.cpp +++ b/code/components/ros-patches-five/src/ros/SubprocessTool.cpp @@ -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]() @@ -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", ""); @@ -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) { @@ -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(); } } }