aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Maps/Map.cpp
diff options
context:
space:
mode:
authortreeston <treeston.mmoc@gmail.com>2016-01-25 01:03:56 +0100
committertreeston <treeston.mmoc@gmail.com>2016-02-10 19:35:11 +0100
commit6102a7937ddb0cf145c72fe056fc5ac4b4c3b1b5 (patch)
treee1b3d156889486829bd88a18368ab806a6149b9a /src/server/game/Maps/Map.cpp
parentcfed2d7a3ddf4f8121d3359f9888e6116fc82e62 (diff)
Maps/Instances: Implement handling of CMSG_SET_SAVED_INSTANCE_EXTEND
Diffstat (limited to 'src/server/game/Maps/Map.cpp')
-rw-r--r--src/server/game/Maps/Map.cpp34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 1560d4bdd08..ab5d3f69f58 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -3209,22 +3209,37 @@ bool InstanceMap::Reset(uint8 method)
}
else
{
+ bool doUnload = true;
if (method == INSTANCE_RESET_GLOBAL)
+ {
// set the homebind timer for players inside (1 minute)
for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
- itr->GetSource()->m_InstanceValid = false;
+ {
+ InstancePlayerBind* bind = itr->GetSource()->GetBoundInstance(GetId(), GetDifficulty());
+ if (bind && bind->extendState && bind->save->GetInstanceId() == GetInstanceId())
+ doUnload = false;
+ else
+ itr->GetSource()->m_InstanceValid = false;
+ }
+
+ if (doUnload && HasPermBoundPlayers()) // check if any unloaded players have a nonexpired save to this
+ doUnload = false;
+ }
- // the unload timer is not started
- // instead the map will unload immediately after the players have left
- m_unloadWhenEmpty = true;
- m_resetAfterUnload = true;
+ if (doUnload)
+ {
+ // the unload timer is not started
+ // instead the map will unload immediately after the players have left
+ m_unloadWhenEmpty = true;
+ m_resetAfterUnload = true;
+ }
}
}
else
{
// unloaded at next update
m_unloadTimer = MIN_UNLOAD_DELAY;
- m_resetAfterUnload = true;
+ m_resetAfterUnload = !(method == INSTANCE_RESET_GLOBAL && HasPermBoundPlayers());
}
return m_mapRefManager.isEmpty();
@@ -3305,6 +3320,13 @@ MapDifficulty const* Map::GetMapDifficulty() const
return GetMapDifficultyData(GetId(), GetDifficulty());
}
+bool InstanceMap::HasPermBoundPlayers() const
+{
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PERM_BIND_BY_INSTANCE);
+ stmt->setUInt16(0,GetInstanceId());
+ return !!CharacterDatabase.Query(stmt);
+}
+
uint32 InstanceMap::GetMaxPlayers() const
{
MapDifficulty const* mapDiff = GetMapDifficulty();