From 1211888ce14236af80a3ab74945c040360453b01 Mon Sep 17 00:00:00 2001 From: stiffly Date: Wed, 9 Mar 2016 15:10:32 +0100 Subject: [PATCH] The world is deleted upon connection to a server. --- src/Engine/Network/Client.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index bac0acee..6b5dd092 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -549,15 +549,22 @@ bool Client::OnDashAbility(const Events::DashAbility& e) bool Client::OnConnectRequest(const Events::ConnectRequest& e) { + std::vector childrenToBeDeleted; + auto rootEntites = m_World->GetDirectChildren(EntityID_Invalid); + for (auto it = rootEntites.first; it != rootEntites.second; it++) { + childrenToBeDeleted.push_back(it->second); + } + for (int i = 0; i < childrenToBeDeleted.size(); ++i) { + m_World->DeleteEntity(childrenToBeDeleted[i]); + } if (m_Reliable.Connect(m_PlayerName, e.IP, e.Port)) { // The client send a successful connect message - auto rootEntities = m_World->GetDirectChildren(EntityID_Invalid); - for (auto it = rootEntities.first; it != rootEntities.second; it++) { - m_World->DeleteEntity(it->first); - } + return true; } else { // The client could not send a successful connect message + return false; + // Load the main menu again ? } return false; }