[11123] Move respawn data to InstanceSave.

This make prev commit more useful.
In future InstanceSave also planned store local pools state.
This commit is contained in:
VladimirMangos 2011-02-08 06:30:44 +03:00
parent 852c4ddf32
commit 6cfa64db97
13 changed files with 258 additions and 191 deletions

View file

@ -32,6 +32,7 @@
#include "GridNotifiersImpl.h"
#include "CellImpl.h"
#include "InstanceData.h"
#include "InstanceSaveMgr.h"
#include "BattleGround.h"
#include "BattleGroundAV.h"
#include "Util.h"
@ -596,13 +597,14 @@ bool GameObject::LoadFromDB(uint32 guid, Map *map)
{
m_spawnedByDefault = true;
m_respawnDelayTime = data->spawntimesecs;
m_respawnTime = sObjectMgr.GetGORespawnTime(m_DBTableGuid, map->GetInstanceId());
m_respawnTime = map->GetInstanceSave()->GetGORespawnTime(m_DBTableGuid);
// ready to respawn
if(m_respawnTime && m_respawnTime <= time(NULL))
if (m_respawnTime && m_respawnTime <= time(NULL))
{
m_respawnTime = 0;
sObjectMgr.SaveGORespawnTime(m_DBTableGuid,GetInstanceId(),0);
map->GetInstanceSave()->SaveGORespawnTime(m_DBTableGuid, 0);
}
}
else
@ -618,7 +620,10 @@ bool GameObject::LoadFromDB(uint32 guid, Map *map)
void GameObject::DeleteFromDB()
{
sObjectMgr.SaveGORespawnTime(m_DBTableGuid,GetInstanceId(),0);
// FIXME: this can be not safe in case multiply loaded instance copies
if (InstanceSave* save = sInstanceSaveMgr.GetInstanceSave(GetMapId(), GetInstanceId()))
save->SaveGORespawnTime(m_DBTableGuid, 0);
sObjectMgr.DeleteGOData(m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM game_event_gameobject WHERE guid = '%u'", m_DBTableGuid);
@ -671,7 +676,7 @@ Unit* GameObject::GetOwner() const
void GameObject::SaveRespawnTime()
{
if(m_respawnTime > time(NULL) && m_spawnedByDefault)
sObjectMgr.SaveGORespawnTime(m_DBTableGuid,GetInstanceId(),m_respawnTime);
GetMap()->GetInstanceSave()->SaveGORespawnTime(m_DBTableGuid, m_respawnTime);
}
bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const
@ -714,7 +719,7 @@ void GameObject::Respawn()
if(m_spawnedByDefault && m_respawnTime > 0)
{
m_respawnTime = time(NULL);
sObjectMgr.SaveGORespawnTime(m_DBTableGuid,GetInstanceId(),0);
GetMap()->GetInstanceSave()->SaveGORespawnTime(m_DBTableGuid, 0);
}
}