mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 15:50:20 +00:00
Fix handleInstanceDifficulty to handle variable-length packet formats
MSG_SET_DUNGEON_DIFFICULTY sends 4 or 12 bytes (difficulty + optional isInGroup + savedBool) while SMSG_INSTANCE_DIFFICULTY sends 8 bytes (difficulty + heroic). The previous guard of < 8 caused the handler to silently return for 4-byte variants, leaving instanceDifficulty_ unchanged. Now reads as much as available and infers heroic flag from the field count.
This commit is contained in:
parent
7c77c4a81e
commit
a67feb6d93
1 changed files with 20 additions and 3 deletions
|
|
@ -12266,10 +12266,27 @@ void GameHandler::handleRaidInstanceInfo(network::Packet& packet) {
|
|||
}
|
||||
|
||||
void GameHandler::handleInstanceDifficulty(network::Packet& packet) {
|
||||
if (packet.getSize() - packet.getReadPos() < 8) return;
|
||||
// SMSG_INSTANCE_DIFFICULTY: uint32 difficulty, uint32 heroic (8 bytes)
|
||||
// MSG_SET_DUNGEON_DIFFICULTY: uint32 difficulty[, uint32 isInGroup, uint32 savedBool] (4 or 12 bytes)
|
||||
auto rem = [&]() { return packet.getSize() - packet.getReadPos(); };
|
||||
if (rem() < 4) return;
|
||||
instanceDifficulty_ = packet.readUInt32();
|
||||
uint32_t isHeroic = packet.readUInt32();
|
||||
instanceIsHeroic_ = (isHeroic != 0);
|
||||
if (rem() >= 4) {
|
||||
uint32_t secondField = packet.readUInt32();
|
||||
// SMSG_INSTANCE_DIFFICULTY: second field is heroic flag (0 or 1)
|
||||
// MSG_SET_DUNGEON_DIFFICULTY: second field is isInGroup (not heroic)
|
||||
// Heroic = difficulty value 1 for 5-man, so use the field value for SMSG and
|
||||
// infer from difficulty for MSG variant (which has larger payloads).
|
||||
if (rem() >= 4) {
|
||||
// Three+ fields: this is MSG_SET_DUNGEON_DIFFICULTY; heroic = (difficulty == 1)
|
||||
instanceIsHeroic_ = (instanceDifficulty_ == 1);
|
||||
} else {
|
||||
// Two fields: SMSG_INSTANCE_DIFFICULTY format
|
||||
instanceIsHeroic_ = (secondField != 0);
|
||||
}
|
||||
} else {
|
||||
instanceIsHeroic_ = (instanceDifficulty_ == 1);
|
||||
}
|
||||
LOG_INFO("Instance difficulty: ", instanceDifficulty_, " heroic=", instanceIsHeroic_);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue