about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ap_state.cpp41
-rw-r--r--src/ap_state.h2
-rw-r--r--src/area_popup.cpp3
-rw-r--r--src/global.cpp16
-rw-r--r--src/global.h4
-rw-r--r--src/tracker_panel.cpp4
6 files changed, 62 insertions, 8 deletions
diff --git a/src/ap_state.cpp b/src/ap_state.cpp index 5b02ba6..fdc0219 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp
@@ -6,6 +6,7 @@
6 6
7#include <hkutil/string.h> 7#include <hkutil/string.h>
8 8
9#include <any>
9#include <apclient.hpp> 10#include <apclient.hpp>
10#include <apuuid.hpp> 11#include <apuuid.hpp>
11#include <chrono> 12#include <chrono>
@@ -15,6 +16,7 @@
15#include <memory> 16#include <memory>
16#include <mutex> 17#include <mutex>
17#include <set> 18#include <set>
19#include <sstream>
18#include <thread> 20#include <thread>
19#include <tuple> 21#include <tuple>
20 22
@@ -47,10 +49,11 @@ struct APState {
47 49
48 std::string data_storage_prefix; 50 std::string data_storage_prefix;
49 std::list<std::string> tracked_data_storage_keys; 51 std::list<std::string> tracked_data_storage_keys;
52 std::string victory_data_storage_key;
50 53
51 std::map<int64_t, int> inventory; 54 std::map<int64_t, int> inventory;
52 std::set<int64_t> checked_locations; 55 std::set<int64_t> checked_locations;
53 std::map<std::string, bool> data_storage; 56 std::map<std::string, std::any> data_storage;
54 57
55 DoorShuffleMode door_shuffle_mode = kNO_DOORS; 58 DoorShuffleMode door_shuffle_mode = kNO_DOORS;
56 bool color_shuffle = false; 59 bool color_shuffle = false;
@@ -119,6 +122,7 @@ struct APState {
119 inventory.clear(); 122 inventory.clear();
120 checked_locations.clear(); 123 checked_locations.clear();
121 data_storage.clear(); 124 data_storage.clear();
125 victory_data_storage_key.clear();
122 door_shuffle_mode = kNO_DOORS; 126 door_shuffle_mode = kNO_DOORS;
123 color_shuffle = false; 127 color_shuffle = false;
124 painting_shuffle = false; 128 painting_shuffle = false;
@@ -187,6 +191,10 @@ struct APState {
187 data_storage[key] = value.get<bool>(); 191 data_storage[key] = value.get<bool>();
188 TrackerLog("Data storage " + key + " retrieved as " + 192 TrackerLog("Data storage " + key + " retrieved as " +
189 (value.get<bool>() ? "true" : "false")); 193 (value.get<bool>() ? "true" : "false"));
194 } else if (value.is_number()) {
195 data_storage[key] = value.get<int>();
196 TrackerLog("Data storage " + key + " retrieved as " +
197 std::to_string(value.get<int>()));
190 } 198 }
191 } 199 }
192 200
@@ -198,11 +206,15 @@ struct APState {
198 const nlohmann::json&) { 206 const nlohmann::json&) {
199 if (value.is_boolean()) { 207 if (value.is_boolean()) {
200 data_storage[key] = value.get<bool>(); 208 data_storage[key] = value.get<bool>();
201 TrackerLog("Data storage " + key + " set to " + 209 TrackerLog("Data storage " + key + " retrieved as " +
202 (value.get<bool>() ? "true" : "false")); 210 (value.get<bool>() ? "true" : "false"));
203 211 } else if (value.is_number()) {
204 RefreshTracker(); 212 data_storage[key] = value.get<int>();
213 TrackerLog("Data storage " + key + " retrieved as " +
214 std::to_string(value.get<int>()));
205 } 215 }
216
217 RefreshTracker();
206 }); 218 });
207 219
208 apclient->set_slot_connected_handler([this]( 220 apclient->set_slot_connected_handler([this](
@@ -242,6 +254,15 @@ struct APState {
242 corrected_keys.push_back(data_storage_prefix + key); 254 corrected_keys.push_back(data_storage_prefix + key);
243 } 255 }
244 256
257 {
258 std::ostringstream vdsks;
259 vdsks << "_read_client_status_" << apclient->get_team_number() << "_"
260 << apclient->get_player_number();
261 victory_data_storage_key = vdsks.str();
262 }
263
264 corrected_keys.push_back(victory_data_storage_key);
265
245 apclient->Get(corrected_keys); 266 apclient->Get(corrected_keys);
246 apclient->SetNotify(corrected_keys); 267 apclient->SetNotify(corrected_keys);
247 }); 268 });
@@ -321,7 +342,7 @@ struct APState {
321 bool HasCheckedHuntPanel(int location_id) { 342 bool HasCheckedHuntPanel(int location_id) {
322 std::string key = 343 std::string key =
323 data_storage_prefix + "Hunt|" + std::to_string(location_id); 344 data_storage_prefix + "Hunt|" + std::to_string(location_id);
324 return data_storage.count(key) && data_storage.at(key); 345 return data_storage.count(key) && std::any_cast<bool>(data_storage.at(key));
325 } 346 }
326 347
327 bool HasItem(int item_id, int quantity) { 348 bool HasItem(int item_id, int quantity) {
@@ -330,7 +351,7 @@ struct APState {
330 351
331 bool HasAchievement(const std::string& name) { 352 bool HasAchievement(const std::string& name) {
332 std::string key = data_storage_prefix + "Achievement|" + name; 353 std::string key = data_storage_prefix + "Achievement|" + name;
333 return data_storage.count(key) && data_storage.at(key); 354 return data_storage.count(key) && std::any_cast<bool>(data_storage.at(key));
334 } 355 }
335 356
336 void RefreshTracker() { 357 void RefreshTracker() {
@@ -349,6 +370,12 @@ struct APState {
349 return ap_id; 370 return ap_id;
350 } 371 }
351 372
373 bool HasReachedGoal() {
374 return data_storage.count(victory_data_storage_key) &&
375 std::any_cast<int>(data_storage.at(victory_data_storage_key)) ==
376 30; // CLIENT_GOAL
377 }
378
352 void DestroyClient() { 379 void DestroyClient() {
353 client_active = false; 380 client_active = false;
354 apclient->reset(); 381 apclient->reset();
@@ -417,3 +444,5 @@ bool AP_HasAchievement(const std::string& achievement_name) {
417} 444}
418 445
419bool AP_HasEarlyColorHallways() { return GetState().early_color_hallways; } 446bool AP_HasEarlyColorHallways() { return GetState().early_color_hallways; }
447
448bool AP_HasReachedGoal() { return GetState().HasReachedGoal(); }
diff --git a/src/ap_state.h b/src/ap_state.h index 9b94a72..cc51a78 100644 --- a/src/ap_state.h +++ b/src/ap_state.h
@@ -44,4 +44,6 @@ bool AP_HasAchievement(const std::string& achievement_name);
44 44
45bool AP_HasEarlyColorHallways(); 45bool AP_HasEarlyColorHallways();
46 46
47bool AP_HasReachedGoal();
48
47#endif /* end of include guard: AP_STATE_H_664A4180 */ 49#endif /* end of include guard: AP_STATE_H_664A4180 */
diff --git a/src/area_popup.cpp b/src/area_popup.cpp index 9c97d78..3b5d8d4 100644 --- a/src/area_popup.cpp +++ b/src/area_popup.cpp
@@ -87,7 +87,8 @@ void AreaPopup::UpdateIndicators() {
87 87
88 bool checked = 88 bool checked =
89 AP_HasCheckedGameLocation(location.ap_location_id) || 89 AP_HasCheckedGameLocation(location.ap_location_id) ||
90 (location.hunt && AP_HasCheckedHuntPanel(location.ap_location_id)); 90 (location.hunt && AP_HasCheckedHuntPanel(location.ap_location_id)) ||
91 (IsLocationWinCondition(location) && AP_HasReachedGoal());
91 92
92 wxBitmap* eye_ptr = checked ? &checked_eye_ : &unchecked_eye_; 93 wxBitmap* eye_ptr = checked ? &checked_eye_ : &unchecked_eye_;
93 94
diff --git a/src/global.cpp b/src/global.cpp index 3ee4f58..bd0dcaa 100644 --- a/src/global.cpp +++ b/src/global.cpp
@@ -6,6 +6,9 @@
6#include <string> 6#include <string>
7#include <string_view> 7#include <string_view>
8 8
9#include "ap_state.h"
10#include "game_data.h"
11
9const std::filesystem::path& GetExecutableDirectory() { 12const std::filesystem::path& GetExecutableDirectory() {
10 static const std::filesystem::path* executable_directory = []() { 13 static const std::filesystem::path* executable_directory = []() {
11 int length = wai_getExecutablePath(NULL, 0, NULL); 14 int length = wai_getExecutablePath(NULL, 0, NULL);
@@ -22,3 +25,16 @@ const std::filesystem::path& GetExecutableDirectory() {
22std::string GetAbsolutePath(std::string_view path) { 25std::string GetAbsolutePath(std::string_view path) {
23 return (GetExecutableDirectory() / path).string(); 26 return (GetExecutableDirectory() / path).string();
24} 27}
28
29bool IsLocationWinCondition(const Location& location) {
30 switch (AP_GetVictoryCondition()) {
31 case kTHE_END:
32 return location.ap_location_name ==
33 "Orange Tower Seventh Floor - THE END";
34 case kTHE_MASTER:
35 return location.ap_location_name ==
36 "Orange Tower Seventh Floor - THE MASTER";
37 case kLEVEL_2:
38 return location.ap_location_name == "Second Room - LEVEL 2";
39 }
40}
diff --git a/src/global.h b/src/global.h index 2eb7884..31ebde3 100644 --- a/src/global.h +++ b/src/global.h
@@ -4,8 +4,12 @@
4#include <filesystem> 4#include <filesystem>
5#include <string_view> 5#include <string_view>
6 6
7struct Location;
8
7const std::filesystem::path& GetExecutableDirectory(); 9const std::filesystem::path& GetExecutableDirectory();
8 10
9std::string GetAbsolutePath(std::string_view path); 11std::string GetAbsolutePath(std::string_view path);
10 12
13bool IsLocationWinCondition(const Location& location);
14
11#endif /* end of include guard: GLOBAL_H_44945DBA */ 15#endif /* end of include guard: GLOBAL_H_44945DBA */
diff --git a/src/tracker_panel.cpp b/src/tracker_panel.cpp index 3102110..daaeff7 100644 --- a/src/tracker_panel.cpp +++ b/src/tracker_panel.cpp
@@ -118,7 +118,9 @@ void TrackerPanel::Redraw() {
118 bool has_unreachable_unchecked = false; 118 bool has_unreachable_unchecked = false;
119 for (const Location &section : map_area.locations) { 119 for (const Location &section : map_area.locations) {
120 bool has_unchecked = false; 120 bool has_unchecked = false;
121 if (AP_IsLocationVisible(section.classification)) { 121 if (IsLocationWinCondition(section)) {
122 has_unchecked = !AP_HasReachedGoal();
123 } else if (AP_IsLocationVisible(section.classification)) {
122 has_unchecked = !AP_HasCheckedGameLocation(section.ap_location_id); 124 has_unchecked = !AP_HasCheckedGameLocation(section.ap_location_id);
123 } else if (section.hunt && GetTrackerConfig().show_hunt_panels) { 125 } else if (section.hunt && GetTrackerConfig().show_hunt_panels) {
124 has_unchecked = !AP_HasCheckedHuntPanel(section.ap_location_id); 126 has_unchecked = !AP_HasCheckedHuntPanel(section.ap_location_id);