diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-01-13 13:27:21 +0100 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-01-13 13:27:21 +0100 |
commit | e3369aff83e3a55440564d3e4738449821a309d0 (patch) | |
tree | 50640edafbc7c83d7ae9712245b5d59488706701 /src/GlobalState.cpp | |
parent | Removed GlobalState thread. His tasks assigned to Render thread. (diff) | |
download | AltCraft-e3369aff83e3a55440564d3e4738449821a309d0.tar AltCraft-e3369aff83e3a55440564d3e4738449821a309d0.tar.gz AltCraft-e3369aff83e3a55440564d3e4738449821a309d0.tar.bz2 AltCraft-e3369aff83e3a55440564d3e4738449821a309d0.tar.lz AltCraft-e3369aff83e3a55440564d3e4738449821a309d0.tar.xz AltCraft-e3369aff83e3a55440564d3e4738449821a309d0.tar.zst AltCraft-e3369aff83e3a55440564d3e4738449821a309d0.zip |
Diffstat (limited to '')
-rw-r--r-- | src/GlobalState.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/GlobalState.cpp b/src/GlobalState.cpp index a9f3d4e..80a3342 100644 --- a/src/GlobalState.cpp +++ b/src/GlobalState.cpp @@ -38,12 +38,18 @@ void InitEvents() { } LOG(INFO) << "Connecting to server"; PUSH_EVENT("Connecting",0); + gs = std::make_unique<GameState>(); + isPhysRunning = true; + threadPhys = std::thread(&PhysExec); try { nc = std::make_unique<NetworkClient>(std::get<0>(data), std::get<1>(data), std::get<2>(data)); } catch (std::exception &e) { LOG(WARNING) << "Connection failed"; PUSH_EVENT("ConnectionFailed", std::string(e.what())); + isPhysRunning = false; + threadPhys.join(); + gs.reset(); return; } LOG(INFO) << "Connected to server"; @@ -70,12 +76,6 @@ void InitEvents() { isRunning = false; }); - listener.RegisterHandler("ConnectionSuccessfull", [](const Event&) { - gs = std::make_unique<GameState>(); - isPhysRunning = true; - threadPhys = std::thread(&PhysExec); - }); - listener.RegisterHandler("Disconnected", [](const Event&) { if (!gs) return; |