feat(Core/Scripting): Added new hook: OnInstanceIdRemoved. (#14670)
Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Co-authored-by: 55Honey <71938210+55Honey@users.noreply.github.com>
This commit is contained in:
@@ -137,6 +137,8 @@ bool InstanceSaveMgr::DeleteInstanceSaveIfNeeded(InstanceSave* save, bool skipMa
|
|||||||
// clear respawn times (if map is loaded do it just to be sure, if already unloaded it won't do it by itself)
|
// clear respawn times (if map is loaded do it just to be sure, if already unloaded it won't do it by itself)
|
||||||
Map::DeleteRespawnTimesInDB(save->GetMapId(), save->GetInstanceId());
|
Map::DeleteRespawnTimesInDB(save->GetMapId(), save->GetInstanceId());
|
||||||
|
|
||||||
|
sScriptMgr->OnInstanceIdRemoved(save->GetInstanceId());
|
||||||
|
|
||||||
if (deleteSave)
|
if (deleteSave)
|
||||||
{
|
{
|
||||||
delete save;
|
delete save;
|
||||||
@@ -529,6 +531,8 @@ void InstanceSaveMgr::_ResetSave(InstanceSaveHashMap::iterator& itr)
|
|||||||
if (!sMapMgr->FindMap(itr->second->GetMapId(), itr->second->GetInstanceId()))
|
if (!sMapMgr->FindMap(itr->second->GetMapId(), itr->second->GetInstanceId()))
|
||||||
Map::DeleteRespawnTimesInDB(itr->second->GetMapId(), itr->second->GetInstanceId());
|
Map::DeleteRespawnTimesInDB(itr->second->GetMapId(), itr->second->GetInstanceId());
|
||||||
|
|
||||||
|
sScriptMgr->OnInstanceIdRemoved(itr->second->GetInstanceId());
|
||||||
|
|
||||||
delete itr->second;
|
delete itr->second;
|
||||||
m_instanceSaveById.erase(itr);
|
m_instanceSaveById.erase(itr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,3 +176,16 @@ bool ScriptMgr::OnAllowedForPlayerLootCheck(Player const* player, ObjectGuid sou
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Called when an instance Id is deleted, usually because it expired or no players are bound to it anymore.
|
||||||
|
*
|
||||||
|
* @param instanceId The unique id of the instance
|
||||||
|
*/
|
||||||
|
void ScriptMgr::OnInstanceIdRemoved(uint32 instanceId)
|
||||||
|
{
|
||||||
|
ExecuteScript<GlobalScript>([&](GlobalScript* script)
|
||||||
|
{
|
||||||
|
script->OnInstanceIdRemoved(instanceId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -1594,6 +1594,9 @@ public:
|
|||||||
|
|
||||||
// Called when checking if a player can see the creature loot
|
// Called when checking if a player can see the creature loot
|
||||||
virtual bool OnAllowedForPlayerLootCheck(Player const* /*player*/, ObjectGuid /*source*/) { return false; };
|
virtual bool OnAllowedForPlayerLootCheck(Player const* /*player*/, ObjectGuid /*source*/) { return false; };
|
||||||
|
|
||||||
|
// Called when instance id is removed from database (e.g. instance reset)
|
||||||
|
virtual void OnInstanceIdRemoved(uint32 /*instanceId*/) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class BGScript : public ScriptObject
|
class BGScript : public ScriptObject
|
||||||
@@ -2427,6 +2430,7 @@ public: /* GlobalScript */
|
|||||||
bool OnSpellHealingBonusTakenNegativeModifiers(Unit const* target, Unit const* caster, SpellInfo const* spellInfo, float& val);
|
bool OnSpellHealingBonusTakenNegativeModifiers(Unit const* target, Unit const* caster, SpellInfo const* spellInfo, float& val);
|
||||||
void OnLoadSpellCustomAttr(SpellInfo* spell);
|
void OnLoadSpellCustomAttr(SpellInfo* spell);
|
||||||
bool OnAllowedForPlayerLootCheck(Player const* player, ObjectGuid source);
|
bool OnAllowedForPlayerLootCheck(Player const* player, ObjectGuid source);
|
||||||
|
void OnInstanceIdRemoved(uint32 instanceId);
|
||||||
|
|
||||||
public: /* Scheduled scripts */
|
public: /* Scheduled scripts */
|
||||||
uint32 IncreaseScheduledScriptsCount() { return ++_scheduledScripts; }
|
uint32 IncreaseScheduledScriptsCount() { return ++_scheduledScripts; }
|
||||||
|
|||||||
Reference in New Issue
Block a user