From 786b7481c47ecf54306e5d8a6c1e173f222b7ea8 Mon Sep 17 00:00:00 2001 From: Jerom Venneker Date: Mon, 30 Jun 2025 19:34:45 +0200 Subject: [PATCH] Added Disconnecting from the server when selecting new game and backing out of name select --- soh/soh/Network/Archipelago/Archipelago.cpp | 6 ++++++ soh/soh/OTRGlobals.cpp | 4 ++++ soh/soh/OTRGlobals.h | 1 + .../gamestates/ovl_file_choose/z_file_choose.c | 12 ++++++++++-- .../gamestates/ovl_file_choose/z_file_nameset_PAL.c | 2 ++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/soh/soh/Network/Archipelago/Archipelago.cpp b/soh/soh/Network/Archipelago/Archipelago.cpp index 2a024facc..b8196ebaf 100644 --- a/soh/soh/Network/Archipelago/Archipelago.cpp +++ b/soh/soh/Network/Archipelago/Archipelago.cpp @@ -206,6 +206,11 @@ bool ArchipelagoClient::StartClient() { return true; } +bool ArchipelagoClient::StopClient() { + disconnecting = true; + return true; +} + void ArchipelagoClient::GameLoaded() { if(apClient == nullptr) { return; @@ -387,6 +392,7 @@ void ArchipelagoClient::Poll() { apClient->reset(); apClient = nullptr; disconnecting = false; + CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 0); // disconnected return; } diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 831d7a3aa..0895aebd3 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -2169,6 +2169,10 @@ extern "C" void Archipelago_Connect() { ArchipelagoClient::GetInstance().StartClient(); } +extern "C" void Archipelago_Disconnect() { + ArchipelagoClient::GetInstance().StopClient(); +} + extern "C" void Archipelago_ShowArchipelagoMenu() { SohGui::ShowArchipelagoSettingsMenu(); } diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 864a80af8..0bfad7555 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -157,6 +157,7 @@ void Randomizer_SetSpoilerLoaded(bool spoilerLoaded); uint8_t Randomizer_GenerateRandomizer(); void Randomizer_ShowRandomizerMenu(); void Archipelago_Connect(); +void Archipelago_Disconnect(); void Archipelago_ShowArchipelagoMenu(); int CustomMessage_RetrieveIfExists(PlayState* play); void Overlay_DisplayText(float duration, const char* text); diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 333a29431..358810cb2 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -1699,6 +1699,8 @@ void FileChoose_RotateToMain(GameState* thisx) { void FileChoose_RotateToQuest(GameState* thisx) { FileChooseContext* this = (FileChooseContext*)thisx; + Archipelago_Disconnect(); + if (this->configMode == CM_NAME_ENTRY_TO_QUEST_MENU || this->configMode == CM_BOSS_RUSH_TO_QUEST || this->configMode == CM_RANDOMIZER_SETTINGS_MENU_TO_QUEST || this->configMode == CM_ARCHIPELAGO_SETTINGS_TO_QUEST) { @@ -1859,6 +1861,8 @@ void FileChoose_UpdateArchipelagoMenu(GameState* thisx) { void FileChoose_StartArchipelagoMenu(GameState* thisx) { FileChooseContext* this = (FileChooseContext*)thisx; + Archipelago_Disconnect(); + fileSelectArchipelagoLoaded = false; this->logoAlpha -= 25; this->archipelagoUIAlpha = 0; @@ -3163,7 +3167,9 @@ void FileChoose_ConfigModeDraw(GameState* thisx) { if (this->configMode != CM_NAME_ENTRY && this->configMode != CM_START_NAME_ENTRY && this->configMode != CM_QUEST_MENU && this->configMode != CM_NAME_ENTRY_TO_QUEST_MENU && this->configMode != CM_RANDOMIZER_SETTINGS_MENU && - this->configMode != CM_NAME_ENTRY_TO_RANDOMIZER_SETTINGS_MENU) { + this->configMode != CM_NAME_ENTRY_TO_RANDOMIZER_SETTINGS_MENU && + this->configMode != CM_ARCHIPELAGO_SETTINGS_MENU && + this->configMode != CM_NAME_ENTRY_TO_ARCHIPELAGO_SETTINGS_MENU) { gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2], @@ -3273,7 +3279,9 @@ void FileChoose_ConfigModeDraw(GameState* thisx) { this->configMode == CM_NAME_ENTRY_TO_QUEST_MENU || this->configMode == CM_ROTATE_TO_BOSS_RUSH_MENU || this->configMode == CM_ROTATE_TO_RANDOMIZER_SETTINGS_MENU || this->configMode == CM_ROTATE_TO_ARCHIPELAGO_MENU || - this->configMode == CM_NAME_ENTRY_TO_RANDOMIZER_SETTINGS_MENU) { + this->configMode == CM_NAME_ENTRY_TO_RANDOMIZER_SETTINGS_MENU || + this->configMode == CM_ARCHIPELAGO_SETTINGS_MENU || + this->configMode == CM_NAME_ENTRY_TO_ARCHIPELAGO_SETTINGS_MENU) { // window gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c index d82ec3844..308c7e7bd 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c @@ -379,6 +379,8 @@ void FileChoose_DrawNameEntry(GameState* thisx) { this->configMode = CM_NAME_ENTRY_TO_QUEST_MENU; } else if (this->prevConfigMode == CM_RANDOMIZER_SETTINGS_MENU) { this->configMode = CM_NAME_ENTRY_TO_RANDOMIZER_SETTINGS_MENU; + } else if (this->prevConfigMode = CM_ARCHIPELAGO_SETTINGS_MENU) { + this->configMode = CM_NAME_ENTRY_TO_ARCHIPELAGO_SETTINGS_MENU; } else { this->configMode = CM_NAME_ENTRY_TO_MAIN; }