[11133] Implement template functions for call functor for all Map/MapPersistentState with some map id.

This commit is contained in:
VladimirMangos 2011-02-11 04:02:19 +03:00
parent f4a2a582d9
commit da1b616312
5 changed files with 76 additions and 7 deletions

View file

@ -1353,6 +1353,19 @@ bool Creature::HasInvolvedQuest(uint32 quest_id) const
return false;
}
struct CreatureRespawnDeleteWorker
{
explicit CreatureRespawnDeleteWorker(uint32 guid) : i_guid(guid) {}
void operator() (MapPersistentState* state)
{
state->SaveCreatureRespawnTime(i_guid, 0);
}
uint32 i_guid;
};
void Creature::DeleteFromDB()
{
if (!m_DBTableGuid)
@ -1361,9 +1374,7 @@ void Creature::DeleteFromDB()
return;
}
// FIXME: this not safe for another map copies can be
if (MapPersistentState* save = sMapPersistentStateMgr.GetPersistentState(GetMapId(), GetInstanceId()))
save->SaveCreatureRespawnTime(m_DBTableGuid, 0);
sMapPersistentStateMgr.DoForAllStatesWithMapId(GetMapId(), CreatureRespawnDeleteWorker(m_DBTableGuid));
sObjectMgr.DeleteCreatureData(m_DBTableGuid);