diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-12-19 22:48:41 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-12-19 22:48:41 -0500 |
commit | 5a7559e39d2cd8306a99adbc6d39e90716b14687 (patch) | |
tree | ab8e99c780b6a1dd6d27f0521f052e20bd7e3798 /src/ap_state.h | |
parent | 4f2ac8d575549501e29a7c0088293db2e5e236dd (diff) | |
download | lingo-ap-tracker-5a7559e39d2cd8306a99adbc6d39e90716b14687.tar.gz lingo-ap-tracker-5a7559e39d2cd8306a99adbc6d39e90716b14687.tar.bz2 lingo-ap-tracker-5a7559e39d2cd8306a99adbc6d39e90716b14687.zip |
Rewrote APState so connection happens on thread
The whole file is more thread-safe than before, with a few notable exceptions. This fixes a read-after-free issue where, when reconnecting after a disconnection, the client thread would attempt to lock a mutex owned and already destroyed by the main thread.
Diffstat (limited to 'src/ap_state.h')
-rw-r--r-- | src/ap_state.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/ap_state.h b/src/ap_state.h index f310ee8..a23b13d 100644 --- a/src/ap_state.h +++ b/src/ap_state.h | |||
@@ -51,8 +51,13 @@ bool AP_HasCheckedGameLocation(int location_id); | |||
51 | 51 | ||
52 | bool AP_HasCheckedHuntPanel(int location_id); | 52 | bool AP_HasCheckedHuntPanel(int location_id); |
53 | 53 | ||
54 | // This doesn't lock the state mutex, for speed, so it must ONLY be called from | ||
55 | // RecalculateReachability, which is only called from the APState thread anyway. | ||
54 | bool AP_HasItem(int item_id, int quantity = 1); | 56 | bool AP_HasItem(int item_id, int quantity = 1); |
55 | 57 | ||
58 | // This doesn't lock the client mutex because it is ONLY to be called from | ||
59 | // RecalculateReachability, which is only called from within a client callback | ||
60 | // anyway. | ||
56 | std::string AP_GetItemName(int item_id); | 61 | std::string AP_GetItemName(int item_id); |
57 | 62 | ||
58 | DoorShuffleMode AP_GetDoorShuffleMode(); | 63 | DoorShuffleMode AP_GetDoorShuffleMode(); |
@@ -63,10 +68,12 @@ bool AP_IsColorShuffle(); | |||
63 | 68 | ||
64 | bool AP_IsPaintingShuffle(); | 69 | bool AP_IsPaintingShuffle(); |
65 | 70 | ||
71 | // WARNING: Not thread-safe! | ||
66 | const std::map<std::string, std::string>& AP_GetPaintingMapping(); | 72 | const std::map<std::string, std::string>& AP_GetPaintingMapping(); |
67 | 73 | ||
68 | bool AP_IsPaintingMappedTo(const std::string& painting_id); | 74 | bool AP_IsPaintingMappedTo(const std::string& painting_id); |
69 | 75 | ||
76 | // WARNING: Not thread-safe! | ||
70 | const std::set<std::string>& AP_GetCheckedPaintings(); | 77 | const std::set<std::string>& AP_GetCheckedPaintings(); |
71 | 78 | ||
72 | bool AP_IsPaintingChecked(const std::string& painting_id); | 79 | bool AP_IsPaintingChecked(const std::string& painting_id); |
@@ -93,6 +100,7 @@ SunwarpAccess AP_GetSunwarpAccess(); | |||
93 | 100 | ||
94 | bool AP_IsSunwarpShuffle(); | 101 | bool AP_IsSunwarpShuffle(); |
95 | 102 | ||
103 | // WARNING: Not thread-safe! | ||
96 | const std::map<int, SunwarpMapping>& AP_GetSunwarpMapping(); | 104 | const std::map<int, SunwarpMapping>& AP_GetSunwarpMapping(); |
97 | 105 | ||
98 | bool AP_HasReachedGoal(); | 106 | bool AP_HasReachedGoal(); |