From 3332062f86707ea251a1fdbeace55adb12caae67 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Tue, 13 Jan 2026 23:04:21 -0600 Subject: [PATCH] feat(object): handle disabled objects in GetUpdateObject --- src/object/client/ClntObjMgr.hpp | 2 ++ src/object/client/Util.cpp | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/object/client/ClntObjMgr.hpp b/src/object/client/ClntObjMgr.hpp index baf848d..7cd4fe3 100644 --- a/src/object/client/ClntObjMgr.hpp +++ b/src/object/client/ClntObjMgr.hpp @@ -12,8 +12,10 @@ class ClntObjMgr { public: // Member variables TSHashTable m_objects; + TSHashTable m_lazyCleanupObjects; // TODO STORM_EXPLICIT_LIST(CGObject_C, m_link) m_visibleObjects; + STORM_EXPLICIT_LIST(CGObject_C, m_link) m_reenabledObjects; // TODO WOWGUID m_activePlayer = 0; uint32_t m_mapID = 0; diff --git a/src/object/client/Util.cpp b/src/object/client/Util.cpp index 4690487..b4142ca 100644 --- a/src/object/client/Util.cpp +++ b/src/object/client/Util.cpp @@ -17,6 +17,8 @@ CGObject_C* FindActiveObject(WOWGUID guid) { CGObject_C* GetUpdateObject(WOWGUID guid, int32_t* reenabled) { *reenabled = false; + // Active object + auto activeObject = FindActiveObject(guid); if (activeObject) { @@ -25,7 +27,32 @@ CGObject_C* GetUpdateObject(WOWGUID guid, int32_t* reenabled) { return activeObject; } - // TODO handle reenabling object + // Disabled object + + auto disabledObject = ClntObjMgrGetCurrent()->m_lazyCleanupObjects.Ptr(guid, CHashKeyGUID(guid)); + + if (disabledObject) { + ClntObjMgrGetCurrent()->m_lazyCleanupObjects.Unlink(disabledObject); + disabledObject->m_link.Unlink(); + + ClntObjMgrGetCurrent()->m_objects.Insert(disabledObject, guid, CHashKeyGUID(guid)); + + // These link checks are guaranteed to pass because of the unlink above (both lists share + // the same link). This check is either from an inlined function or is cruft left behind + // after a refactor. + if ( + !ClntObjMgrGetCurrent()->m_visibleObjects.IsLinked(disabledObject) + && !ClntObjMgrGetCurrent()->m_reenabledObjects.IsLinked(disabledObject) + ) { + *reenabled = true; + ClntObjMgrGetCurrent()->m_reenabledObjects.LinkToTail(disabledObject); + } + + return disabledObject; + } + + // Object not found + return nullptr; }