Setup/Fixups

* sanity check slot / invtype realtion on setup (and hide offenders)
 * hide internal/unused items by name part
 * always truncate table to get rid of old data
 * fixing one->many relation revealed by replacing REPLACE with INSERT in creature setup
This commit is contained in:
Sarjuuk
2023-04-23 19:45:44 +02:00
parent 1130581152
commit e916deaafc
4 changed files with 30 additions and 7 deletions

View File

@@ -19,7 +19,7 @@ SqlGen::register(new class extends SetupScript
$baseQuery = '
SELECT
ct.entry,
IF(ie.entry IS NULL, 0, ?d) AS cuFlags, -- cuFlags
IF(ie.creditEntry IS NULL, 0, ?d) AS cuFlags, -- cuFlags
difficulty_entry_1, difficulty_entry_2, difficulty_entry_3,
KillCredit1, KillCredit2,
modelid1, modelid2, modelid3, modelid4,
@@ -91,7 +91,7 @@ SqlGen::register(new class extends SetupScript
LEFT JOIN
creature_template_locale ctl8 ON ct.entry = ctl8.entry AND ctl8.`locale` = "ruRU"
LEFT JOIN
instance_encounters ie ON ie.creditEntry = ct.entry AND ie.creditType = 0
(SELECT creditEntry FROM instance_encounters WHERE creditType = 0 GROUP BY creditEntry) ie ON ie.creditEntry = ct.entry
LEFT JOIN
creature_template_spell cts0 ON ct.entry = cts0.CreatureID AND cts0.Index = 0
LEFT JOIN
@@ -157,12 +157,13 @@ SqlGen::register(new class extends SetupScript
c.humanoid = IF(cdie.id IS NULL, 0, 1)';
$i = 0;
DB::Aowow()->query('TRUNCATE ?_creature');
while ($npcs = DB::World()->select($baseQuery, NPC_CU_INSTANCE_BOSS, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize * $i, SqlGen::$sqlBatchSize))
{
CLI::write(' * batch #' . ++$i . ' (' . count($npcs) . ')');
foreach ($npcs as $npc)
DB::Aowow()->query('REPLACE INTO ?_creature VALUES (?a)', array_values($npc));
DB::Aowow()->query('INSERT INTO ?_creature VALUES (?a)', array_values($npc));
}
// apply "textureString", "modelId" and "iconSring"

View File

@@ -141,15 +141,15 @@ SqlGen::register(new class extends SetupScript
?d, ?d';
$i = 0;
DB::Aowow()->query('TRUNCATE ?_items');
while ($items = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize * $i, SqlGen::$sqlBatchSize))
{
CLI::write(' * batch #' . ++$i . ' (' . count($items) . ')');
foreach ($items as $item)
DB::Aowow()->query('REPLACE INTO ?_items VALUES (?a)', array_values($item));
DB::Aowow()->query('INSERT INTO ?_items VALUES (?a)', array_values($item));
}
// merge with gemProperties
DB::Aowow()->query('UPDATE ?_items i, dbc_gemproperties gp SET i.gemEnchantmentId = gp.enchantmentId, i.gemColorMask = gp.colorMask WHERE i.gemColorMask = gp.id');
@@ -238,6 +238,26 @@ SqlGen::register(new class extends SetupScript
WHERE
durability > 0 AND ((classBak = 4 AND subClassBak IN (1, 2, 3, 4, 6)) OR (classBak = 2 AND subClassBak <> 9))');
// hide some nonsense
DB::Aowow()->query('UPDATE ?_items SET `cuFlags` = `cuFlags` | ?d WHERE
`name_loc0` LIKE "Monster - %" OR `name_loc0` LIKE "Creature - %" OR
`name_loc0` LIKE "%[PH]%" OR `name_loc0` LIKE "% PH %" OR
`name_loc0` LIKE "%(new)%" OR `name_loc0` LIKE "%(old)%" OR
`name_loc0` LIKE "%deprecated%" OR `name_loc0` LIKE "%obsolete%" OR
`name_loc0` LIKE "%1H%" OR `name_loc0` LIKE "%QA%" OR
`name_loc0` LIKE "%(test)%" OR `name_loc0` LIKE "test %" OR (`name_loc0` LIKE "% test %" AND `class` > 0)',
CUSTOM_EXCLUDE_FOR_LISTVIEW
);
// sanity check weapon class and invtype relation
$checks = array(
[[INVTYPE_WEAPONOFFHAND, INVTYPE_WEAPONMAINHAND, INVTYPE_WEAPON], [0, 4, 7, 13, 14, 15]],
[[INVTYPE_2HWEAPON], [1, 5, 6, 8, 10, 14, 20]],
[[INVTYPE_RANGED, INVTYPE_RANGEDRIGHT], [2, 3, 16, 18, 14, 19]]
);
foreach ($checks as [$slots, $subclasses])
DB::Aowow()->query('UPDATE ?_items SET `cuFlags` = `cuFlags` | ?d WHERE `class`= ?d AND `slotBak` IN (?a) AND `subClass` NOT IN (?a)', CUSTOM_EXCLUDE_FOR_LISTVIEW, ITEM_CLASS_WEAPON, $slots, $subclasses);
$this->reapplyCCFlags('items', Type::ITEM);
return true;

View File

@@ -104,12 +104,13 @@ SqlGen::register(new class extends SetupScript
}';
$i = 0;
DB::Aowow()->query('TRUNCATE ?_objects');
while ($objects = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize * $i, SqlGen::$sqlBatchSize))
{
CLI::write(' * batch #' . ++$i . ' (' . count($objects) . ')');
foreach ($objects as $object)
DB::Aowow()->query('REPLACE INTO ?_objects VALUES (?a)', array_values($object));
DB::Aowow()->query('INSERT INTO ?_objects VALUES (?a)', array_values($object));
}
// apply typeCat and reqSkill depending on locks

View File

@@ -171,12 +171,13 @@ SqlGen::register(new class extends SetupScript
$i = 0;
DB::Aowow()->query('TRUNCATE ?_quests');
while ($quests = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize * $i, SqlGen::$sqlBatchSize))
{
CLI::write(' * batch #' . ++$i . ' (' . count($quests) . ')');
foreach ($quests as $quest)
DB::Aowow()->query('REPLACE INTO ?_quests VALUES (?a)', array_values($quest));
DB::Aowow()->query('INSERT INTO ?_quests VALUES (?a)', array_values($quest));
}
/*