Use mutex for proper synchronization
* Guard both hack and reader threads so that only one thread can interact with critical variables at a time. This fixes exception related to bone esp.
This commit is contained in:
@@ -26,6 +26,9 @@ namespace hack {
|
||||
};
|
||||
|
||||
void loop() {
|
||||
|
||||
std::lock_guard<std::mutex> lock(dataMutex);
|
||||
|
||||
if (g_game.isC4Planted)
|
||||
{
|
||||
Vector3 c4Origin = g_game.c4.get_origin();
|
||||
|
||||
@@ -68,6 +68,9 @@ void CGame::close() {
|
||||
}
|
||||
|
||||
void CGame::loop() {
|
||||
|
||||
std::lock_guard<std::mutex> lock(dataMutex);
|
||||
|
||||
inGame = false;
|
||||
isC4Planted = false;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "../classes/vector.hpp"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
|
||||
struct view_matrix_t {
|
||||
float* operator[ ](int index) {
|
||||
@@ -75,3 +76,5 @@ private:
|
||||
};
|
||||
|
||||
inline CGame g_game;
|
||||
|
||||
inline std::mutex dataMutex;
|
||||
Reference in New Issue
Block a user