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
-rw-r--r--src/version.h2
7 files changed, 63 insertions, 9 deletions
diff --git a/src/ap_state.cpp b/src/ap_state.cpp index ea74c93..1937597 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;
@@ -121,6 +124,7 @@ struct APState {
121 inventory.clear(); 124 inventory.clear();
122 checked_locations.clear(); 125 checked_locations.clear();
123 data_storage.clear(); 126 data_storage.clear();
127 victory_data_storage_key.clear();
124 door_shuffle_mode = kNO_DOORS; 128 door_shuffle_mode = kNO_DOORS;
125 color_shuffle = false; 129 color_shuffle = false;
126 painting_shuffle = false; 130 painting_shuffle = false;
@@ -191,6 +195,10 @@ struct APState {
191 data_storage[key] = value.get<bool>(); 195 data_storage[key] = value.get<bool>();
192 TrackerLog("Data storage " + key + " retrieved as " + 196 TrackerLog("Data storage " + key + " retrieved as " +
193 (value.get<bool>() ? "true" : "false")); 197 (value.get<bool>() ? "true" : "false"));
198 } else if (value.is_number()) {
199 data_storage[key] = value.get<int>();
200 TrackerLog("Data storage " + key + " retrieved as " +
201 std::to_string(value.get<int>()));
194 } 202 }
195 } 203 }
196 204
@@ -202,11 +210,15 @@ struct APState {
202 const nlohmann::json&) { 210 const nlohmann::json&) {
203 if (value.is_boolean()) { 211 if (value.is_boolean()) {
204 data_storage[key] = value.get<bool>(); 212 data_storage[key] = value.get<bool>();
205 TrackerLog("Data storage " + key + " set to " + 213 TrackerLog("Data storage " + key + " retrieved as " +
206 (value.get<bool>() ? "true" : "false")); 214 (value.get<bool>() ? "true" : "false"));
207 215 } else if (value.is_number()) {
208 RefreshTracker(); 216 data_storage[key] = value.get<int>();
217 TrackerLog("Data storage " + key + " retrieved as " +
218 std::to_string(value.get<int>()));
209 } 219 }
220
221 RefreshTracker();
210 }); 222 });
211 223
212 apclient->set_slot_connected_handler([this]( 224 apclient->set_slot_connected_handler([this](
@@ -249,6 +261,15 @@ struct APState {
249 corrected_keys.push_back(data_storage_prefix + key); 261 corrected_keys.push_back(data_storage_prefix + key);
250 } 262 }
251 263
264 {
265 std::ostringstream vdsks;
266 vdsks << "_read_client_status_" << apclient->get_team_number() << "_"
267 << apclient->get_player_number();
268 victory_data_storage_key = vdsks.str();
269 }
270
271 corrected_keys.push_back(victory_data_storage_key);
272
252 apclient->Get(corrected_keys); 273 apclient->Get(corrected_keys);
253 apclient->SetNotify(corrected_keys); 274 apclient->SetNotify(corrected_keys);
254 }); 275 });
@@ -328,7 +349,7 @@ struct APState {
328 bool HasCheckedHuntPanel(int location_id) { 349 bool HasCheckedHuntPanel(int location_id) {
329 std::string key = 350 std::string key =
330 data_storage_prefix + "Hunt|" + std::to_string(location_id); 351 data_storage_prefix + "Hunt|" + std::to_string(location_id);
331 return data_storage.count(key) && data_storage.at(key); 352 return data_storage.count(key) && std::any_cast<bool>(data_storage.at(key));
332 } 353 }
333 354
334 bool HasItem(int item_id, int quantity) { 355 bool HasItem(int item_id, int quantity) {
@@ -337,7 +358,7 @@ struct APState {
337 358
338 bool HasAchievement(const std::string& name) { 359 bool HasAchievement(const std::string& name) {
339 std::string key = data_storage_prefix + "Achievement|" + name; 360 std::string key = data_storage_prefix + "Achievement|" + name;
340 return data_storage.count(key) && data_storage.at(key); 361 return data_storage.count(key) && std::any_cast<bool>(data_storage.at(key));
341 } 362 }
342 363
343 void RefreshTracker() { 364 void RefreshTracker() {
@@ -356,6 +377,12 @@ struct APState {
356 return ap_id; 377 return ap_id;
357 } 378 }
358 379
380 bool HasReachedGoal() {
381 return data_storage.count(victory_data_storage_key) &&
382 std::any_cast<int>(data_storage.at(victory_data_storage_key)) ==
383 30; // CLIENT_GOAL
384 }
385
359 void DestroyClient() { 386 void DestroyClient() {
360 client_active = false; 387 client_active = false;
361 apclient->reset(); 388 apclient->reset();
@@ -428,3 +455,5 @@ bool AP_HasEarlyColorHallways() { return GetState().early_color_hallways; }
428bool AP_IsPilgrimageEnabled() { return GetState().pilgrimage_enabled; } 455bool AP_IsPilgrimageEnabled() { return GetState().pilgrimage_enabled; }
429 456
430SunwarpAccess AP_GetSunwarpAccess() { return GetState().sunwarp_access; } 457SunwarpAccess AP_GetSunwarpAccess() { return GetState().sunwarp_access; }
458
459bool AP_HasReachedGoal() { return GetState().HasReachedGoal(); }
diff --git a/src/ap_state.h b/src/ap_state.h index e145066..fe424fd 100644 --- a/src/ap_state.h +++ b/src/ap_state.h
@@ -50,4 +50,6 @@ bool AP_IsPilgrimageEnabled();
50 50
51SunwarpAccess AP_GetSunwarpAccess(); 51SunwarpAccess AP_GetSunwarpAccess();
52 52
53bool AP_HasReachedGoal();
54
53#endif /* end of include guard: AP_STATE_H_664A4180 */ 55#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);
diff --git a/src/version.h b/src/version.h index e9c8264..62a4cd1 100644 --- a/src/version.h +++ b/src/version.h
@@ -35,6 +35,6 @@ std::ostream& operator<<(std::ostream& out, const Version& ver) {
35 return out << "v" << ver.major << "." << ver.minor << "." << ver.revision; 35 return out << "v" << ver.major << "." << ver.minor << "." << ver.revision;
36} 36}
37 37
38constexpr const Version kTrackerVersion = Version(0, 6, 4); 38constexpr const Version kTrackerVersion = Version(0, 6, 5);
39 39
40#endif /* end of include guard: VERSION_H_C757E53C */ \ No newline at end of file 40#endif /* end of include guard: VERSION_H_C757E53C */ \ No newline at end of file