aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2017-08-21 17:07:53 +0200
committerShauren <shauren.trinity@gmail.com>2020-08-23 14:47:48 +0200
commit2924ae08038314e3c935a132cc56a4135d9f103c (patch)
treec09325e2d7ecc913d53221e014c7a6008ed2aece /src
parent88a61fa9d675f8adcd76085f935bc7d7b5d3bb6d (diff)
Scripts/Commands: .npc delete and .gobj delete now work while the specified guid is despawned. Fixes #20145.
(cherry picked from commit cac99beffd66218c6cbdd873d4a90461d04b25c4)
Diffstat (limited to 'src')
-rw-r--r--src/server/scripts/Commands/cs_gobject.cpp5
-rw-r--r--src/server/scripts/Commands/cs_npc.cpp3
2 files changed, 7 insertions, 1 deletions
diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp
index 3160e659082..ec5eac82672 100644
--- a/src/server/scripts/Commands/cs_gobject.cpp
+++ b/src/server/scripts/Commands/cs_gobject.cpp
@@ -347,6 +347,9 @@ public:
if (!guidLow)
return false;
+ Player const* const player = handler->GetSession()->GetPlayer();
+ // force respawn to make sure we find something
+ player->GetMap()->RemoveRespawnTime(SPAWN_TYPE_GAMEOBJECT, guidLow, true);
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
@@ -358,7 +361,7 @@ public:
ObjectGuid ownerGuid = object->GetOwnerGUID();
if (!ownerGuid.IsEmpty())
{
- Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(), ownerGuid);
+ Unit* owner = ObjectAccessor::GetUnit(*player, ownerGuid);
if (!owner || !ownerGuid.IsPlayer())
{
handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, ownerGuid.ToString().c_str(), object->GetGUID().ToString().c_str());
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp
index c770d499463..e420bdfbf16 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -603,6 +603,9 @@ public:
ObjectGuid::LowType lowguid = atoull(cId);
if (!lowguid)
return false;
+ // force respawn to make sure we find something
+ handler->GetSession()->GetPlayer()->GetMap()->RemoveRespawnTime(SPAWN_TYPE_CREATURE, lowguid, true);
+ // then try to find it
creature = handler->GetCreatureFromPlayerMapByDbGuid(lowguid);
}
else