From e32bfc38f5f1aa1f627db34dab0f7557e4ffc4d8 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 13 Nov 2013 01:06:17 -0800 Subject: [PATCH] change voxelServersExist() to make sure that all existing voxel servers have a legitimate jurisdiction --- libraries/voxels/src/VoxelEditPacketSender.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/libraries/voxels/src/VoxelEditPacketSender.cpp b/libraries/voxels/src/VoxelEditPacketSender.cpp index 0835282ad4..ec7ea3810b 100644 --- a/libraries/voxels/src/VoxelEditPacketSender.cpp +++ b/libraries/voxels/src/VoxelEditPacketSender.cpp @@ -88,16 +88,30 @@ void VoxelEditPacketSender::sendVoxelEditMessage(PACKET_TYPE type, VoxelDetail& } bool VoxelEditPacketSender::voxelServersExist() const { + bool hasVoxelServers = false; + bool atLeastOnJurisdictionMissing = false; // assume the best NodeList* nodeList = NodeList::getInstance(); for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { // only send to the NodeTypes that are NODE_TYPE_VOXEL_SERVER if (node->getType() == NODE_TYPE_VOXEL_SERVER) { if (nodeList->getNodeActiveSocketOrPing(&(*node))) { - return true; + QUuid nodeUUID = node->getUUID(); + // If we've got Jurisdictions set, then check to see if we know the jurisdiction for this server + if (_voxelServerJurisdictions) { + // lookup our nodeUUID in the jurisdiction map, if it's missing then we're + // missing at least one jurisdiction + if ((*_voxelServerJurisdictions).find(nodeUUID) == (*_voxelServerJurisdictions).end()) { + atLeastOnJurisdictionMissing = true; + } + } + hasVoxelServers = true; } } + if (atLeastOnJurisdictionMissing) { + break; // no point in looking further... + } } - return false; + return (hasVoxelServers && !atLeastOnJurisdictionMissing); } // This method is called when the edit packet layer has determined that it has a fully formed packet destined for