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:
1 parent
8a1828aa43
commit
f9184f026b
12 files changed
+150
-182
No files matched your search
@@ -31,6 +31,8 @@
|
||||
#include "GroupMgr.h"
|
||||
#include "Log.h"
|
||||
#include "LootMgr.h"
|
||||
#include "Map.h"
|
||||
#include "MapManager.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "OutdoorPvPMgr.h"
|
||||
@@ -985,26 +987,45 @@ bool GameObject::LoadFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap
|
||||
return true;
|
||||
}
|
||||
|
||||
void GameObject::DeleteFromDB()
|
||||
/*static*/ bool GameObject::DeleteFromDB(ObjectGuid::LowType spawnId)
|
||||
{
|
||||
GetMap()->RemoveRespawnTime(SPAWN_TYPE_GAMEOBJECT, m_spawnId);
|
||||
sObjectMgr->DeleteGameObjectData(m_spawnId);
|
||||
GameObjectData const* data = sObjectMgr->GetGameObjectData(spawnId);
|
||||
if (!data)
|
||||
return false;
|
||||
|
||||
SQLTransaction trans = WorldDatabase.BeginTransaction();
|
||||
|
||||
sMapMgr->DoForAllMapsWithMapId(data->spawnPoint.GetMapId(),
|
||||
[spawnId, trans](Map* map) -> void
|
||||
{
|
||||
// despawn all active objects, and remove their respawns
|
||||
std::vector<GameObject*> toUnload;
|
||||
for (auto const& pair : Trinity::Containers::MapEqualRange(map->GetGameObjectBySpawnIdStore(), spawnId))
|
||||
toUnload.push_back(pair.second);
|
||||
for (GameObject* obj : toUnload)
|
||||
map->AddObjectToRemoveList(obj);
|
||||
map->RemoveRespawnTime(SPAWN_TYPE_GAMEOBJECT, spawnId, false, trans);
|
||||
}
|
||||
);
|
||||
|
||||
// delete data from memory
|
||||
sObjectMgr->DeleteGameObjectData(spawnId);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAMEOBJECT);
|
||||
stmt->setUInt32(0, spawnId);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_SPAWNGROUP_MEMBER);
|
||||
stmt->setUInt8(0, uint8(SPAWN_TYPE_GAMEOBJECT));
|
||||
stmt->setUInt32(1, m_spawnId);
|
||||
stmt->setUInt32(1, spawnId);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_EVENT_GAMEOBJECT);
|
||||
stmt->setUInt32(0, m_spawnId);
|
||||
stmt->setUInt32(0, spawnId);
|
||||
trans->Append(stmt);
|
||||
|
||||
WorldDatabase.CommitTransaction(trans);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
Reference in new issue
Block a user