From e204400dbb1a420ad2fc71b555a77de29938281c Mon Sep 17 00:00:00 2001 From: Jerom Venneker Date: Mon, 4 Aug 2025 17:59:35 +0200 Subject: [PATCH 1/6] Changed connection flags to support starting items --- soh/soh/Network/Archipelago/Archipelago.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/soh/Network/Archipelago/Archipelago.cpp b/soh/soh/Network/Archipelago/Archipelago.cpp index 4c87c7d0c..a18093920 100644 --- a/soh/soh/Network/Archipelago/Archipelago.cpp +++ b/soh/soh/Network/Archipelago/Archipelago.cpp @@ -78,7 +78,7 @@ bool ArchipelagoClient::StartClient() { if (CVarGetInteger(CVAR_REMOTE_ARCHIPELAGO("DeathLink"), 0)) { tags.push_back("DeathLink"); } - apClient->ConnectSlot(CVarGetString(CVAR_REMOTE_ARCHIPELAGO("SlotName"), ""), password, 0b001, tags); + apClient->ConnectSlot(CVarGetString(CVAR_REMOTE_ARCHIPELAGO("SlotName"), ""), password, 0b0101, tags); }); apClient->set_slot_connected_handler([&](const nlohmann::json data) { From 799e2c2d5ae00969ec96ac7e91f2d77d8108da08 Mon Sep 17 00:00:00 2001 From: Jerom Venneker Date: Mon, 4 Aug 2025 18:15:55 +0200 Subject: [PATCH 2/6] Cleared up error messages around failed connections --- soh/soh/Network/Archipelago/Archipelago.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/soh/soh/Network/Archipelago/Archipelago.cpp b/soh/soh/Network/Archipelago/Archipelago.cpp index a18093920..9291d0b76 100644 --- a/soh/soh/Network/Archipelago/Archipelago.cpp +++ b/soh/soh/Network/Archipelago/Archipelago.cpp @@ -60,8 +60,7 @@ bool ArchipelagoClient::StartClient() { apClient->set_socket_error_handler([&](const std::string& msg) { retries++; if (retries >= AP_Client_consts::MAX_RETRIES) { - ArchipelagoConsole_SendMessage("[ERROR] Could not connect to server after several tries.\nAre the entered " - "server address and slot name correct?"); + ArchipelagoConsole_SendMessage("[ERROR] Could not connect to server after several tries.\nAre the entered server address and port correct?"); CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 2); // Connection error disconnecting = true; @@ -70,7 +69,7 @@ bool ArchipelagoClient::StartClient() { } return; } - ArchipelagoConsole_SendMessage("[ERROR] Could not connect to server, retrying..."); + ArchipelagoConsole_SendMessage(std::string("[ERROR] " + msg).c_str()); }); apClient->set_room_info_handler([&]() { @@ -111,6 +110,13 @@ bool ArchipelagoClient::StartClient() { } }); + apClient->set_slot_refused_handler([&](const std::list& msgs) { + disconnecting = true; + for(const std::string& msg : msgs) { + ArchipelagoConsole_SendMessage(std::string("[ERROR] "+ msg).c_str()); + } + }); + apClient->set_items_received_handler([&](const std::list& items) { if (disconnecting) { return; From a72660959c7881d2f79ec2524b135899da0c4ea4 Mon Sep 17 00:00:00 2001 From: Jerom Venneker Date: Mon, 4 Aug 2025 21:27:17 +0200 Subject: [PATCH 3/6] Added queueing up song of time check when getting the ocarina of time check when its already been checked remotely --- .../Enhancements/randomizer/hook_handlers.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp index 445b75088..8651e74a4 100644 --- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp +++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp @@ -257,9 +257,10 @@ void RandomizerOnFlagSetHandler(int16_t flagType, int16_t flag) { Rando::Context::GetInstance()->GetOption(RSK_SHUFFLE_TOKENS).Is(RO_TOKENSANITY_OFF)) return; auto loc = Rando::Context::GetInstance()->GetItemLocation(rc); - if (loc == nullptr || loc->HasObtained() || loc->GetPlacedRandomizerGet() == RG_NONE) - return; - + if(rc != RC_HF_OCARINA_OF_TIME_ITEM) { + if (loc == nullptr || loc->HasObtained() || loc->GetPlacedRandomizerGet() == RG_NONE) + return; + } SPDLOG_INFO("Queuing RC: {}", static_cast(rc)); randomizerQueuedChecks.push(rc); } @@ -301,6 +302,12 @@ void RandomizerOnExternalCheckHandler(uint32_t randomizerCheck) { inSameArea = scene == gPlayState->sceneNum; } + // setting the ocarinina obtained event flag + if(rc == RC_HF_OCARINA_OF_TIME_ITEM) { + randomizerQueuedChecks.push(rc); + return; + } + std::string logMessage = ""; switch (loc->GetCollectionCheck().type) { @@ -375,6 +382,10 @@ void RandomizerOnPlayerUpdateForRCQueueHandler() { getItemEntry = Rando::Context::GetInstance()->GetFinalGIEntry(rc, true, (GetItemID)vanillaRandomizerGet); } + if(rc == RC_HF_OCARINA_OF_TIME_ITEM && loc->HasObtained()) { + RandomizerOnExternalCheckHandler(RC_SONG_FROM_OCARINA_OF_TIME); + } + if (loc->HasObtained()) { SPDLOG_INFO("RC {} already obtained, skipping", static_cast(rc)); } else { From 48e869b61f6c11929471e0aafff2df996c967a7e Mon Sep 17 00:00:00 2001 From: Jerom Venneker Date: Wed, 6 Aug 2025 14:32:44 +0200 Subject: [PATCH 4/6] Downloading cert store at build time --- soh/CMakeLists.txt | 13 +++++++++++++ soh/soh/Network/Archipelago/Archipelago.cpp | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/soh/CMakeLists.txt b/soh/CMakeLists.txt index cc38cb6d6..9a39f930f 100644 --- a/soh/CMakeLists.txt +++ b/soh/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required(VERSION 3.26.0 FATAL_ERROR) +include(FetchContent) set(CMAKE_SYSTEM_VERSION 10.0 CACHE STRING "" FORCE) @@ -339,6 +340,18 @@ if (BUILD_REMOTE_CONTROL) message(STATUS "OpenSSL not found (it's possible the version installed is too old). Disabling BUILD_REMOTE_CONTROL.") set(BUILD_REMOTE_CONTROL 0) endif() + + FetchContent_Declare( + sslCertStore + URL https://curl.se/ca/cacert.pem + DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/networking + DOWNLOAD_NO_EXTRACT TRUE + ) + + FetchContent_MakeAvailable( + sslCertStore + ) + endif() if (ESPEAK) diff --git a/soh/soh/Network/Archipelago/Archipelago.cpp b/soh/soh/Network/Archipelago/Archipelago.cpp index 9291d0b76..a75a93cbd 100644 --- a/soh/soh/Network/Archipelago/Archipelago.cpp +++ b/soh/soh/Network/Archipelago/Archipelago.cpp @@ -53,7 +53,7 @@ bool ArchipelagoClient::StartClient() { uri = CVarGetString(CVAR_REMOTE_ARCHIPELAGO("ServerAddress"), "localhost:38281"); password = CVarGetString(CVAR_REMOTE_ARCHIPELAGO("Password"), ""); - apClient = std::unique_ptr(new APClient(uuid, AP_Client_consts::AP_GAME_NAME, uri, "cacert.pem")); + apClient = std::unique_ptr(new APClient(uuid, AP_Client_consts::AP_GAME_NAME, uri, "networking/cacert.pem")); CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 1); // Connecting From bd90e56a6af2e7665c8bebb838e9e5a3123f612a Mon Sep 17 00:00:00 2001 From: Jerom Venneker Date: Wed, 6 Aug 2025 17:04:03 +0200 Subject: [PATCH 5/6] Adding cert to packages --- soh/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/soh/CMakeLists.txt b/soh/CMakeLists.txt index 9a39f930f..4be8f505b 100644 --- a/soh/CMakeLists.txt +++ b/soh/CMakeLists.txt @@ -352,6 +352,8 @@ if (BUILD_REMOTE_CONTROL) sslCertStore ) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/networking/cacert.pem DESTINATION ./networking COMPONENT ship) + endif() if (ESPEAK) From 9774826ad27d5f7c2f6bb72911e48b3d48a75e11 Mon Sep 17 00:00:00 2001 From: Jerom Venneker Date: Wed, 6 Aug 2025 19:50:23 +0200 Subject: [PATCH 6/6] Attempting to load cert from package --- soh/soh/Network/Archipelago/Archipelago.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/soh/soh/Network/Archipelago/Archipelago.cpp b/soh/soh/Network/Archipelago/Archipelago.cpp index a75a93cbd..73a715a45 100644 --- a/soh/soh/Network/Archipelago/Archipelago.cpp +++ b/soh/soh/Network/Archipelago/Archipelago.cpp @@ -53,7 +53,9 @@ bool ArchipelagoClient::StartClient() { uri = CVarGetString(CVAR_REMOTE_ARCHIPELAGO("ServerAddress"), "localhost:38281"); password = CVarGetString(CVAR_REMOTE_ARCHIPELAGO("Password"), ""); - apClient = std::unique_ptr(new APClient(uuid, AP_Client_consts::AP_GAME_NAME, uri, "networking/cacert.pem")); + const std::string cert = Ship::Context::LocateFileAcrossAppDirs("networking/cacert.pem"); + SPDLOG_DEBUG("Location of cert: " + cert); + apClient = std::unique_ptr(new APClient(uuid, AP_Client_consts::AP_GAME_NAME, uri, cert)); CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 1); // Connecting