From cd92a340825e26fd47f46d87216393c717d210f3 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 24 Aug 2020 10:35:14 -0400 Subject: [PATCH] Scripts/Commands: Fix some quirkiness and potential crashes with live DB modification commands (npc move and npc delete), which are horrible and should be deleted anyway. Port From (https://github.com/TrinityCore/TrinityCore/commit/f15b4f5043799b3a580c8577ad4466135ca9ae38) --- Source/Game/Entities/Creature/Creature.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index 7b8db4187..d0a314fa8 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -1477,6 +1477,11 @@ namespace Game.Entities trans.Append(stmt); DB.World.CommitTransaction(trans); + + // then delete any active instances of the creature + var range = GetMap().GetCreatureBySpawnIdStore().LookupByKey(m_spawnId); + foreach (var creature in range) + creature.AddObjectToRemoveList(); } public override bool IsInvisibleDueToDespawn()