diff options
Diffstat (limited to 'src/ThreadGame.cpp')
-rw-r--r-- | src/ThreadGame.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/ThreadGame.cpp b/src/ThreadGame.cpp index d3750ea..ef7a95e 100644 --- a/src/ThreadGame.cpp +++ b/src/ThreadGame.cpp @@ -19,13 +19,14 @@ void ThreadGame::Execute() { listener.RegisterHandler(EventType::ConnectionSuccessfull, [this](EventData eventData) { auto data = std::get<ConnectionSuccessfullData>(eventData); - gs = new GameState(data.ptr); + gs = std::make_shared<GameState>(data.ptr); + gs->gs = gs; }); listener.RegisterHandler(EventType::Disconnected, [this](EventData eventData) { std::this_thread::sleep_for(std::chrono::milliseconds(500)); - delete gs; - gs = nullptr; + gs->gs.reset(); + gs.reset(); }); listener.RegisterHandler(EventType::KeyPressed, [this](EventData eventData) { @@ -100,5 +101,5 @@ void ThreadGame::Execute() { } timer.Update(); } - delete gs; + gs.reset(); } |