Showing the changes to assignment-client/src/scripts/EntityScriptServer.cpp (1 of 1 file). Show all
Unified · Split
| @@ -326,7 +326,26 @@ void EntityScriptServer::nodeActivated(SharedNodePointer activatedNode) { · 325 unmodified lines | ||
| 326 | 326 | void EntityScriptServer::nodeKilled(SharedNodePointer killedNode) { |
| 327 | 327 | switch (killedNode->getType()) { |
| 328 | 328 | case NodeType::EntityServer: { |
| 329 | − clear(); | |
| 329 | + // Before we clear, make sure this was our only entity server. | |
| 330 | + // Otherwise we're assuming that we have "trading" entity servers | |
| 331 | + // (an old one going away and a new one coming onboard) | |
| 332 | + // and that we shouldn't clear here because we're still doing work. | |
| 333 | + bool hasAnotherEntityServer = false; | |
| 334 | + auto nodeList = DependencyManager::get<NodeList>(); | |
| 335 | + | |
| 336 | + nodeList->eachNodeBreakable([&hasAnotherEntityServer, &killedNode](const SharedNodePointer& node){ | |
| 337 | + if (node->getType() == NodeType::EntityServer && node->getUUID() != killedNode->getUUID()) { | |
| 338 | + // we're talking to > 1 entity servers, we know we won't clear | |
| 339 | + hasAnotherEntityServer = true; | |
| 340 | + return false; | |
| 341 | + } | |
| 342 | + | |
| 343 | + return true; | |
| 344 | + }); | |
| 345 | + | |
| 346 | + if (hasAnotherEntityServer) { | |
| 347 | + clear(); | |
| 348 | + } | |
| 330 | 349 | |
| 331 | 350 | break; |
| 332 | 351 | } |