Core/Instance: add new hook & method

(cherry picked from commit 953b05459a)
This commit is contained in:
ccrs
2019-06-29 19:24:05 +02:00
committed by Shauren
parent fc6dc06513
commit 6a63200e40
3 changed files with 40 additions and 1 deletions

View File

@@ -4058,12 +4058,19 @@ void InstanceMap::Update(uint32 t_diff)
void InstanceMap::RemovePlayerFromMap(Player* player, bool remove)
{
TC_LOG_DEBUG("maps", "MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to another map", player->GetName().c_str(), GetInstanceId(), GetMapName());
//if last player set unload timer
if (i_data)
i_data->OnPlayerLeave(player);
// if last player set unload timer
if (!m_unloadTimer && m_mapRefManager.getSize() == 1)
m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld->getIntConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY);
if (i_scenario)
i_scenario->OnPlayerExit(player);
Map::RemovePlayerFromMap(player, remove);
// for normal instances schedule the reset after all players have left
SetResetSchedule(true);
sInstanceSaveMgr->UnloadInstanceSave(GetInstanceId());