mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 20:58:38 +02:00
add a guard for trading entity servers by checking node count
This commit is contained in:
parent
c63a2c9cda
commit
0a118bd268
1 changed files with 20 additions and 1 deletions
|
@ -326,7 +326,26 @@ void EntityScriptServer::nodeActivated(SharedNodePointer activatedNode) {
|
||||||
void EntityScriptServer::nodeKilled(SharedNodePointer killedNode) {
|
void EntityScriptServer::nodeKilled(SharedNodePointer killedNode) {
|
||||||
switch (killedNode->getType()) {
|
switch (killedNode->getType()) {
|
||||||
case NodeType::EntityServer: {
|
case NodeType::EntityServer: {
|
||||||
clear();
|
// Before we clear, make sure this was our only entity server.
|
||||||
|
// Otherwise we're assuming that we have "trading" entity servers
|
||||||
|
// (an old one going away and a new one coming onboard)
|
||||||
|
// and that we shouldn't clear here because we're still doing work.
|
||||||
|
bool hasAnotherEntityServer = false;
|
||||||
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
|
||||||
|
nodeList->eachNodeBreakable([&hasAnotherEntityServer, &killedNode](const SharedNodePointer& node){
|
||||||
|
if (node->getType() == NodeType::EntityServer && node->getUUID() != killedNode->getUUID()) {
|
||||||
|
// we're talking to > 1 entity servers, we know we won't clear
|
||||||
|
hasAnotherEntityServer = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (hasAnotherEntityServer) {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue