TrinityCore / WowPacketParser

World of Warcraft Packet Parser
GNU General Public License v3.0
426 stars 354 forks source link

[3.3.5] SMSG_ATTACKER_STATE_UPDATE structure #348

Open ariel- opened 6 years ago

ariel- commented 6 years ago

Description: SMSG_ATTACKER_STATE_UPDATE packet structure is wrong for 3.3.5 sniffs and does not match TrinityCore structure.

Current (wrong):

            var hitInfo = packet.ReadInt32E<SpellHitInfo>("HitInfo");
            packet.ReadPackedGuid("AttackerGUID");
            packet.ReadPackedGuid("TargetGUID");
            packet.ReadInt32("Damage");
            packet.ReadInt32("OverDamage");

            var subDmgCount = packet.ReadByte();
            for (var i = 0; i < subDmgCount; ++i)
            {
                packet.ReadInt32("SchoolMask", i);
                packet.ReadSingle("Float Damage", i);
                packet.ReadInt32("Int Damage", i);

                if (hitInfo.HasAnyFlag(SpellHitInfo.HITINFO_PARTIAL_ABSORB | SpellHitInfo.HITINFO_FULL_ABSORB))
                    packet.ReadInt32("Damage Absorbed", i);

                if (hitInfo.HasAnyFlag(SpellHitInfo.HITINFO_PARTIAL_RESIST | SpellHitInfo.HITINFO_FULL_RESIST))
                    packet.ReadInt32("Damage Resisted", i);
            }
...

Expected (correct):

            var hitInfo = packet.ReadInt32E<SpellHitInfo>("HitInfo");
            packet.ReadPackedGuid("AttackerGUID");
            packet.ReadPackedGuid("TargetGUID");
            packet.ReadInt32("Damage");
            packet.ReadInt32("OverDamage");

            var subDmgCount = packet.ReadByte();
            for (var i = 0; i < subDmgCount; ++i)
            {
                packet.ReadInt32("SchoolMask", i);
                packet.ReadSingle("Float Damage", i);
                packet.ReadInt32("Int Damage", i);
            }

            if (hitInfo.HasAnyFlag(SpellHitInfo.HITINFO_PARTIAL_ABSORB | SpellHitInfo.HITINFO_FULL_ABSORB))
            {
                for (var i = 0; i < subDmgCount; ++i)
                    packet.ReadInt32("Damage Absorbed", i);
            }

            if (hitInfo.HasAnyFlag(SpellHitInfo.HITINFO_PARTIAL_RESIST | SpellHitInfo.HITINFO_FULL_RESIST))
            {
                for (var i = 0; i < subDmgCount; ++i)
                    packet.ReadInt32("Damage Resisted", i);
            }
...
ennioVisco commented 6 years ago

Do you have any reference about the correct behavior? Maybe a sniff?

ariel- commented 6 years ago

There's a sniff on the repo which showcases the behaviour, also TrinityCore's own code showing the packet real structure (I don't change the WPP code myself because it has some version conditionals thrown around)

here specifically: https://github.com/TrinityCore/TrinityCore/blob/a93d74c8df26e836211092aaf79d0c199d25decc/src/server/game/Entities/Unit/Unit.cpp#L5460-L5488