mirror of
https://github.com/overte-org/overte.git
synced 2025-07-10 18:58:37 +02:00
removed old SentPacketHistory
This commit is contained in:
parent
69c2a2d12b
commit
14f50f4576
2 changed files with 0 additions and 79 deletions
|
@ -1,44 +0,0 @@
|
||||||
//
|
|
||||||
// SentPacketHistory.cpp
|
|
||||||
// assignement-client/src/octree
|
|
||||||
//
|
|
||||||
// Created by Yixin Wang on 6/5/2014
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "SentPacketHistory.h"
|
|
||||||
|
|
||||||
SentPacketHistory::SentPacketHistory(int size)
|
|
||||||
: _sentPackets(size),
|
|
||||||
_newestPacketAt(0),
|
|
||||||
_numExistingPackets(0),
|
|
||||||
_newestSequenceNumber(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void SentPacketHistory::packetSent(OCTREE_PACKET_SEQUENCE sequenceNumber, const QByteArray& packet) {
|
|
||||||
_newestSequenceNumber = sequenceNumber;
|
|
||||||
|
|
||||||
// increment _newestPacketAt cyclically, insert new packet there.
|
|
||||||
// this will overwrite the oldest packet in the buffer
|
|
||||||
_newestPacketAt = (_newestPacketAt == _sentPackets.size() - 1) ? 0 : _newestPacketAt + 1;
|
|
||||||
_sentPackets[_newestPacketAt] = packet;
|
|
||||||
if (_numExistingPackets < _sentPackets.size()) {
|
|
||||||
_numExistingPackets++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const QByteArray* SentPacketHistory::getPacket(OCTREE_PACKET_SEQUENCE sequenceNumber) const {
|
|
||||||
OCTREE_PACKET_SEQUENCE seqDiff = _newestSequenceNumber - sequenceNumber;
|
|
||||||
if (!(seqDiff >= 0 && seqDiff < _numExistingPackets)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
int packetAt = _newestPacketAt - seqDiff;
|
|
||||||
if (packetAt < 0) {
|
|
||||||
packetAt += _sentPackets.size();
|
|
||||||
}
|
|
||||||
return &_sentPackets.at(packetAt);
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
//
|
|
||||||
// SentPacketHistory.h
|
|
||||||
// assignement-client/src/octree
|
|
||||||
//
|
|
||||||
// Created by Yixin Wang on 6/5/2014
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef hifi_SentPacketHistory_h
|
|
||||||
#define hifi_SentPacketHistory_h
|
|
||||||
|
|
||||||
#include <qbytearray.h>
|
|
||||||
#include <qvector.h>
|
|
||||||
|
|
||||||
#include "OctreePacketData.h"
|
|
||||||
|
|
||||||
class SentPacketHistory {
|
|
||||||
|
|
||||||
public:
|
|
||||||
SentPacketHistory(int size);
|
|
||||||
|
|
||||||
void packetSent(OCTREE_PACKET_SEQUENCE sequenceNumber, const QByteArray& packet);
|
|
||||||
const QByteArray* getPacket(OCTREE_PACKET_SEQUENCE sequenceNumber) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QVector<QByteArray> _sentPackets; // circular buffer
|
|
||||||
int _newestPacketAt;
|
|
||||||
int _numExistingPackets;
|
|
||||||
|
|
||||||
OCTREE_PACKET_SEQUENCE _newestSequenceNumber;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in a new issue