diff --git a/soh/soh/Network/Anchor/Anchor.cpp b/soh/soh/Network/Anchor/Anchor.cpp index 7d1b701ab..bc40f13b5 100644 --- a/soh/soh/Network/Anchor/Anchor.cpp +++ b/soh/soh/Network/Anchor/Anchor.cpp @@ -383,6 +383,15 @@ void Anchor::DrawMenu() { ImGui::EndMenu(); } } + + if (ImGui::Button("Request Team State", ImVec2(ImGui::GetContentRegionAvail().x - 25.0f, 0.0f))) { + SendPacket_RequestTeamState(); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_TRASH)) { + SendPacket_ClearTeamState(); + } + UIWidgets::Tooltip("Clear Team State"); } else { ImGui::Text("Connecting..."); } diff --git a/soh/soh/Network/Anchor/Anchor.h b/soh/soh/Network/Anchor/Anchor.h index eceb02c1d..16e3dd142 100644 --- a/soh/soh/Network/Anchor/Anchor.h +++ b/soh/soh/Network/Anchor/Anchor.h @@ -133,6 +133,7 @@ class Anchor : public Network { void SendJsonToRemote(nlohmann::json packet); bool IsSaveLoaded(); + void SendPacket_ClearTeamState(); void SendPacket_ConsumeAdultTradeItem(u8 itemId); void SendPacket_DamagePlayer(u32 clientId, u8 damageEffect, u8 damage); void SendPacket_EntranceDiscovered(u16 entranceIndex); diff --git a/soh/soh/Network/Anchor/AnchorRoomWindow.cpp b/soh/soh/Network/Anchor/AnchorRoomWindow.cpp index 7a683eca0..4e20713ad 100644 --- a/soh/soh/Network/Anchor/AnchorRoomWindow.cpp +++ b/soh/soh/Network/Anchor/AnchorRoomWindow.cpp @@ -49,6 +49,8 @@ void AnchorRoomWindow::Draw() { continue; } + ImGui::PushID(clientId); + if (client.clientId == Anchor::Instance->roomState.ownerClientId) { ImGui::TextColored(ImVec4(1, 1, 0, 1), "%s", ICON_FA_GAVEL); ImGui::SameLine(); @@ -58,6 +60,7 @@ void AnchorRoomWindow::Draw() { ImGui::TextColored(ImVec4(0.8f, 1.0f, 0.8f, 1.0f), "%s", CVarGetString(CVAR_REMOTE_ANCHOR("Name"), "")); } else if (!client.online) { ImGui::TextColored(ImVec4(1, 1, 1, 0.3f), "%s - offline", client.name.c_str()); + ImGui::PopID(); continue; } else { ImGui::Text("%s", client.name.c_str()); @@ -105,6 +108,7 @@ void AnchorRoomWindow::Draw() { ImGui::EndTooltip(); } } + ImGui::PopID(); } } diff --git a/soh/soh/Network/Anchor/Packets/EntranceDiscovered.cpp b/soh/soh/Network/Anchor/Packets/EntranceDiscovered.cpp index f5c27a82f..71773dcfd 100644 --- a/soh/soh/Network/Anchor/Packets/EntranceDiscovered.cpp +++ b/soh/soh/Network/Anchor/Packets/EntranceDiscovered.cpp @@ -7,12 +7,14 @@ #include "soh/Enhancements/randomizer/randomizer_entrance.h" #include "soh/OTRGlobals.h" +static bool isResultOfHandling = false; + /** * ENTRANCE_DISCOVERED */ void Anchor::SendPacket_EntranceDiscovered(u16 entranceIndex) { - if (!IsSaveLoaded()) { + if (!IsSaveLoaded() || isResultOfHandling) { return; } @@ -30,8 +32,10 @@ void Anchor::HandlePacket_EntranceDiscovered(nlohmann::json payload) { return; } + isResultOfHandling = true; u16 entranceIndex = payload["entranceIndex"].get(); Entrance_SetEntranceDiscovered(entranceIndex, 1); + isResultOfHandling = false; } #endif // ENABLE_REMOTE_CONTROL diff --git a/soh/soh/Network/Anchor/Packets/RequestTeamState.cpp b/soh/soh/Network/Anchor/Packets/RequestTeamState.cpp index f2a556dd1..88638b082 100644 --- a/soh/soh/Network/Anchor/Packets/RequestTeamState.cpp +++ b/soh/soh/Network/Anchor/Packets/RequestTeamState.cpp @@ -19,6 +19,10 @@ */ void Anchor::SendPacket_RequestTeamState() { + if (!IsSaveLoaded()) { + return; + } + nlohmann::json payload; payload["type"] = REQUEST_TEAM_STATE; payload["targetTeamId"] = CVarGetString(CVAR_REMOTE_ANCHOR("TeamId"), "default"); diff --git a/soh/soh/Network/Anchor/Packets/SetFlag.cpp b/soh/soh/Network/Anchor/Packets/SetFlag.cpp index b7438ab95..693c75350 100644 --- a/soh/soh/Network/Anchor/Packets/SetFlag.cpp +++ b/soh/soh/Network/Anchor/Packets/SetFlag.cpp @@ -13,6 +13,10 @@ */ void Anchor::SendPacket_SetFlag(s16 sceneNum, s16 flagType, s16 flag) { + if (!IsSaveLoaded()) { + return; + } + nlohmann::json payload; payload["type"] = SET_FLAG; payload["targetTeamId"] = CVarGetString(CVAR_REMOTE_ANCHOR("TeamId"), "default"); diff --git a/soh/soh/Network/Anchor/Packets/UnsetFlag.cpp b/soh/soh/Network/Anchor/Packets/UnsetFlag.cpp index 91da3f9b1..5de78595a 100644 --- a/soh/soh/Network/Anchor/Packets/UnsetFlag.cpp +++ b/soh/soh/Network/Anchor/Packets/UnsetFlag.cpp @@ -13,6 +13,10 @@ */ void Anchor::SendPacket_UnsetFlag(s16 sceneNum, s16 flagType, s16 flag) { + if (!IsSaveLoaded()) { + return; + } + nlohmann::json payload; payload["type"] = UNSET_FLAG; payload["targetTeamId"] = CVarGetString(CVAR_REMOTE_ANCHOR("TeamId"), "default"); diff --git a/soh/soh/Network/Anchor/Packets/UpdateTeamState.cpp b/soh/soh/Network/Anchor/Packets/UpdateTeamState.cpp index fb937b4d1..d17981f4f 100644 --- a/soh/soh/Network/Anchor/Packets/UpdateTeamState.cpp +++ b/soh/soh/Network/Anchor/Packets/UpdateTeamState.cpp @@ -105,6 +105,20 @@ void Anchor::SendPacket_UpdateTeamState() { SendJsonToRemote(payload); } +void Anchor::SendPacket_ClearTeamState() { + if (!IsSaveLoaded()) { + return; + } + + json payload; + payload["type"] = UPDATE_TEAM_STATE; + payload["targetTeamId"] = CVarGetString(CVAR_REMOTE_ANCHOR("TeamId"), "default"); + + payload["queue"] = json::array(); + payload["state"] = json::object(); + SendJsonToRemote(payload); +} + void Anchor::HandlePacket_UpdateTeamState(nlohmann::json payload) { isHandlingUpdateTeamState = true; // This can happen in between file select and the game starting, so we cant use this check, but we need to ensure we