mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 18:55:01 +02:00
moved around code in sendNack() a bit
This commit is contained in:
parent
3bc457d4d2
commit
529dd827a2
3 changed files with 38 additions and 33 deletions
|
@ -2137,6 +2137,25 @@ void Application::sendNack() {
|
|||
|| node->getType() == NodeType::ModelServer)
|
||||
) {
|
||||
|
||||
QUuid nodeUUID = node->getUUID();
|
||||
|
||||
|
||||
_octreeSceneStatsLock.lockForWrite();
|
||||
|
||||
// retreive octree scene stats of this node
|
||||
if (_octreeServerSceneStats.find(nodeUUID) == _octreeServerSceneStats.end()) {
|
||||
_octreeSceneStatsLock.unlock();
|
||||
continue;
|
||||
}
|
||||
OctreeSceneStats& stats = _octreeServerSceneStats[nodeUUID];
|
||||
|
||||
// check if there are any sequence numbers that need to be nacked
|
||||
int numSequenceNumbersAvailable = stats.getNumSequenceNumbersToNack();
|
||||
if (numSequenceNumbersAvailable == 0) {
|
||||
_octreeSceneStatsLock.unlock();
|
||||
continue;
|
||||
}
|
||||
|
||||
char* dataAt = packet;
|
||||
int bytesRemaining = MAX_PACKET_SIZE;
|
||||
|
||||
|
@ -2146,40 +2165,26 @@ void Application::sendNack() {
|
|||
bytesRemaining -= numBytesPacketHeader;
|
||||
int numSequenceNumbersRoomFor = (bytesRemaining - sizeof(uint16_t)) / sizeof(OCTREE_PACKET_SEQUENCE);
|
||||
|
||||
// calculate and pack the number of sequence numbers
|
||||
uint16_t numSequenceNumbers = min(numSequenceNumbersAvailable, numSequenceNumbersRoomFor);
|
||||
uint16_t* numSequenceNumbersAt = (uint16_t*)dataAt;
|
||||
*numSequenceNumbersAt = numSequenceNumbers;
|
||||
dataAt += sizeof(uint16_t);
|
||||
|
||||
QUuid nodeUUID = node->getUUID();
|
||||
|
||||
_octreeSceneStatsLock.lockForWrite();
|
||||
if (_octreeServerSceneStats.find(nodeUUID) != _octreeServerSceneStats.end()) {
|
||||
OctreeSceneStats& stats = _octreeServerSceneStats[nodeUUID];
|
||||
|
||||
int numSequenceNumbersAvailable = stats.getNumSequenceNumbersToNack();
|
||||
if (numSequenceNumbersAvailable == 0) {
|
||||
_octreeSceneStatsLock.unlock();
|
||||
continue;
|
||||
}
|
||||
|
||||
// calculate and pack number of sequence numbers
|
||||
uint16_t numSequenceNumbers = min(numSequenceNumbersAvailable, numSequenceNumbersRoomFor);
|
||||
uint16_t* numSequenceNumbersAt = (uint16_t*)dataAt;
|
||||
*numSequenceNumbersAt = numSequenceNumbers;
|
||||
dataAt += sizeof(uint16_t);
|
||||
|
||||
// pack sequence numbers
|
||||
//printf("\n\t sending nack...\n");
|
||||
//printf("\t\t packed %d seq #s:", numSequenceNumbers);
|
||||
for (int i = 0; i < numSequenceNumbers; i++) {
|
||||
OCTREE_PACKET_SEQUENCE* sequenceNumberAt = (OCTREE_PACKET_SEQUENCE*)dataAt;
|
||||
*sequenceNumberAt = stats.getNextSequenceNumberToNack();
|
||||
dataAt += sizeof(OCTREE_PACKET_SEQUENCE);
|
||||
//printf(" %d,", *sequenceNumberAt);
|
||||
}
|
||||
//printf("\n");
|
||||
// pack sequence numbers
|
||||
//printf("\n\t sending nack...\n");
|
||||
//printf("\t\t packed %d seq #s:", numSequenceNumbers);
|
||||
for (int i = 0; i < numSequenceNumbers; i++) {
|
||||
OCTREE_PACKET_SEQUENCE* sequenceNumberAt = (OCTREE_PACKET_SEQUENCE*)dataAt;
|
||||
*sequenceNumberAt = stats.getNextSequenceNumberToNack();
|
||||
dataAt += sizeof(OCTREE_PACKET_SEQUENCE);
|
||||
//printf(" %d,", *sequenceNumberAt);
|
||||
}
|
||||
//printf("\n");
|
||||
|
||||
_octreeSceneStatsLock.unlock();
|
||||
|
||||
// make sure we still have an active socket????
|
||||
nodeList->writeUnverifiedDatagram(packet, dataAt-packet, node);
|
||||
nodeList->writeUnverifiedDatagram(packet, dataAt - packet, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ int populatePacketHeader(char* packet, PacketType type, const QUuid& connectionU
|
|||
position += NUM_BYTES_RFC4122_UUID;
|
||||
|
||||
if (!NON_VERIFIED_PACKETS.contains(type)) {
|
||||
// pack 16 bytes of zeros where the md5 hash will be placed one data is packed
|
||||
// pack 16 bytes of zeros where the md5 hash will be placed once data is packed
|
||||
memset(position, 0, NUM_BYTES_MD5_HASH);
|
||||
position += NUM_BYTES_MD5_HASH;
|
||||
}
|
||||
|
|
|
@ -275,8 +275,8 @@ private:
|
|||
quint32 _incomingLate; /// out of order later than expected
|
||||
quint32 _incomingReallyLate; /// out of order and later than MAX_MISSING_SEQUENCE_OLD_AGE late
|
||||
quint32 _incomingPossibleDuplicate; /// out of order possibly a duplicate
|
||||
QSet<OCTREE_PACKET_SEQUENCE> _missingSequenceNumbers;
|
||||
QSet<OCTREE_PACKET_SEQUENCE> _sequenceNumbersToNack;
|
||||
QSet<uint16_t> _missingSequenceNumbers;
|
||||
QSet<uint16_t> _sequenceNumbersToNack;
|
||||
SimpleMovingAverage _incomingFlightTimeAverage;
|
||||
|
||||
// features related items
|
||||
|
|
Loading…
Reference in a new issue