mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 19:13:38 +02:00
fix templated write/read and various write calls
This commit is contained in:
parent
7a2be74f34
commit
9f4e4f1948
5 changed files with 10 additions and 9 deletions
|
@ -559,7 +559,7 @@ std::unique_ptr<NLPacket> constructICEPingPacket(PingType_t pingType, const QUui
|
|||
auto icePingPacket = NLPacket::create(PacketType::ICEPing, packetSize);
|
||||
|
||||
icePingPacket->write(iceID.toRfc4122());
|
||||
icePingPacket->write(pingType);
|
||||
icePingPacket->writePrimitive(pingType);
|
||||
|
||||
return icePingPacket;
|
||||
}
|
||||
|
@ -575,7 +575,7 @@ std::unique_ptr<NLPacket> constructICEPingReplyPacket(const QByteArray& pingPack
|
|||
|
||||
// pack the ICE ID and then the ping type
|
||||
icePingReplyPacket->write(iceID.toRfc4122());
|
||||
icePingReplyPacket->write(pingType);
|
||||
icePingReplyPacket->writePrimitive(pingType);
|
||||
|
||||
return icePingReplyPacket;
|
||||
}
|
||||
|
|
|
@ -402,7 +402,7 @@ void NodeList::sendDSPathQuery(const QString& newPath) {
|
|||
|
||||
if (numPathBytes + ((qint64) sizeof(numPathBytes)) < pathQueryPacket->bytesAvailable()) {
|
||||
// append the size of the path to the query packet
|
||||
pathQueryPacket->write(numPathBytes);
|
||||
pathQueryPacket->writePrimitive(numPathBytes);
|
||||
|
||||
// append the path itself to the query packet
|
||||
pathQueryPacket->write(pathQueryUTF8);
|
||||
|
|
|
@ -157,11 +157,12 @@ void Packet::writeSequenceNumber(SequenceNumber seqNum) {
|
|||
&seqNum, sizeof(seqNum));
|
||||
}
|
||||
|
||||
template<typename T> qint64 Packet::read(T* data) {
|
||||
template<typename T> qint64 Packet::readPrimitive(T* data) {
|
||||
return QIODevice::read(reinterpret_cast<char*>(data), sizeof(T));
|
||||
}
|
||||
|
||||
template<typename T> qint64 Packet::write(const T& data) {
|
||||
template<typename T> qint64 Packet::writePrimitive(const T& data) {
|
||||
static_assert(!std::is_pointer<T>::value, "T must not be a pointer");
|
||||
return QIODevice::write(reinterpret_cast<const char*>(&data), sizeof(T));
|
||||
}
|
||||
|
||||
|
|
|
@ -59,8 +59,8 @@ public:
|
|||
virtual bool reset() { setSizeUsed(0); return QIODevice::reset(); }
|
||||
virtual qint64 size() const { return _capacity; }
|
||||
|
||||
template<typename T> qint64 read(T* data);
|
||||
template<typename T> qint64 write(const T& data);
|
||||
template<typename T> qint64 readPrimitive(T* data);
|
||||
template<typename T> qint64 writePrimitive(const T& data);
|
||||
|
||||
protected:
|
||||
Packet(PacketType::Value type, int64_t size);
|
||||
|
|
|
@ -421,7 +421,7 @@ int OctreeSceneStats::packIntoPacket() {
|
|||
// copy the
|
||||
int bytes = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(_jurisdictionRoot));
|
||||
_statsPacket->write(bytes);
|
||||
_statsPacket->write(_jurisdictionRoot, bytes);
|
||||
_statsPacket->write(reinterpret_cast<char*>(_jurisdictionRoot), bytes);
|
||||
|
||||
// if and only if there's a root jurisdiction, also include the end elements
|
||||
int endNodeCount = _jurisdictionEndNodes.size();
|
||||
|
@ -432,7 +432,7 @@ int OctreeSceneStats::packIntoPacket() {
|
|||
unsigned char* endNodeCode = _jurisdictionEndNodes[i];
|
||||
int bytes = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(endNodeCode));
|
||||
_statsPacket->write(bytes);
|
||||
_statsPacket->write(endNodeCode, bytes);
|
||||
_statsPacket->write(reinterpret_cast<char*>(endNodeCode), bytes);
|
||||
}
|
||||
} else {
|
||||
int bytes = 0;
|
||||
|
|
Loading…
Reference in a new issue