From dcd69240b6a57e4e4687febd9422069c184a4cae Mon Sep 17 00:00:00 2001 From: Shauren Date: Tue, 15 Jan 2019 16:54:57 +0100 Subject: Core/Commands: Fixed creature/gameobject move commands not updating which cell they belong to Closes #22720 (cherry picked from commit ec1cfa36f4c286ad8037516460a4e99ea5d7a5ed) --- src/server/scripts/Commands/cs_gobject.cpp | 4 ++++ src/server/scripts/Commands/cs_npc.cpp | 2 ++ 2 files changed, 6 insertions(+) (limited to 'src/server/scripts') diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index 4a6d3a37c4b..7b3aed3bd43 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -497,7 +497,11 @@ public: Map* map = object->GetMap(); object->Relocate(x, y, z, object->GetOrientation()); + + // update which cell has this gameobject registered for loading + sObjectMgr->RemoveGameobjectFromGrid(guidLow, object->GetGameObjectData()); object->SaveToDB(); + sObjectMgr->AddGameobjectToGrid(guidLow, object->GetGameObjectData()); // Generate a completely new spawn with new guid // 3.3.5a client caches recently deleted objects and brings them back to life diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 0c82ee14b7f..fe1f60033ed 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -819,7 +819,9 @@ public: } // update position in memory + sObjectMgr->RemoveCreatureFromGrid(lowguid, data); const_cast(data)->spawnPoint.Relocate(*player); + sObjectMgr->AddCreatureToGrid(lowguid, data); // update position in DB WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_POSITION); -- cgit v1.2.3