diff --git a/src/object/client/Mirror.cpp b/src/object/client/Mirror.cpp index c7e90cf..eac065d 100644 --- a/src/object/client/Mirror.cpp +++ b/src/object/client/Mirror.cpp @@ -8,6 +8,34 @@ #include "object/client/CGPlayer.hpp" #include "object/client/CGUnit.hpp" #include "object/client/ObjMgr.hpp" +#include + +#define MAX_DIRTY_MASKS 42 + +/** + * Given a message data store, extract the dirty masks contained inside. Any masks not present are + * zeroed out. This function assumes the provided masks pointer has enough space for + * MAX_DIRTY_MASKS. + */ +int32_t ExtractDirtyMasks(CDataStore* msg, uint8_t* maskCount, uint32_t* masks) { + uint8_t count; + msg->Get(count); + + *maskCount = count; + + if (count > MAX_DIRTY_MASKS) { + return 0; + } + + for (int32_t i = 0; i < count; i++) { + msg->Get(masks[i]); + } + + // Zero out unused masks + memset(&masks[count], 0, (MAX_DIRTY_MASKS - count) * sizeof(uint32_t)); + + return 1; +} /** * Given an object type hierarchy and GUID, return the number of DWORD blocks backing the object's