From 8dc19ac21d1d8a33a53fee873e7d19a153ea8a67 Mon Sep 17 00:00:00 2001 From: Phatcat Date: Sun, 11 Sep 2016 19:53:33 +0200 Subject: [PATCH] Remove db error again and simplify a bit --- src/game/AI/CreatureAISelector.cpp | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/game/AI/CreatureAISelector.cpp b/src/game/AI/CreatureAISelector.cpp index eb4b04da4a3..4bd79880f9f 100644 --- a/src/game/AI/CreatureAISelector.cpp +++ b/src/game/AI/CreatureAISelector.cpp @@ -34,15 +34,11 @@ namespace FactorySelector { CreatureAI* selectAI(Creature* creature) { - CreatureAI* scriptedAI = sScriptMgr.GetCreatureAI(creature); - if (scriptedAI) + if (CreatureAI* scriptedAI = sScriptMgr.GetCreatureAI(creature)) { // charmed creature may have some script even if its not supposed to be that way (ex: Eye of Acherus) - if (creature->isCharmed()) - return scriptedAI; - // Allow scripting AI for normal creatures and not controlled pets (guardians and mini-pets) - if (!creature->IsPet() || !static_cast(creature)->isControlled()) + if (creature->isCharmed() || !(creature->IsPet() && static_cast(creature)->isControlled())) return scriptedAI; } @@ -52,27 +48,21 @@ namespace FactorySelector std::string ainame = creature->GetAIName(); - // select by NPC flags _first_ - otherwise EventAI might be choosen for pets/totems + // select by NPC flags if (creature->IsPet()) { - if (((Pet*)creature)->isControlled()) + if (static_cast(creature)->isControlled()) ai_factory = ai_registry.GetRegistryItem("PetAI"); - else - { + else // For guardians and creature pets in general ai_factory = ai_registry.GetRegistryItem("GuardianAI"); - if (!ainame.empty() && (ai_registry.GetRegistryItem(ainame.c_str()) != ai_registry.GetRegistryItem("GuardianAI"))) - sLog.outErrorDb("FactorySelector: creature pet / guardian not up-to-date on entry: %u ! it shouldn't have %s - GuardianAI will be used.", creature->GetEntry(), ainame.c_str()); - } } else if (creature->IsTotem()) ai_factory = ai_registry.GetRegistryItem("TotemAI"); - // select by script name - else if (!ainame.empty()) + else if (!ainame.empty()) // select by script name ai_factory = ai_registry.GetRegistryItem(ainame.c_str()); else if (creature->IsGuard()) ai_factory = ai_registry.GetRegistryItem("GuardAI"); - // select by permit check - else + else // select by permit check { int best_val = PERMIT_BASE_NO; typedef CreatureAIRegistry::RegistryMapType RMT;