Try fix crash - upon reload you must respawn creatures to make AI apply

This commit is contained in:
Rochet2
2017-09-28 23:50:42 +03:00
parent fad53ae637
commit 8ecd5c6254

View File

@@ -119,22 +119,6 @@ void Eluna::LoadScriptPaths()
ELUNA_LOG_DEBUG("[Eluna]: Loaded %u scripts in %u ms", uint32(lua_scripts.size() + lua_extensions.size()), ElunaUtil::GetTimeDiff(oldMSTime)); ELUNA_LOG_DEBUG("[Eluna]: Loaded %u scripts in %u ms", uint32(lua_scripts.size() + lua_extensions.size()), ElunaUtil::GetTimeDiff(oldMSTime));
} }
#ifdef TRINITY
class ElunaAIUpdateWorker
{
public:
void Visit(std::unordered_map<ObjectGuid, Creature*>& creatureMap)
{
for (auto const& p : creatureMap)
if (p.second->IsInWorld())
p.second->AIM_Initialize();
}
template<class T>
void Visit(std::unordered_map<ObjectGuid, T*>&) { }
};
#endif
void Eluna::_ReloadEluna() void Eluna::_ReloadEluna()
{ {
LOCK_ELUNA; LOCK_ELUNA;
@@ -157,16 +141,6 @@ void Eluna::_ReloadEluna()
// Run scripts from laoded paths // Run scripts from laoded paths
sEluna->RunScripts(); sEluna->RunScripts();
#ifdef TRINITY
// Re initialize creature AI restoring C++ AI or applying lua AI
sMapMgr->DoForAllMaps([](Map* map)
{
ElunaAIUpdateWorker worker;
TypeContainerVisitor<ElunaAIUpdateWorker, MapStoredObjectTypesContainer> visitor(worker);
visitor.Visit(map->GetObjectsStore());
});
#endif
reload = false; reload = false;
} }