Spells/Misc

* try to handle bogus data from creature_template_addon.auras
This commit is contained in:
Sarjuuk
2024-01-31 22:17:25 +01:00
parent a14b5e2be1
commit 85e8175338
3 changed files with 16 additions and 9 deletions

View File

@@ -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];

View File

@@ -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)

View File

@@ -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);
/**********/