mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
fix for arguments that are now const NLPacket&
This commit is contained in:
parent
765265abd8
commit
c903d284bb
3 changed files with 12 additions and 8 deletions
|
@ -38,7 +38,7 @@ void SentPacketHistory::packetSent(uint16_t sequenceNumber, const NLPacket& pack
|
|||
_sentPackets.insert(NLPacket::createCopy(packet));
|
||||
}
|
||||
|
||||
const NLPacket& SentPacketHistory::getPacket(uint16_t sequenceNumber) const {
|
||||
const NLPacket* SentPacketHistory::getPacket(uint16_t sequenceNumber) const {
|
||||
|
||||
const int UINT16_RANGE = std::numeric_limits<uint16_t>::max() + 1;
|
||||
|
||||
|
@ -48,6 +48,10 @@ const NLPacket& SentPacketHistory::getPacket(uint16_t sequenceNumber) const {
|
|||
if (seqDiff < 0) {
|
||||
seqDiff += UINT16_RANGE;
|
||||
}
|
||||
|
||||
return *_sentPackets.get(seqDiff)->get();
|
||||
auto packet = _sentPackets.get(seqDiff);
|
||||
if (packet) {
|
||||
return packet->get();
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
SentPacketHistory(int size = MAX_REASONABLE_SEQUENCE_GAP);
|
||||
|
||||
void packetSent(uint16_t sequenceNumber, const NLPacket& packet);
|
||||
const NLPacket& getPacket(uint16_t sequenceNumber) const;
|
||||
const NLPacket* getPacket(uint16_t sequenceNumber) const;
|
||||
|
||||
private:
|
||||
RingBufferHistory<std::unique_ptr<NLPacket>> _sentPackets; // circular buffer
|
||||
|
|
|
@ -108,7 +108,7 @@ void OctreeEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, std::uniqu
|
|||
}
|
||||
|
||||
// add packet to history
|
||||
_sentPacketHistories[nodeUUID].packetSent(sequence, packet);
|
||||
_sentPacketHistories[nodeUUID].packetSent(sequence, *packet.get());
|
||||
|
||||
queuePacketForSending(node, std::move(packet));
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ void OctreeEditPacketSender::queuePacketToNodes(std::unique_ptr<NLPacket> packet
|
|||
|
||||
if (isMyJurisdiction) {
|
||||
// make a copy of this packet for this node and queue
|
||||
auto packetCopy = NLPacket::createCopy(packet);
|
||||
auto packetCopy = NLPacket::createCopy(*packet.get());
|
||||
queuePacketToNode(nodeUUID, std::move(packetCopy));
|
||||
}
|
||||
}
|
||||
|
@ -362,10 +362,10 @@ void OctreeEditPacketSender::processNackPacket(const QByteArray& packet) {
|
|||
dataAt += sizeof(unsigned short int);
|
||||
|
||||
// retrieve packet from history
|
||||
const std::unique_ptr<NLPacket>& packet = sentPacketHistory.getPacket(sequenceNumber);
|
||||
const NLPacket* packet = sentPacketHistory.getPacket(sequenceNumber);
|
||||
if (packet) {
|
||||
const SharedNodePointer& node = DependencyManager::get<NodeList>()->nodeWithUUID(sendingNodeUUID);
|
||||
queuePacketForSending(node, NLPacket::createCopy(packet));
|
||||
queuePacketForSending(node, NLPacket::createCopy(*packet));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue