From 03c93484fd72a360b885c2120a66f1dabb5f258c Mon Sep 17 00:00:00 2001 From: Jerom Venneker Date: Fri, 30 May 2025 11:36:34 +0200 Subject: [PATCH] Added Error messages when attempting to send messages while disconnected and when attempting to use local commands --- soh/soh/Network/Archipelago/Archipelago.cpp | 13 ++++++++++--- soh/soh/Network/Archipelago/Archipelago.h | 2 +- .../Archipelago/ArchipelagoConsoleWindow.cpp | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/soh/soh/Network/Archipelago/Archipelago.cpp b/soh/soh/Network/Archipelago/Archipelago.cpp index 1990f7c1c..c6e495608 100644 --- a/soh/soh/Network/Archipelago/Archipelago.cpp +++ b/soh/soh/Network/Archipelago/Archipelago.cpp @@ -342,12 +342,19 @@ void ArchipelagoClient::SendGameWon() { } } -void ArchipelagoClient::SendMessage(const char* message) { - if(apClient == nullptr) { +void ArchipelagoClient::SendMessage(const std::string message) { + // local commands not implemented yet + if(message.starts_with("/")) { + ArchipelagoConsole_SendMessage("Ship of Harkinian does not have any local commands yet.\nUse !help\" to see server commands instead", false); return; } - apClient->Say(std::string(message)); + if(apClient == nullptr) { + ArchipelagoConsole_SendMessage("[ERROR] Could not send message. Please Connect to your slot.", false); + return; + } + + apClient->Say(message); } void ArchipelagoClient::Poll() { diff --git a/soh/soh/Network/Archipelago/Archipelago.h b/soh/soh/Network/Archipelago/Archipelago.h index a2056c71a..fecb6038a 100644 --- a/soh/soh/Network/Archipelago/Archipelago.h +++ b/soh/soh/Network/Archipelago/Archipelago.h @@ -58,7 +58,7 @@ class ArchipelagoClient{ void QueueExternalCheck(int64_t apLocation); void SendGameWon(); - void SendMessage(const char* message); + void SendMessage(const std::string message); void Poll(); std::unique_ptr apClient; diff --git a/soh/soh/Network/Archipelago/ArchipelagoConsoleWindow.cpp b/soh/soh/Network/Archipelago/ArchipelagoConsoleWindow.cpp index 66a91d692..b1580711f 100644 --- a/soh/soh/Network/Archipelago/ArchipelagoConsoleWindow.cpp +++ b/soh/soh/Network/Archipelago/ArchipelagoConsoleWindow.cpp @@ -75,14 +75,14 @@ void ArchipelagoConsoleWindow::DrawElement() { keepFocus = false; } if(ImGui::InputText("##AP_MessageField", textEntryBuf, 1023, ImGuiInputTextFlags_EnterReturnsTrue)) { - ArchipelagoClient::GetInstance().SendMessage(textEntryBuf); + ArchipelagoClient::GetInstance().SendMessage(std::string(textEntryBuf)); textEntryBuf[0] = '\0'; keepFocus = true; } //keepFocus = ImGui::IsItemActive(); ImGui::SameLine(); if(ImGui::Button("Send")) { - ArchipelagoClient::GetInstance().SendMessage(textEntryBuf); + ArchipelagoClient::GetInstance().SendMessage(std::string(textEntryBuf)); textEntryBuf[0] = '\0'; keepFocus = true; }