Core/Instances: Fix Instance binding
Fix players not being bound to instance if the group was disbanded before killing any boss. Fixes #437
This commit is contained in:
1 parent
9d6904f03d
commit
1f170c99ef
4 files changed
+14
-1
No files matched your search
@@ -1960,7 +1960,7 @@ void Group::ResetInstances(uint8 method, bool isRaid, Player* SendMsgTo)
|
||||
if (isEmpty || method == INSTANCE_RESET_GROUP_DISBAND || method == INSTANCE_RESET_CHANGE_DIFFICULTY)
|
||||
{
|
||||
// do not reset the instance, just unbind if others are permanently bound to it
|
||||
if (instanceSave->CanReset())
|
||||
if (isEmpty && instanceSave->CanReset())
|
||||
instanceSave->DeleteFromDB();
|
||||
else
|
||||
{
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -195,6 +195,7 @@ class InstanceSaveManager
|
||||
InstanceSave* AddInstanceSave(uint32 mapId, uint32 instanceId, Difficulty difficulty, time_t resetTime,
|
||||
bool canReset, bool load = false);
|
||||
void RemoveInstanceSave(uint32 InstanceId);
|
||||
void UnloadInstanceSave(uint32 InstanceId);
|
||||
static void DeleteInstanceFromDB(uint32 instanceid);
|
||||
|
||||
InstanceSave* GetInstanceSave(uint32 InstanceId);
|
||||
|
||||
@@ -2863,6 +2863,7 @@ void InstanceMap::RemovePlayerFromMap(Player* player, bool remove)
|
||||
Map::RemovePlayerFromMap(player, remove);
|
||||
// for normal instances schedule the reset after all players have left
|
||||
SetResetSchedule(true);
|
||||
sInstanceSaveMgr->UnloadInstanceSave(GetInstanceId());
|
||||
}
|
||||
|
||||
void InstanceMap::CreateInstanceData(bool load)
|
||||
|
||||
Reference in new issue
Block a user