mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-04 16:23:52 +00:00
refactor: add Packet::writePackedGuid, remove redundant static methods
Add writePackedGuid() to Packet class for read/write symmetry. Remove now-redundant UpdateObjectParser::readPackedGuid and MovementPacket::writePackedGuid static methods. Replace 6 internal readPackedGuid calls, 9 writePackedGuid calls, and 1 inline 14-line transport GUID write with Packet method calls.
This commit is contained in:
parent
2c79d82446
commit
43caf7b5e6
7 changed files with 36 additions and 78 deletions
|
|
@ -97,6 +97,22 @@ uint64_t Packet::readPackedGuid() {
|
|||
return guid;
|
||||
}
|
||||
|
||||
void Packet::writePackedGuid(uint64_t guid) {
|
||||
uint8_t mask = 0;
|
||||
uint8_t guidBytes[8];
|
||||
int count = 0;
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
uint8_t byte = static_cast<uint8_t>((guid >> (i * 8)) & 0xFF);
|
||||
if (byte != 0) {
|
||||
mask |= (1 << i);
|
||||
guidBytes[count++] = byte;
|
||||
}
|
||||
}
|
||||
writeUInt8(mask);
|
||||
for (int i = 0; i < count; ++i)
|
||||
writeUInt8(guidBytes[i]);
|
||||
}
|
||||
|
||||
std::string Packet::readString() {
|
||||
std::string result;
|
||||
while (readPos < data.size()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue