mirror of
https://github.com/overte-org/overte.git
synced 2025-08-16 09:12:26 +02:00
make eachNode callers return bool to say if iteration should continue
This commit is contained in:
parent
e0c4f14c81
commit
c80633499f
5 changed files with 19 additions and 16 deletions
|
@ -425,6 +425,8 @@ unsigned LimitedNodeList::broadcastToNodes(const QByteArray& packet, const NodeS
|
|||
writeDatagram(packet, node);
|
||||
++n;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return n;
|
||||
|
|
|
@ -132,7 +132,9 @@ public:
|
|||
QReadLocker readLock(&_nodeMutex);
|
||||
|
||||
for (NodeHash::const_iterator it = _nodeHash.cbegin(); it != _nodeHash.cend(); ++it) {
|
||||
functor(it->second);
|
||||
if (!functor(it->second)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -454,6 +454,8 @@ void NodeList::pingInactiveNodes() {
|
|||
// we don't have an active link to this node, ping it to set that up
|
||||
pingPunchForInactiveNode(node);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -38,16 +38,14 @@ bool JurisdictionListener::queueJurisdictionRequest() {
|
|||
int sizeOut = populatePacketHeader(reinterpret_cast<char*>(bufferOut), PacketTypeJurisdictionRequest);
|
||||
int nodeCount = 0;
|
||||
|
||||
NodeList* nodeList = NodeList::getInstance();
|
||||
|
||||
NodeHashSnapshot nodeHashSnapshot = nodeList->getNodeHash().snapshot_table();
|
||||
|
||||
for (auto it = nodeHashSnapshot.begin(); it != nodeHashSnapshot.end(); it++) {
|
||||
if (it->second->getType() == getNodeType() && it->second->getActiveSocket()) {
|
||||
_packetSender.queuePacketForSending(it->second, QByteArray(reinterpret_cast<char*>(bufferOut), sizeOut));
|
||||
NodeList::getInstance()->eachNode([&](const SharedNodePointer& node) {
|
||||
if (node->getType() == getNodeType() && node->getActiveSocket()) {
|
||||
_packetSender.queuePacketForSending(node, QByteArray(reinterpret_cast<char*>(bufferOut), sizeOut));
|
||||
nodeCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
if (nodeCount > 0){
|
||||
_packetSender.setPacketsPerSecond(nodeCount);
|
||||
|
|
|
@ -51,12 +51,8 @@ OctreeEditPacketSender::~OctreeEditPacketSender() {
|
|||
bool OctreeEditPacketSender::serversExist() const {
|
||||
bool hasServers = false;
|
||||
bool atLeastOneJurisdictionMissing = false; // assume the best
|
||||
NodeList* nodeList = NodeList::getInstance();
|
||||
|
||||
NodeHashSnapshot snapshotHash = nodeList->getNodeHash().snapshot_table();
|
||||
for (auto it = snapshotHash.begin(); it != snapshotHash.end(); it++) {
|
||||
// only send to the NodeTypes that are getMyNodeType()
|
||||
SharedNodePointer node = it->second;
|
||||
NodeList::getInstance()->eachNode([&](const SharedNodePointer& node){
|
||||
if (node->getType() == getMyNodeType() && node->getActiveSocket()) {
|
||||
|
||||
QUuid nodeUUID = node->getUUID();
|
||||
|
@ -72,10 +68,13 @@ bool OctreeEditPacketSender::serversExist() const {
|
|||
}
|
||||
hasServers = true;
|
||||
}
|
||||
|
||||
if (atLeastOneJurisdictionMissing) {
|
||||
break; // no point in looking further...
|
||||
return false; // no point in looking further - return false from anonymous function
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return (hasServers && !atLeastOneJurisdictionMissing);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue