Fix processOctreeStats recreating JurisdictionMap for every stat packet

This commit is contained in:
Ryan Huffman 2016-05-17 15:12:14 -07:00
parent 013d902376
commit 47d897f669

View file

@ -4372,8 +4372,11 @@ int Application::processOctreeStats(ReceivedMessage& message, SharedNodePointer
serverType = "Entity"; serverType = "Entity";
} }
bool found = false;
jurisdiction->withReadLock([&] { jurisdiction->withReadLock([&] {
if (jurisdiction->find(nodeUUID) != jurisdiction->end()) { if (jurisdiction->find(nodeUUID) != jurisdiction->end()) {
found = true;
return; return;
} }
@ -4384,15 +4387,18 @@ int Application::processOctreeStats(ReceivedMessage& message, SharedNodePointer
qPrintable(serverType), qPrintable(serverType),
(double)rootDetails.x, (double)rootDetails.y, (double)rootDetails.z, (double)rootDetails.s); (double)rootDetails.x, (double)rootDetails.y, (double)rootDetails.z, (double)rootDetails.s);
}); });
// store jurisdiction details for later use
// This is bit of fiddling is because JurisdictionMap assumes it is the owner of the values used to construct it if (!found) {
// but OctreeSceneStats thinks it's just returning a reference to its contents. So we need to make a copy of the // store jurisdiction details for later use
// details from the OctreeSceneStats to construct the JurisdictionMap // This is bit of fiddling is because JurisdictionMap assumes it is the owner of the values used to construct it
JurisdictionMap jurisdictionMap; // but OctreeSceneStats thinks it's just returning a reference to its contents. So we need to make a copy of the
jurisdictionMap.copyContents(octreeStats.getJurisdictionRoot(), octreeStats.getJurisdictionEndNodes()); // details from the OctreeSceneStats to construct the JurisdictionMap
jurisdiction->withWriteLock([&] { JurisdictionMap jurisdictionMap;
(*jurisdiction)[nodeUUID] = jurisdictionMap; jurisdictionMap.copyContents(octreeStats.getJurisdictionRoot(), octreeStats.getJurisdictionEndNodes());
}); jurisdiction->withWriteLock([&] {
(*jurisdiction)[nodeUUID] = jurisdictionMap;
});
}
}); });
return statsMessageLength; return statsMessageLength;