mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 23:57:13 +02:00
fix bugs from movement of type/version to NLPacket
This commit is contained in:
parent
2f03075750
commit
069dff0793
4 changed files with 20 additions and 8 deletions
|
@ -16,9 +16,9 @@ qint64 NLPacket::maxPayloadSize(PacketType type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 NLPacket::localHeaderSize(PacketType type) {
|
qint64 NLPacket::localHeaderSize(PacketType type) {
|
||||||
qint64 size = ((NON_SOURCED_PACKETS.contains(type)) ? 0 : NUM_BYTES_RFC4122_UUID) +
|
qint64 optionalSize = ((NON_SOURCED_PACKETS.contains(type)) ? 0 : NUM_BYTES_RFC4122_UUID) +
|
||||||
((NON_SOURCED_PACKETS.contains(type) || NON_VERIFIED_PACKETS.contains(type)) ? 0 : NUM_BYTES_MD5_HASH);
|
((NON_SOURCED_PACKETS.contains(type) || NON_VERIFIED_PACKETS.contains(type)) ? 0 : NUM_BYTES_MD5_HASH);
|
||||||
return size;
|
return sizeof(PacketType) + sizeof(PacketVersion) + optionalSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 NLPacket::maxPayloadSize() const {
|
qint64 NLPacket::maxPayloadSize() const {
|
||||||
|
@ -85,6 +85,8 @@ NLPacket::NLPacket(PacketType type, bool isReliable, bool isPartOfMessage) :
|
||||||
_version(versionForPacketType(type))
|
_version(versionForPacketType(type))
|
||||||
{
|
{
|
||||||
adjustPayloadStartAndCapacity();
|
adjustPayloadStartAndCapacity();
|
||||||
|
|
||||||
|
writeTypeAndVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
NLPacket::NLPacket(PacketType type, qint64 size, bool isReliable, bool isPartOfMessage) :
|
NLPacket::NLPacket(PacketType type, qint64 size, bool isReliable, bool isPartOfMessage) :
|
||||||
|
@ -104,10 +106,14 @@ NLPacket::NLPacket(std::unique_ptr<Packet> packet) :
|
||||||
{
|
{
|
||||||
adjustPayloadStartAndCapacity(_payloadSize > 0);
|
adjustPayloadStartAndCapacity(_payloadSize > 0);
|
||||||
|
|
||||||
|
readType();
|
||||||
|
readVersion();
|
||||||
readSourceID();
|
readSourceID();
|
||||||
}
|
}
|
||||||
|
|
||||||
NLPacket::NLPacket(const NLPacket& other) : Packet(other) {
|
NLPacket::NLPacket(const NLPacket& other) : Packet(other) {
|
||||||
|
_type = other._type;
|
||||||
|
_version = other._version;
|
||||||
_sourceID = other._sourceID;
|
_sourceID = other._sourceID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,14 +131,18 @@ NLPacket::NLPacket(std::unique_ptr<char> data, qint64 size, const HifiSockAddr&
|
||||||
}
|
}
|
||||||
|
|
||||||
NLPacket::NLPacket(NLPacket&& other) :
|
NLPacket::NLPacket(NLPacket&& other) :
|
||||||
Packet(other)
|
Packet(std::move(other))
|
||||||
{
|
{
|
||||||
|
_type = other._type;
|
||||||
|
_version = other._version;
|
||||||
_sourceID = std::move(other._sourceID);
|
_sourceID = std::move(other._sourceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
NLPacket& NLPacket::operator=(const NLPacket& other) {
|
NLPacket& NLPacket::operator=(const NLPacket& other) {
|
||||||
Packet::operator=(other);
|
Packet::operator=(other);
|
||||||
|
|
||||||
|
_type = other._type;
|
||||||
|
_version = other._version;
|
||||||
_sourceID = other._sourceID;
|
_sourceID = other._sourceID;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -142,6 +152,8 @@ NLPacket& NLPacket::operator=(NLPacket&& other) {
|
||||||
|
|
||||||
Packet::operator=(std::move(other));
|
Packet::operator=(std::move(other));
|
||||||
|
|
||||||
|
_type = other._type;
|
||||||
|
_version = other._version;
|
||||||
_sourceID = std::move(other._sourceID);
|
_sourceID = std::move(other._sourceID);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -188,8 +200,7 @@ void NLPacket::writeTypeAndVersion() {
|
||||||
memcpy(_packet.get() + headerOffset, &_type, sizeof(PacketType));
|
memcpy(_packet.get() + headerOffset, &_type, sizeof(PacketType));
|
||||||
|
|
||||||
// Pack the packet version
|
// Pack the packet version
|
||||||
auto version = versionForPacketType(_type);
|
memcpy(_packet.get() + headerOffset + sizeof(PacketType), &_version, sizeof(_version));
|
||||||
memcpy(_packet.get() + headerOffset + sizeof(PacketType), &version, sizeof(version));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NLPacket::setType(PacketType type) {
|
void NLPacket::setType(PacketType type) {
|
||||||
|
|
|
@ -533,8 +533,7 @@ void NodeList::sendAssignment(Assignment& assignment) {
|
||||||
|
|
||||||
QDataStream packetStream(assignmentPacket.get());
|
QDataStream packetStream(assignmentPacket.get());
|
||||||
packetStream << assignment;
|
packetStream << assignment;
|
||||||
|
|
||||||
// TODO: should this be a non sourced packet?
|
|
||||||
sendPacket(std::move(assignmentPacket), _assignmentServerSocket);
|
sendPacket(std::move(assignmentPacket), _assignmentServerSocket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,8 @@ BasePacket& BasePacket::operator=(const BasePacket& other) {
|
||||||
|
|
||||||
_payloadSize = other._payloadSize;
|
_payloadSize = other._payloadSize;
|
||||||
|
|
||||||
|
_senderSockAddr = other._senderSockAddr;
|
||||||
|
|
||||||
if (other.isOpen() && !isOpen()) {
|
if (other.isOpen() && !isOpen()) {
|
||||||
open(other.openMode());
|
open(other.openMode());
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ Packet& Packet::operator=(const Packet& other) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Packet::Packet(Packet&& other) :
|
Packet::Packet(Packet&& other) :
|
||||||
BasePacket(other)
|
BasePacket(std::move(other))
|
||||||
{
|
{
|
||||||
_isReliable = other._isReliable;
|
_isReliable = other._isReliable;
|
||||||
_isPartOfMessage = other._isPartOfMessage;
|
_isPartOfMessage = other._isPartOfMessage;
|
||||||
|
|
Loading…
Reference in a new issue