Skip to content

Commit

Permalink
Add support for partial reading of updatefield changes without having…
Browse files Browse the repository at this point in the history
… seen CreateObject data for that object
  • Loading branch information
Shauren committed Oct 29, 2024
1 parent 9e6b821 commit beea43d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions WowPacketParserModule.V11_0_0_55666/Parsers/UpdateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,29 @@ public static void HandleUpdateObject(Packet packet)
WoWObject obj;
Storage.Objects.TryGetValue(guid, out obj);

var fragments = obj != null ? obj.EntityFragments : [WowCSEntityFragments.CGObject];

fieldsData.ReadBool("IsOwned", i);
if (fieldsData.ReadBool("HasFragmentUpdates", i))
{
switch (fieldsData.ReadByte("ArchetypeSerializationType", i))
{
case 0:
obj.EntityFragments = ReadEntityFragments(fieldsData, "NewEntityFragmentID", i);
fragments = ReadEntityFragments(fieldsData, "NewEntityFragmentID", i);
if (obj != null)
obj.EntityFragments = fragments;
break;
case 1:
obj.EntityFragments.AddRange(ReadEntityFragments(fieldsData, "NewEntityFragmentID", i));
fragments.AddRange(ReadEntityFragments(fieldsData, "NewEntityFragmentID", i));
foreach (var removedFragment in ReadEntityFragments(fieldsData, "RemovedEntityFragmentID", i))
obj.EntityFragments.RemoveAll(f => f == removedFragment);
obj.EntityFragments.Sort();
fragments.RemoveAll(f => f == removedFragment);
fragments.Sort();
break;
}
}

var fragmentBitCount = 0;
foreach (var existingFragment in obj.EntityFragments)
foreach (var existingFragment in fragments)
{
if (!WowCSUtilities.IsUpdateable(existingFragment))
continue;
Expand All @@ -101,7 +105,7 @@ public static void HandleUpdateObject(Packet packet)

var changedFragments = new BitArray(fieldsData.ReadBytes((fragmentBitCount + 7) / 8));

var objectIndirectFragment = WowCSUtilities.GetUpdateBitIndex(obj.EntityFragments, WowCSEntityFragments.CGObject);
var objectIndirectFragment = WowCSUtilities.GetUpdateBitIndex(fragments, WowCSEntityFragments.CGObject);
if (objectIndirectFragment >= 0 && changedFragments[objectIndirectFragment])
{
if (changedFragments[objectIndirectFragment + 1])
Expand Down

0 comments on commit beea43d

Please sign in to comment.