diff --git a/pages/npc.php b/pages/npc.php index fbb9f109..e482f3fc 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -426,7 +426,10 @@ class NpcPage extends GenericPage $genSpells = $smartSpells; if ($auras = DB::World()->selectCell('SELECT auras FROM creature_template_addon WHERE entry = ?d', $this->typeId)) + { + $auras = preg_replace('/[^\d ]/', ' ', $auras); // remove erronous chars from string $genSpells = array_merge($genSpells, array_filter(explode(' ', $auras))); + } if ($genSpells) $conditions[] = ['id', $genSpells]; diff --git a/pages/spell.php b/pages/spell.php index 40857b75..d0f6263c 100644 --- a/pages/spell.php +++ b/pages/spell.php @@ -852,10 +852,8 @@ class SpellPage extends GenericPage if (!empty($ubSAI[Type::NPC])) $conditions[] = ['id', $ubSAI[Type::NPC]]; - if ($auras = DB::World()->selectCol('SELECT `entry` AS ARRAY_KEY, auras FROM creature_template_addon WHERE `auras` LIKE ?', '%'.$this->typeId.'%')) - if ($auras = array_filter($auras, function($x) { return preg_match('/\b'.$this->typeId.'\b/', $x); })) - $conditions[] = ['id', array_keys($auras)]; - + if ($auras = DB::World()->selectCol('SELECT `entry` FROM creature_template_addon WHERE `auras` REGEXP ?', '\\b'.$this->typeId.'\\b')) + $conditions[] = ['id', $auras]; $ubCreature = new CreatureList($conditions); if (!$ubCreature->error) diff --git a/setup/tools/sqlgen/spell.func.php b/setup/tools/sqlgen/spell.func.php index 43bbd8cb..c5ca1330 100644 --- a/setup/tools/sqlgen/spell.func.php +++ b/setup/tools/sqlgen/spell.func.php @@ -617,12 +617,18 @@ SqlGen::register(new class extends SetupScript SELECT cts.Spell FROM creature_template_spell cts' ); - $auras = DB::World()->selectCol('SELECT cta.auras FROM creature_template_addon cta WHERE auras <> ""'); - foreach ($auras as $a) - foreach (explode(' ', $a ) as $spell) - $world[] = $spell; + $auras = DB::World()->selectCol('SELECT `entry` AS ARRAY_KEY, cta.auras FROM creature_template_addon cta WHERE auras <> ""'); + foreach ($auras as $e => $aur) + { + // people keep trying to seperate auras with commas + $a = preg_replace('/[^\d ]/', ' ', $aur, -1, $nErrors); + if ($nErrors > 0) + CLI::write('creature_template_addon entry #' . CLI::bold($e) . ' has invalid chars in auras string "'. CLI::bold($aur).'"', CLI::LOG_WARN); - DB::Aowow()->query('UPDATE ?_spell s SET s.typeCat = -8 WHERE s.typeCat = 0 AND s.id In (?a)', $world); + $world = array_merge($world, array_filter(explode(' ', $a))); + } + + DB::Aowow()->query('UPDATE ?_spell s SET s.typeCat = -8 WHERE s.typeCat = 0 AND s.id IN (?a)', $world); /**********/