mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[11133] Implement template functions for call functor for all Map/MapPersistentState with some map id.
This commit is contained in:
parent
f4a2a582d9
commit
da1b616312
5 changed files with 76 additions and 7 deletions
|
|
@ -618,11 +618,28 @@ bool GameObject::LoadFromDB(uint32 guid, Map *map)
|
|||
return true;
|
||||
}
|
||||
|
||||
struct GameObjectRespawnDeleteWorker
|
||||
{
|
||||
explicit GameObjectRespawnDeleteWorker(uint32 guid) : i_guid(guid) {}
|
||||
|
||||
void operator() (MapPersistentState* state)
|
||||
{
|
||||
state->SaveGORespawnTime(i_guid, 0);
|
||||
}
|
||||
|
||||
uint32 i_guid;
|
||||
};
|
||||
|
||||
|
||||
void GameObject::DeleteFromDB()
|
||||
{
|
||||
// FIXME: this can be not safe in case multiply loaded instance copies
|
||||
if (MapPersistentState* save = sMapPersistentStateMgr.GetPersistentState(GetMapId(), GetInstanceId()))
|
||||
save->SaveGORespawnTime(m_DBTableGuid, 0);
|
||||
if (!m_DBTableGuid)
|
||||
{
|
||||
DEBUG_LOG("Trying to delete not saved gameobject!");
|
||||
return;
|
||||
}
|
||||
|
||||
sMapPersistentStateMgr.DoForAllStatesWithMapId(GetMapId(), GameObjectRespawnDeleteWorker(m_DBTableGuid));
|
||||
|
||||
sObjectMgr.DeleteGOData(m_DBTableGuid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue