Maps/Instances: Implement handling of CMSG_SET_SAVED_INSTANCE_EXTEND

This commit is contained in:
treeston committed 2016-02-10 19:35:11 +01:00
1 parent cfed2d7a3d
commit 6102a7937d
17 files changed
+232 -77

No files matched your search

+28 -6
View File
@@ -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;
}
// 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 && HasPermBoundPlayers()) // check if any unloaded players have a nonexpired save to this
doUnload = false;
}
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();