diff --git a/libraries/networking/src/NLPacket.cpp b/libraries/networking/src/NLPacket.cpp index c34e589eff..7a6503dbc3 100644 --- a/libraries/networking/src/NLPacket.cpp +++ b/libraries/networking/src/NLPacket.cpp @@ -64,13 +64,7 @@ std::unique_ptr NLPacket::fromReceivedPacket(std::unique_ptr dat } std::unique_ptr NLPacket::createCopy(const NLPacket& other) { - auto packet = std::unique_ptr(new NLPacket(other)); - - if (other.isOpen()) { - packet->open(other.openMode()); - } - - return packet; + return std::unique_ptr(new NLPacket(other)); } NLPacket::NLPacket(PacketType::Value type, qint64 size) : diff --git a/libraries/networking/src/udt/Packet.cpp b/libraries/networking/src/udt/Packet.cpp index 5be229e129..02a44c4a4f 100644 --- a/libraries/networking/src/udt/Packet.cpp +++ b/libraries/networking/src/udt/Packet.cpp @@ -44,13 +44,7 @@ std::unique_ptr Packet::fromReceivedPacket(std::unique_ptr data, q } std::unique_ptr Packet::createCopy(const Packet& other) { - auto packet = std::unique_ptr(new Packet(other)); - - if (other.isOpen()) { - packet->open(other.openMode()); - } - - return packet; + return std::unique_ptr(new Packet(other)); } qint64 Packet::totalHeadersSize() const { @@ -104,6 +98,11 @@ Packet::Packet(const Packet& other) : QIODevice() { *this = other; + + if (other.isOpen()) { + this->open(other.openMode()); + } + this->seek(other.pos()); } diff --git a/libraries/networking/src/udt/Packet.h b/libraries/networking/src/udt/Packet.h index 33fa8134bc..b4c53b8165 100644 --- a/libraries/networking/src/udt/Packet.h +++ b/libraries/networking/src/udt/Packet.h @@ -81,7 +81,7 @@ public: using QIODevice::read; QByteArray read(qint64 maxSize); - + template qint64 peekPrimitive(T* data); template qint64 readPrimitive(T* data); template qint64 writePrimitive(const T& data); diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index eb8ca12b69..0591ac30fe 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -69,7 +69,7 @@ PacketVersion versionForPacketType(PacketType::Value packetType) { case EntityData: return VERSION_ENTITIES_NEW_PROTOCOL_LAYER; default: - return 10; + return 11; } } diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index a66c9ea566..3f3f165e87 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -27,7 +27,7 @@ // NOTE: if you want the name of the packet packetType to be available for debugging or logging, update nameForPacketType() as well namespace PacketType { - enum Value { + enum Value { Unknown, StunResponse, DomainList, @@ -62,18 +62,18 @@ namespace PacketType { DomainConnectRequest, DomainServerRequireDTLS, NodeJsonStats, - EntityQuery, - EntityData, - EntityAdd, - EntityErase, - EntityEdit, OctreeDataNack, StopNode, AudioEnvironment, EntityEditNack, ICEServerHeartbeat, ICEPing, - ICEPingReply + ICEPingReply, + EntityData, + EntityQuery, + EntityAdd, + EntityErase, + EntityEdit }; }; @@ -138,6 +138,6 @@ const PacketVersion VERSION_ENTITIES_FACE_CAMERA = 30; const PacketVersion VERSION_ENTITIES_SCRIPT_TIMESTAMP = 31; const PacketVersion VERSION_ENTITIES_SCRIPT_TIMESTAMP_FIX = 32; const PacketVersion VERSION_ENTITIES_HAVE_SIMULATION_OWNER_AND_ACTIONS_OVER_WIRE = 33; -const PacketVersion VERSION_ENTITIES_NEW_PROTOCOL_LAYER = 34; +const PacketVersion VERSION_ENTITIES_NEW_PROTOCOL_LAYER = 35; #endif // hifi_PacketHeaders_h