[10103] More cleanups in InstanceSave

* Use single function for erase element from save list.
* Make lock bool checks class local (it need be replaced by normal lock object in future)
* Remove redundent now friend class declarations.
This commit is contained in:
VladimirMangos 2010-06-24 07:11:51 +04:00
parent f244e68c59
commit 593f1e81b9
4 changed files with 9 additions and 8 deletions

View file

@ -115,8 +115,7 @@ bool InstanceSave::UnloadIfEmpty()
{
if(m_playerList.empty() && m_groupList.empty())
{
if(!sInstanceSaveMgr.lock_instLists)
sInstanceSaveMgr.RemoveInstanceSave(GetInstanceId());
sInstanceSaveMgr.RemoveInstanceSave(GetInstanceId());
return false;
}
else
@ -419,14 +418,17 @@ void InstanceSaveManager::DeleteInstanceFromDB(uint32 instanceid)
void InstanceSaveManager::RemoveInstanceSave(uint32 InstanceId)
{
if (lock_instLists)
return;
InstanceSaveHashMap::iterator itr = m_instanceSaveById.find( InstanceId );
if(itr != m_instanceSaveById.end())
{
// save the resettime for normal instances only when they get unloaded
if(time_t resettime = itr->second->GetResetTimeForDB())
CharacterDatabase.PExecute("UPDATE instance SET resettime = '"UI64FMTD"' WHERE id = '%u'", (uint64)resettime, InstanceId);
delete itr->second;
m_instanceSaveById.erase(itr);
_ResetSave(itr);
}
}