mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:38:29 +02:00
fix writes in JurisdictionMap
This commit is contained in:
parent
9f4e4f1948
commit
c162d53908
1 changed files with 7 additions and 7 deletions
|
@ -273,9 +273,9 @@ std::unique_ptr<NLPacket> JurisdictionMap::packEmptyJurisdictionIntoMessage(Node
|
||||||
auto packet = NLPacket::create(PacketType::Jurisdiction, sizeof(type) + sizeof(bytes));
|
auto packet = NLPacket::create(PacketType::Jurisdiction, sizeof(type) + sizeof(bytes));
|
||||||
|
|
||||||
// Pack the Node Type in first byte
|
// Pack the Node Type in first byte
|
||||||
packet->write(type);
|
packet->writePrimitive(type);
|
||||||
// No root or end node details to pack!
|
// No root or end node details to pack!
|
||||||
packet->write(bytes);
|
packet->writePrimitive(bytes);
|
||||||
|
|
||||||
return std::move(packet); // includes header!
|
return std::move(packet); // includes header!
|
||||||
}
|
}
|
||||||
|
@ -285,18 +285,18 @@ std::unique_ptr<NLPacket> JurisdictionMap::packIntoMessage() {
|
||||||
|
|
||||||
// Pack the Node Type in first byte
|
// Pack the Node Type in first byte
|
||||||
NodeType_t type = getNodeType();
|
NodeType_t type = getNodeType();
|
||||||
packet->write(type);
|
packet->writePrimitive(type);
|
||||||
|
|
||||||
// add the root jurisdiction
|
// add the root jurisdiction
|
||||||
if (_rootOctalCode) {
|
if (_rootOctalCode) {
|
||||||
size_t bytes = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(_rootOctalCode));
|
size_t bytes = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(_rootOctalCode));
|
||||||
// No root or end node details to pack!
|
// No root or end node details to pack!
|
||||||
packet->write(bytes);
|
packet->writePrimitive(bytes);
|
||||||
packet->write(reinterpret_cast<char*>(_rootOctalCode), bytes);
|
packet->write(reinterpret_cast<char*>(_rootOctalCode), bytes);
|
||||||
|
|
||||||
// if and only if there's a root jurisdiction, also include the end nodes
|
// if and only if there's a root jurisdiction, also include the end nodes
|
||||||
int endNodeCount = _endNodes.size();
|
int endNodeCount = _endNodes.size();
|
||||||
packet->write(endNodeCount);
|
packet->writePrimitive(endNodeCount);
|
||||||
|
|
||||||
for (int i=0; i < endNodeCount; i++) {
|
for (int i=0; i < endNodeCount; i++) {
|
||||||
unsigned char* endNodeCode = _endNodes[i];
|
unsigned char* endNodeCode = _endNodes[i];
|
||||||
|
@ -304,12 +304,12 @@ std::unique_ptr<NLPacket> JurisdictionMap::packIntoMessage() {
|
||||||
if (endNodeCode) {
|
if (endNodeCode) {
|
||||||
bytes = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(endNodeCode));
|
bytes = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(endNodeCode));
|
||||||
}
|
}
|
||||||
packet->write(bytes);
|
packet->writePrimitive(bytes);
|
||||||
packet->write(reinterpret_cast<char*>(endNodeCode), bytes);
|
packet->write(reinterpret_cast<char*>(endNodeCode), bytes);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int bytes = 0;
|
int bytes = 0;
|
||||||
packet->write(bytes);
|
packet->writePrimitive(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::move(packet);
|
return std::move(packet);
|
||||||
|
|
Loading…
Reference in a new issue