summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GlobalState.cpp12
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;