mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
chore(Debug/Scripting): improve debug errors during the unloading scripts (#19643)
* chore(Debug/Scripting): improve debug errors during script unloading * add the script name to increase debug informations and ensure to derefence script pointers
This commit is contained in:
@@ -30,9 +30,24 @@ namespace
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
inline void SCR_CLEAR()
|
inline void SCR_CLEAR()
|
||||||
{
|
{
|
||||||
for (auto const& [scriptID, script] : ScriptRegistry<T>::ScriptPointerList)
|
for (auto& [scriptID, script] : ScriptRegistry<T>::ScriptPointerList)
|
||||||
{
|
{
|
||||||
delete script;
|
try
|
||||||
|
{
|
||||||
|
if(script)
|
||||||
|
{
|
||||||
|
delete script;
|
||||||
|
script = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
LOG_ERROR("scripts.unloading", "Failed to unload script {} with ID: {}. Error: {}", script->GetName(), scriptID, e.what());
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
LOG_ERROR("scripts.unloading", "Failed to unload script {} with ID: {}. Unknown error occurred.", script->GetName(), scriptID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptRegistry<T>::ScriptPointerList.clear();
|
ScriptRegistry<T>::ScriptPointerList.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user