Skip to content

Commit 69d6631

Browse files
Some tweaks to WIP (#4706)
1 parent d725125 commit 69d6631

File tree

8 files changed

+45
-1
lines changed

8 files changed

+45
-1
lines changed

soh/soh/Network/Anchor/Anchor.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,15 @@ void Anchor::DrawMenu() {
383383
ImGui::EndMenu();
384384
}
385385
}
386+
387+
if (ImGui::Button("Request Team State", ImVec2(ImGui::GetContentRegionAvail().x - 25.0f, 0.0f))) {
388+
SendPacket_RequestTeamState();
389+
}
390+
ImGui::SameLine();
391+
if (ImGui::Button(ICON_FA_TRASH)) {
392+
SendPacket_ClearTeamState();
393+
}
394+
UIWidgets::Tooltip("Clear Team State");
386395
} else {
387396
ImGui::Text("Connecting...");
388397
}

soh/soh/Network/Anchor/Anchor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ class Anchor : public Network {
133133
void SendJsonToRemote(nlohmann::json packet);
134134
bool IsSaveLoaded();
135135

136+
void SendPacket_ClearTeamState();
136137
void SendPacket_ConsumeAdultTradeItem(u8 itemId);
137138
void SendPacket_DamagePlayer(u32 clientId, u8 damageEffect, u8 damage);
138139
void SendPacket_EntranceDiscovered(u16 entranceIndex);

soh/soh/Network/Anchor/AnchorRoomWindow.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ void AnchorRoomWindow::Draw() {
4949
continue;
5050
}
5151

52+
ImGui::PushID(clientId);
53+
5254
if (client.clientId == Anchor::Instance->roomState.ownerClientId) {
5355
ImGui::TextColored(ImVec4(1, 1, 0, 1), "%s", ICON_FA_GAVEL);
5456
ImGui::SameLine();
@@ -58,6 +60,7 @@ void AnchorRoomWindow::Draw() {
5860
ImGui::TextColored(ImVec4(0.8f, 1.0f, 0.8f, 1.0f), "%s", CVarGetString(CVAR_REMOTE_ANCHOR("Name"), ""));
5961
} else if (!client.online) {
6062
ImGui::TextColored(ImVec4(1, 1, 1, 0.3f), "%s - offline", client.name.c_str());
63+
ImGui::PopID();
6164
continue;
6265
} else {
6366
ImGui::Text("%s", client.name.c_str());
@@ -105,6 +108,7 @@ void AnchorRoomWindow::Draw() {
105108
ImGui::EndTooltip();
106109
}
107110
}
111+
ImGui::PopID();
108112
}
109113
}
110114

soh/soh/Network/Anchor/Packets/EntranceDiscovered.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
#include "soh/Enhancements/randomizer/randomizer_entrance.h"
88
#include "soh/OTRGlobals.h"
99

10+
static bool isResultOfHandling = false;
11+
1012
/**
1113
* ENTRANCE_DISCOVERED
1214
*/
1315

1416
void Anchor::SendPacket_EntranceDiscovered(u16 entranceIndex) {
15-
if (!IsSaveLoaded()) {
17+
if (!IsSaveLoaded() || isResultOfHandling) {
1618
return;
1719
}
1820

@@ -30,8 +32,10 @@ void Anchor::HandlePacket_EntranceDiscovered(nlohmann::json payload) {
3032
return;
3133
}
3234

35+
isResultOfHandling = true;
3336
u16 entranceIndex = payload["entranceIndex"].get<u16>();
3437
Entrance_SetEntranceDiscovered(entranceIndex, 1);
38+
isResultOfHandling = false;
3539
}
3640

3741
#endif // ENABLE_REMOTE_CONTROL

soh/soh/Network/Anchor/Packets/RequestTeamState.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
*/
2020

2121
void Anchor::SendPacket_RequestTeamState() {
22+
if (!IsSaveLoaded()) {
23+
return;
24+
}
25+
2226
nlohmann::json payload;
2327
payload["type"] = REQUEST_TEAM_STATE;
2428
payload["targetTeamId"] = CVarGetString(CVAR_REMOTE_ANCHOR("TeamId"), "default");

soh/soh/Network/Anchor/Packets/SetFlag.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
*/
1414

1515
void Anchor::SendPacket_SetFlag(s16 sceneNum, s16 flagType, s16 flag) {
16+
if (!IsSaveLoaded()) {
17+
return;
18+
}
19+
1620
nlohmann::json payload;
1721
payload["type"] = SET_FLAG;
1822
payload["targetTeamId"] = CVarGetString(CVAR_REMOTE_ANCHOR("TeamId"), "default");

soh/soh/Network/Anchor/Packets/UnsetFlag.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
*/
1414

1515
void Anchor::SendPacket_UnsetFlag(s16 sceneNum, s16 flagType, s16 flag) {
16+
if (!IsSaveLoaded()) {
17+
return;
18+
}
19+
1620
nlohmann::json payload;
1721
payload["type"] = UNSET_FLAG;
1822
payload["targetTeamId"] = CVarGetString(CVAR_REMOTE_ANCHOR("TeamId"), "default");

soh/soh/Network/Anchor/Packets/UpdateTeamState.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,20 @@ void Anchor::SendPacket_UpdateTeamState() {
105105
SendJsonToRemote(payload);
106106
}
107107

108+
void Anchor::SendPacket_ClearTeamState() {
109+
if (!IsSaveLoaded()) {
110+
return;
111+
}
112+
113+
json payload;
114+
payload["type"] = UPDATE_TEAM_STATE;
115+
payload["targetTeamId"] = CVarGetString(CVAR_REMOTE_ANCHOR("TeamId"), "default");
116+
117+
payload["queue"] = json::array();
118+
payload["state"] = json::object();
119+
SendJsonToRemote(payload);
120+
}
121+
108122
void Anchor::HandlePacket_UpdateTeamState(nlohmann::json payload) {
109123
isHandlingUpdateTeamState = true;
110124
// This can happen in between file select and the game starting, so we cant use this check, but we need to ensure we

0 commit comments

Comments
 (0)