cleanup: migrate 20 remaining setReadPos(getSize()) to skipAll()

The Packet::skipAll() method was introduced to replace the verbose
setReadPos(getSize()) pattern. 186 instances were migrated earlier,
but 20 survived in domain handler files created after the migration.
Also removes a redundant single-element for-loop wrapper around
SMSG_LOOT_CLEAR_MONEY registration.
This commit is contained in:
Kelsi 2026-03-29 21:51:03 -07:00
parent ae32b27d6c
commit 8376757f7e
2 changed files with 11 additions and 13 deletions

View file

@ -108,7 +108,7 @@ void CombatHandler::registerOpcodes(DispatchTable& table) {
table[Opcode::SMSG_ENVIRONMENTAL_DAMAGE_LOG] = [this](network::Packet& packet) {
// uint64 victimGuid + uint8 envDmgType + uint32 damage + uint32 absorbed + uint32 resisted
// envDmgType: 0=Exhausted(fatigue), 1=Drowning, 2=Fall, 3=Lava, 4=Slime, 5=Fire
if (!packet.hasRemaining(21)) { packet.setReadPos(packet.getSize()); return; }
if (!packet.hasRemaining(21)) { packet.skipAll(); return; }
uint64_t victimGuid = packet.readUInt64();
uint8_t envType = packet.readUInt8();
uint32_t dmg = packet.readUInt32();
@ -123,7 +123,7 @@ void CombatHandler::registerOpcodes(DispatchTable& table) {
if (envRes > 0)
addCombatText(CombatTextEntry::RESIST, static_cast<int32_t>(envRes), 0, false, 0, 0, victimGuid);
}
packet.setReadPos(packet.getSize());
packet.skipAll();
};
// ---- Threat updates ----
@ -139,7 +139,7 @@ void CombatHandler::registerOpcodes(DispatchTable& table) {
(void)packet.readPackedGuid(); // highest-threat / current target
if (!packet.hasRemaining(4)) return;
uint32_t cnt = packet.readUInt32();
if (cnt > 100) { packet.setReadPos(packet.getSize()); return; } // sanity
if (cnt > 100) { packet.skipAll(); return; } // sanity
std::vector<ThreatEntry> list;
list.reserve(cnt);
for (uint32_t i = 0; i < cnt; ++i) {
@ -562,7 +562,7 @@ void CombatHandler::handleSetForcedReactions(network::Packet& packet) {
uint32_t count = packet.readUInt32();
if (count > 64) {
LOG_WARNING("SMSG_SET_FORCED_REACTIONS: suspicious count ", count, ", ignoring");
packet.setReadPos(packet.getSize());
packet.skipAll();
return;
}
forcedReactions_.clear();

View file

@ -82,9 +82,7 @@ void InventoryHandler::registerOpcodes(DispatchTable& table) {
}
if (owner_.addonEventCallback_) owner_.addonEventCallback_("PLAYER_MONEY", {});
};
for (auto op : { Opcode::SMSG_LOOT_CLEAR_MONEY }) {
table[op] = [](network::Packet& /*packet*/) {};
}
table[Opcode::SMSG_LOOT_CLEAR_MONEY] = [](network::Packet& /*packet*/) {};
// ---- Read item (books) (moved from GameHandler) ----
table[Opcode::SMSG_READ_ITEM_OK] = [this](network::Packet& packet) {
@ -196,7 +194,7 @@ void InventoryHandler::registerOpcodes(DispatchTable& table) {
// +slot(4)+itemId(4)+suffixFactor(4)+randomPropertyId(4)+count(4)+countInInventory(4)
if (!packet.hasRemaining(45)) return;
uint64_t guid = packet.readUInt64();
if (guid != owner_.playerGuid) { packet.setReadPos(packet.getSize()); return; }
if (guid != owner_.playerGuid) { packet.skipAll(); return; }
/*uint32_t received =*/ packet.readUInt32();
/*uint32_t created =*/ packet.readUInt32();
/*uint32_t displayInChat =*/ packet.readUInt32();
@ -540,7 +538,7 @@ void InventoryHandler::registerOpcodes(DispatchTable& table) {
else
owner_.addSystemChatMessage("Your auction of " + itemLink + " has sold!");
}
packet.setReadPos(packet.getSize());
packet.skipAll();
};
table[Opcode::SMSG_AUCTION_BIDDER_NOTIFICATION] = [this](network::Packet& packet) {
@ -584,7 +582,7 @@ void InventoryHandler::registerOpcodes(DispatchTable& table) {
std::string remLink = buildItemLink(itemEntry, remQuality, rawName3);
owner_.addSystemChatMessage("Your auction of " + remLink + " has expired.");
}
packet.setReadPos(packet.getSize());
packet.skipAll();
};
// ---- Equipment Sets ----
@ -1675,7 +1673,7 @@ void InventoryHandler::handleQueryNextMailTime(network::Packet& packet) {
float nextTime = packet.readFloat();
uint32_t count = packet.readUInt32();
hasNewMail_ = (nextTime >= 0.0f && count > 0);
packet.setReadPos(packet.getSize());
packet.skipAll();
}
// ============================================================
@ -2153,7 +2151,7 @@ void InventoryHandler::handleTradeStatusExtended(network::Packet& packet) {
// Per-slot: 4(item)+4(display)+4(stack)+4(wrapped)+8(creator)
// +4(enchant)+3×4(gems)+4(maxDur)+4(dur)+4(spellCharges)
// +4(suffixFactor)+4(randomPropId)+4(lockId) = 64 bytes
if (!packet.hasRemaining(64)) { packet.setReadPos(packet.getSize()); return; }
if (!packet.hasRemaining(64)) { packet.skipAll(); return; }
uint32_t itemId = packet.readUInt32();
uint32_t displayId = packet.readUInt32();
uint32_t stackCnt = packet.readUInt32();
@ -2291,7 +2289,7 @@ void InventoryHandler::handleEquipmentSetList(network::Packet& packet) {
uint32_t count = packet.readUInt32();
if (count > 10) {
LOG_WARNING("SMSG_EQUIPMENT_SET_LIST: unexpected count ", count, ", ignoring");
packet.setReadPos(packet.getSize());
packet.skipAll();
return;
}
equipmentSets_.clear();