remove more PacketHeader methods

This commit is contained in:
Stephen Birarda 2015-07-16 16:05:27 -07:00
parent 61653bd88d
commit 1bb3e1789a
3 changed files with 1 additions and 33 deletions

View file

@ -126,36 +126,10 @@ QString nameForPacketType(PacketType::Value packetType) {
return QString("unexpected");
}
int numBytesForPacketHeader(const QByteArray& packet) {
PacketType::Value packetType = packetTypeForPacket(packet);
return numBytesForPacketHeaderGivenPacketType(packetType);
}
int numBytesForPacketHeader(const char* packet) {
PacketType::Value packetType = packetTypeForPacket(packet);
return numBytesForPacketHeaderGivenPacketType(packetType);
}
int numBytesForArithmeticCodedPacketType(PacketType::Value packetType) {
return (int) ceilf((float) packetType / 255);
}
int numBytesForPacketHeaderGivenPacketType(PacketType::Value packetType) {
return numBytesForArithmeticCodedPacketType(packetType)
+ numHashBytesForType(packetType)
+ numSequenceNumberBytesForType(packetType)
+ NUM_STATIC_HEADER_BYTES;
}
int numHashBytesForType(PacketType::Value packetType) {
return (NON_VERIFIED_PACKETS.contains(packetType) ? 0 : NUM_BYTES_MD5_HASH);
}
int numSequenceNumberBytesForType(PacketType::Value packetType) {
return (SEQUENCE_NUMBERED_PACKETS.contains(packetType) ? sizeof(PacketSequenceNumber) : 0);
}
PacketType::Value packetTypeForPacket(const QByteArray& packet) {
return (PacketType::Value) arithmeticCodingValueFromBuffer(packet.data());
}

View file

@ -92,13 +92,7 @@ extern const QSet<PacketType::Value> SEQUENCE_NUMBERED_PACKETS;
extern const QSet<PacketType::Value> NON_SOURCED_PACKETS;
const int NUM_BYTES_MD5_HASH = 16;
const int NUM_STATIC_HEADER_BYTES = sizeof(PacketVersion) + NUM_BYTES_RFC4122_UUID;
const int MAX_PACKET_HEADER_BYTES = sizeof(PacketType::Value) + NUM_BYTES_MD5_HASH + NUM_STATIC_HEADER_BYTES;
PacketType::Value packetTypeForPacket(const QByteArray& packet);
PacketType::Value packetTypeForPacket(const char* packet);
PacketVersion versionForPacketType(PacketType::Value packetType);
QString nameForPacketType(PacketType::Value packetType);
const QUuid nullUUID = QUuid();

View file

@ -346,7 +346,7 @@ void OctreeEditPacketSender::processNackPacket(NLPacket& packet, SharedNodePoint
if (_sentPacketHistories.count(sendingNode->getUUID()) == 0) {
return;
}
const SentPacketHistory& sentPacketHistory = _sentPacketHistories[sendingNode->getSourceID()];
const SentPacketHistory& sentPacketHistory = _sentPacketHistories[sendingNode->getUUID()];
// read sequence numbers and queue packets for resend
while (packet.bytesLeftToRead() > 0) {