From 9d19aaf6a2bc81576fa1336e5bb1146be8476072 Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Sat, 18 Jun 2022 14:46:33 +0200 Subject: [PATCH] fix(Core): Crashfix. (#12092) --- src/server/scripts/Commands/cs_gobject.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index 7fbf37780..b538494a0 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -496,7 +496,7 @@ public: } //show info of gameobject - static bool HandleGameObjectInfoCommand(ChatHandler* handler, Optional> objectId) + static bool HandleGameObjectInfoCommand(ChatHandler* handler, Optional isGuid, Variant, Hyperlink, uint32> data) { uint32 entry = 0; uint32 type = 0; @@ -505,17 +505,24 @@ public: uint32 lootId = 0; GameObject* gameObject = nullptr; - if (!objectId) + ObjectGuid::LowType spawnId = 0; + if (isGuid || data.holds_alternative>()) { - if (WorldObject* object = handler->getSelectedObject()) + spawnId = *data; + GameObjectData const* spawnData = sObjectMgr->GetGOData(spawnId); + if (!spawnData) { - entry = object->GetEntry(); - if (object->GetTypeId() == TYPEID_GAMEOBJECT) - gameObject = object->ToGameObject(); + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, spawnId); + handler->SetSentErrorMessage(true); + return false; } + entry = spawnData->id; + gameObject = handler->GetObjectFromPlayerMapByDbGuid(spawnId); } else - entry = static_cast(objectId->get()); + { + entry = *data; + } GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry); if (!gameObjectInfo)