summaryrefslogtreecommitdiffstats
path: root/src/GameState.hpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2019-01-27 04:10:36 +0100
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2019-01-27 04:10:36 +0100
commitc3472b8abd8185f392e6c2afb68a7411232396d6 (patch)
tree7b3544cdb5eccfcce2a1a7c8efaa5c09ae7455df /src/GameState.hpp
parentRefactored GameState (diff)
downloadAltCraft-c3472b8abd8185f392e6c2afb68a7411232396d6.tar
AltCraft-c3472b8abd8185f392e6c2afb68a7411232396d6.tar.gz
AltCraft-c3472b8abd8185f392e6c2afb68a7411232396d6.tar.bz2
AltCraft-c3472b8abd8185f392e6c2afb68a7411232396d6.tar.lz
AltCraft-c3472b8abd8185f392e6c2afb68a7411232396d6.tar.xz
AltCraft-c3472b8abd8185f392e6c2afb68a7411232396d6.tar.zst
AltCraft-c3472b8abd8185f392e6c2afb68a7411232396d6.zip
Diffstat (limited to '')
-rw-r--r--src/GameState.hpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/GameState.hpp b/src/GameState.hpp
index cd39a48..dbea2c3 100644
--- a/src/GameState.hpp
+++ b/src/GameState.hpp
@@ -3,6 +3,7 @@
#include <memory>
#include <string>
#include <vector>
+#include <mutex>
#include <glm/mat4x4.hpp>
@@ -67,6 +68,8 @@ class GameState {
Window playerInventory;
std::vector<Window> openedWindows;
+
+ std::mutex accessMutex;
public:
void Update(float deltaTime);
@@ -92,30 +95,37 @@ public:
glm::mat4 GetViewMatrix();
inline Entity *GetPlayer() {
+ std::lock_guard<std::mutex> guard(accessMutex);
return player;
}
- inline World &GetWorld() {
+ inline World GetWorld() {
+ std::lock_guard<std::mutex> guard(accessMutex);
return world;
}
inline TimeStatus GetTimeStatus() {
+ std::lock_guard<std::mutex> guard(accessMutex);
return timeStatus;
}
inline GameStatus GetGameStatus() {
+ std::lock_guard<std::mutex> guard(accessMutex);
return gameStatus;
}
inline PlayerStatus GetPlayerStatus() {
+ std::lock_guard<std::mutex> guard(accessMutex);
return playerStatus;
}
inline SelectionStatus GetSelectionStatus() {
+ std::lock_guard<std::mutex> guard(accessMutex);
return selectionStatus;
}
inline Window &GetInventory() {
+ std::lock_guard<std::mutex> guard(accessMutex);
return playerInventory;
}
};