aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Instances/InstanceScript.cpp29
-rw-r--r--src/server/game/Instances/InstanceScript.h3
-rw-r--r--src/server/game/Maps/Map.cpp9
3 files changed, 40 insertions, 1 deletions
diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp
index 0d8b75ddbf9..cbfa17dbf48 100644
--- a/src/server/game/Instances/InstanceScript.cpp
+++ b/src/server/game/Instances/InstanceScript.cpp
@@ -681,6 +681,35 @@ void InstanceScript::DoRemoveAurasDueToSpellOnPlayers(uint32 spell, bool include
}
}
+void InstanceScript::DoRemoveAurasDueToSpellOnPlayer(Player* player, uint32 spell, bool includePets /*= false*/, bool includeControlled /*= false*/)
+{
+ if (!player)
+ return;
+
+ player->RemoveAurasDueToSpell(spell);
+
+ if (!includePets)
+ return;
+
+ for (uint8 itr2 = 0; itr2 < MAX_SUMMON_SLOT; ++itr2)
+ {
+ ObjectGuid summonGUID = player->m_SummonSlot[itr2];
+ if (!summonGUID.IsEmpty())
+ if (Creature* summon = instance->GetCreature(summonGUID))
+ summon->RemoveAurasDueToSpell(spell);
+ }
+
+ if (!includeControlled)
+ return;
+
+ for (auto itr2 = player->m_Controlled.begin(); itr2 != player->m_Controlled.end(); ++itr2)
+ {
+ if (Unit* controlled = *itr2)
+ if (controlled->IsInWorld() && controlled->GetTypeId() == TYPEID_UNIT)
+ controlled->RemoveAurasDueToSpell(spell);
+ }
+}
+
void InstanceScript::DoCastSpellOnPlayers(uint32 spell, bool includePets /*= false*/, bool includeControlled /*= false*/)
{
Map::PlayerList const& playerList = instance->GetPlayers();
diff --git a/src/server/game/Instances/InstanceScript.h b/src/server/game/Instances/InstanceScript.h
index e845a56bd94..20723a6e723 100644
--- a/src/server/game/Instances/InstanceScript.h
+++ b/src/server/game/Instances/InstanceScript.h
@@ -200,6 +200,8 @@ class TC_GAME_API InstanceScript : public ZoneScript
// Called when a player successfully enters the instance.
virtual void OnPlayerEnter(Player* /*player*/) { }
+ // Called when a player successfully leaves the instance.
+ virtual void OnPlayerLeave(Player* /*player*/) { }
// Handle open / close objects
// * use HandleGameObject(0, boolen, GO); in OnObjectCreate in instance scripts
@@ -228,6 +230,7 @@ class TC_GAME_API InstanceScript : public ZoneScript
// Remove Auras due to Spell on all players in instance
void DoRemoveAurasDueToSpellOnPlayers(uint32 spell, bool includePets = false, bool includeControlled = false);
+ void DoRemoveAurasDueToSpellOnPlayer(Player* player, uint32 spell, bool includePets = false, bool includeControlled = false);
// Cast spell on all players in instance
void DoCastSpellOnPlayers(uint32 spell, bool includePets = false, bool includeControlled = false);
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 8b72da34de0..f0504dc4252 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -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());