From 4fb25ff5efe48ca8f594ce5b5d2839cb244018a9 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 17 Dec 2024 16:32:10 -0500 Subject: Added solved panels over IPC --- src/ipc_state.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/ipc_state.cpp') diff --git a/src/ipc_state.cpp b/src/ipc_state.cpp index 18f318f..c0bdc9b 100644 --- a/src/ipc_state.cpp +++ b/src/ipc_state.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,7 @@ struct IPCState { std::string game_ap_user; std::optional> player_position; + std::set solved_panels; int backoff_amount = 0; @@ -77,6 +79,12 @@ struct IPCState { return player_position; } + const std::set& GetSolvedPanels() { + std::lock_guard state_guard(state_mutex); + + return solved_panels; + } + private: void Thread() { for (;;) { @@ -137,7 +145,17 @@ struct IPCState { } } - void OnConnect() { connected = true; } + void OnConnect() { + connected = true; + + { + std::lock_guard state_guard(state_mutex); + + slot_matches = false; + player_position = std::nullopt; + solved_panels.clear(); + } + } void OnClose() { connected = false; @@ -168,6 +186,14 @@ struct IPCState { std::make_tuple(msg["position"]["x"], msg["position"]["z"]); tracker_frame->RedrawPosition(); + } else if (msg["cmd"] == "SolvePanels") { + std::lock_guard state_guard(state_mutex); + + for (std::string panel : msg["panels"]) { + solved_panels.insert(std::move(panel)); + } + + tracker_frame->UpdateIndicators(kUPDATE_ONLY_PANELS); } } @@ -229,3 +255,7 @@ bool IPC_IsConnected() { return GetState().IsConnected(); } std::optional> IPC_GetPlayerPosition() { return GetState().GetPlayerPosition(); } + +const std::set& IPC_GetSolvedPanels() { + return GetState().GetSolvedPanels(); +} -- cgit 1.4.1