mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-04 16:23:52 +00:00
refactor: add Packet::hasData(), replace 52 position checks and 14 more Lua guards
Add Packet::hasData() for 'has remaining data' checks, replacing 52 verbose getReadPos()<getSize() comparisons across 3 files. Also replace 14 more standalone Lua return patterns with luaReturnNil/Zero helpers.
This commit is contained in:
parent
4c26b1a8ae
commit
12355316b3
5 changed files with 67 additions and 66 deletions
|
|
@ -1246,7 +1246,7 @@ bool ClassicPacketParsers::parseMessageChat(network::Packet& packet, MessageChat
|
|||
}
|
||||
|
||||
// Read chat tag
|
||||
if (packet.getReadPos() < packet.getSize()) {
|
||||
if (packet.hasData()) {
|
||||
data.chatTag = packet.readUInt8();
|
||||
}
|
||||
|
||||
|
|
@ -1855,7 +1855,7 @@ bool ClassicPacketParsers::parseItemQueryResponse(network::Packet& packet, ItemQ
|
|||
data.bindType = packet.readUInt32();
|
||||
|
||||
// Description (flavor/lore text)
|
||||
if (packet.getReadPos() < packet.getSize())
|
||||
if (packet.hasData())
|
||||
data.description = packet.readString();
|
||||
|
||||
// Post-description: PageText, LanguageID, PageMaterial, StartQuest
|
||||
|
|
@ -2095,7 +2095,7 @@ bool TurtlePacketParsers::parseUpdateObject(network::Packet& packet, UpdateObjec
|
|||
}
|
||||
|
||||
if (withHasTransportByte) {
|
||||
if (packet.getReadPos() >= packet.getSize()) {
|
||||
if (!packet.hasData()) {
|
||||
packet.setReadPos(start);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2122,7 +2122,7 @@ bool TurtlePacketParsers::parseUpdateObject(network::Packet& packet, UpdateObjec
|
|||
return false;
|
||||
}
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
if (packet.getReadPos() >= packet.getSize()) {
|
||||
if (!packet.hasData()) {
|
||||
packet.setReadPos(start);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2136,7 +2136,7 @@ bool TurtlePacketParsers::parseUpdateObject(network::Packet& packet, UpdateObjec
|
|||
out.blockCount = remainingBlockCount;
|
||||
out.blocks.reserve(out.blockCount);
|
||||
for (uint32_t i = 0; i < out.blockCount; ++i) {
|
||||
if (packet.getReadPos() >= packet.getSize()) {
|
||||
if (!packet.hasData()) {
|
||||
packet.setReadPos(start);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2167,7 +2167,7 @@ bool TurtlePacketParsers::parseUpdateObject(network::Packet& packet, UpdateObjec
|
|||
case UpdateType::CREATE_OBJECT:
|
||||
case UpdateType::CREATE_OBJECT2:
|
||||
block.guid = packet.readPackedGuid();
|
||||
if (packet.getReadPos() >= packet.getSize()) return false;
|
||||
if (!packet.hasData()) return false;
|
||||
block.objectType = static_cast<ObjectType>(packet.readUInt8());
|
||||
if (!movementParser(packet, block)) return false;
|
||||
if (!UpdateObjectParser::parseUpdateFields(packet, block)) return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue