aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Instances/InstanceSaveMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Instances/InstanceSaveMgr.cpp')
-rw-r--r--src/server/game/Instances/InstanceSaveMgr.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp
index ee962621048..e37e6847bdd 100644
--- a/src/server/game/Instances/InstanceSaveMgr.cpp
+++ b/src/server/game/Instances/InstanceSaveMgr.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
@@ -161,6 +161,12 @@ void InstanceSaveManager::RemoveInstanceSave(uint32 InstanceId)
}
}
+void InstanceSaveManager::UnloadInstanceSave(uint32 InstanceId)
+{
+ if (InstanceSave* save = GetInstanceSave(InstanceId))
+ save->UnloadIfEmpty();
+}
+
InstanceSave::InstanceSave(uint16 MapId, uint32 InstanceId, Difficulty difficulty, time_t resetTime, bool canReset)
: m_resetTime(resetTime), m_instanceid(InstanceId), m_mapid(MapId),
m_difficulty(difficulty), m_canReset(canReset), m_toDelete(false) { }
@@ -232,6 +238,11 @@ bool InstanceSave::UnloadIfEmpty()
{
if (m_playerList.empty() && m_groupList.empty())
{
+ // don't remove the save if there are still players inside the map
+ if (Map* map = sMapMgr->FindMap(GetMapId(), GetInstanceId()))
+ if (map->HavePlayers())
+ return true;
+
if (!sInstanceSaveMgr->lock_instLists)
sInstanceSaveMgr->RemoveInstanceSave(GetInstanceId());