The world is deleted upon connection to a server.
This commit is contained in:
@@ -549,15 +549,22 @@ bool Client::OnDashAbility(const Events::DashAbility& e)
|
|||||||
|
|
||||||
bool Client::OnConnectRequest(const Events::ConnectRequest& e)
|
bool Client::OnConnectRequest(const Events::ConnectRequest& e)
|
||||||
{
|
{
|
||||||
|
std::vector<EntityID> 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)) {
|
if (m_Reliable.Connect(m_PlayerName, e.IP, e.Port)) {
|
||||||
// The client send a successful connect message
|
// The client send a successful connect message
|
||||||
auto rootEntities = m_World->GetDirectChildren(EntityID_Invalid);
|
return true;
|
||||||
for (auto it = rootEntities.first; it != rootEntities.second; it++) {
|
|
||||||
m_World->DeleteEntity(it->first);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// The client could not send a successful connect message
|
// The client could not send a successful connect message
|
||||||
|
return false;
|
||||||
|
// Load the main menu again ?
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user