about summary refs log tree commit diff stats
path: root/src/ap_state.h
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-12-19 22:48:41 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2024-12-19 22:48:41 -0500
commit5a7559e39d2cd8306a99adbc6d39e90716b14687 (patch)
treeab8e99c780b6a1dd6d27f0521f052e20bd7e3798 /src/ap_state.h
parent4f2ac8d575549501e29a7c0088293db2e5e236dd (diff)
downloadlingo-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.h8
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
52bool AP_HasCheckedHuntPanel(int location_id); 52bool 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.
54bool AP_HasItem(int item_id, int quantity = 1); 56bool 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.
56std::string AP_GetItemName(int item_id); 61std::string AP_GetItemName(int item_id);
57 62
58DoorShuffleMode AP_GetDoorShuffleMode(); 63DoorShuffleMode AP_GetDoorShuffleMode();
@@ -63,10 +68,12 @@ bool AP_IsColorShuffle();
63 68
64bool AP_IsPaintingShuffle(); 69bool AP_IsPaintingShuffle();
65 70
71// WARNING: Not thread-safe!
66const std::map<std::string, std::string>& AP_GetPaintingMapping(); 72const std::map<std::string, std::string>& AP_GetPaintingMapping();
67 73
68bool AP_IsPaintingMappedTo(const std::string& painting_id); 74bool AP_IsPaintingMappedTo(const std::string& painting_id);
69 75
76// WARNING: Not thread-safe!
70const std::set<std::string>& AP_GetCheckedPaintings(); 77const std::set<std::string>& AP_GetCheckedPaintings();
71 78
72bool AP_IsPaintingChecked(const std::string& painting_id); 79bool AP_IsPaintingChecked(const std::string& painting_id);
@@ -93,6 +100,7 @@ SunwarpAccess AP_GetSunwarpAccess();
93 100
94bool AP_IsSunwarpShuffle(); 101bool AP_IsSunwarpShuffle();
95 102
103// WARNING: Not thread-safe!
96const std::map<int, SunwarpMapping>& AP_GetSunwarpMapping(); 104const std::map<int, SunwarpMapping>& AP_GetSunwarpMapping();
97 105
98bool AP_HasReachedGoal(); 106bool AP_HasReachedGoal();