Entities/Unit: Nuke Map::ForceRespawn from orbit, with the following implications:

- .npc respawn no longer causes stupid things to happen (Fixes #23014)
- ::DeleteFromDB methods on Creature and GameObject rewritten to be as sensible as such a colossally stupid method can ever be. They're static now.
- .npc delete and .gobj delete ported to new argument handling, and rewritten as per above. They can no longer crash the server when used in instances, too. Yay for that.
- Adjusted various dusty cobwebbed hacks around the core (why does waypoint visualization use permanent spawns *shudder*) to still work too.
This commit is contained in:
Treeston authored and Ovahlord committed 2019-08-18 12:12:09 +02:00
1 parent 8a1828aa43
commit f9184f026b
12 files changed
+150 -182

No files matched your search

+25 -30
View File
@@ -364,42 +364,37 @@ public:
if (!id)
return false;
ObjectGuid::LowType guidLow = atoul(id);
if (!guidLow)
ObjectGuid::LowType spawnId = atoul(id);
if (!spawnId)
return false;
Player const* const player = handler->GetSession()->GetPlayer();
// force respawn to make sure we find something
player->GetMap()->ForceRespawn(SPAWN_TYPE_GAMEOBJECT, guidLow);
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
if (GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(spawnId))
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
Player const* const player = handler->GetSession()->GetPlayer();
if (ObjectGuid ownerGuid = object->GetOwnerGUID())
{
Unit* owner = ObjectAccessor::GetUnit(*player, ownerGuid);
if (!owner || !ownerGuid.IsPlayer())
{
handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, ownerGuid.GetCounter(), spawnId);
handler->SetSentErrorMessage(true);
return false;
}
owner->RemoveGameObject(object, false);
}
}
if (GameObject::DeleteFromDB(spawnId))
{
handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, spawnId);
return true;
}
else
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, spawnId);
handler->SetSentErrorMessage(true);
return false;
}
ObjectGuid ownerGuid = object->GetOwnerGUID();
if (ownerGuid)
{
Unit* owner = ObjectAccessor::GetUnit(*player, ownerGuid);
if (!owner || !ownerGuid.IsPlayer())
{
handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, ownerGuid.GetCounter(), guidLow);
handler->SetSentErrorMessage(true);
return false;
}
owner->RemoveGameObject(object, false);
}
object->SetRespawnTime(0); // not save respawn time
object->Delete();
object->DeleteFromDB();
handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, object->GetSpawnId());
return true;
}
//turn selected object