From cadb4aa0d3458e6ef7d6a6de2a79424da1f22318 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Wed, 28 Jan 2026 19:24:11 +0100 Subject: [PATCH] Icons/Fixup * reference original icon names/paths during setup * fixes #487 * amends 1e1ce29438cafd888cadf3419cef5e3713ff2c5a --- setup/sql/01-db_structure.sql | 3 ++- setup/sql/02-db_initial_data.sql | 2 +- setup/sql/updates/1769622382_01.sql | 6 ++++++ setup/tools/sqlgen/achievement.ss.php | 2 +- setup/tools/sqlgen/currencies.ss.php | 2 +- setup/tools/sqlgen/glyphproperties.ss.php | 2 +- setup/tools/sqlgen/holidays.ss.php | 4 ++-- setup/tools/sqlgen/icons.ss.php | 7 +------ setup/tools/sqlgen/items.ss.php | 2 +- setup/tools/sqlgen/pet.ss.php | 2 +- setup/tools/sqlgen/races.ss.php | 2 +- setup/tools/sqlgen/skillline.ss.php | 2 +- setup/tools/sqlgen/spell.ss.php | 6 +++--- 13 files changed, 22 insertions(+), 20 deletions(-) create mode 100644 setup/sql/updates/1769622382_01.sql diff --git a/setup/sql/01-db_structure.sql b/setup/sql/01-db_structure.sql index b9eba208..51334af4 100644 --- a/setup/sql/01-db_structure.sql +++ b/setup/sql/01-db_structure.sql @@ -1124,7 +1124,8 @@ CREATE TABLE `aowow_icons` ( `name` varchar(55) NOT NULL DEFAULT '', `name_source` varchar(55) NOT NULL DEFAULT '', PRIMARY KEY (`id`), - KEY `name` (`name`) + KEY `name` (`name`), + KEY `idx_sourcename` (`name_source`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/setup/sql/02-db_initial_data.sql b/setup/sql/02-db_initial_data.sql index bb1774fe..40fbdae8 100644 --- a/setup/sql/02-db_initial_data.sql +++ b/setup/sql/02-db_initial_data.sql @@ -71,7 +71,7 @@ UNLOCK TABLES; LOCK TABLES `aowow_dbversion` WRITE; /*!40000 ALTER TABLE `aowow_dbversion` DISABLE KEYS */; -INSERT INTO `aowow_dbversion` VALUES (1768672800,0,NULL,NULL); +INSERT INTO `aowow_dbversion` VALUES (1769622383,0,NULL,NULL); /*!40000 ALTER TABLE `aowow_dbversion` ENABLE KEYS */; UNLOCK TABLES; diff --git a/setup/sql/updates/1769622382_01.sql b/setup/sql/updates/1769622382_01.sql new file mode 100644 index 00000000..6e644656 --- /dev/null +++ b/setup/sql/updates/1769622382_01.sql @@ -0,0 +1,6 @@ +ALTER TABLE `aowow_icons` ADD KEY "idx_sourcename" (`name_source`); + +UPDATE `aowow_dbversion` SET + `sql` = CONCAT(IFNULL(`sql`, ''), ' achievement currencies glyphproperties holidays icons items pet skillline spell'), + `build` = CONCAT(IFNULL(`build`, ''), ' enchants gems glyphs talenticons') +; diff --git a/setup/tools/sqlgen/achievement.ss.php b/setup/tools/sqlgen/achievement.ss.php index fc5d54be..067229ba 100644 --- a/setup/tools/sqlgen/achievement.ss.php +++ b/setup/tools/sqlgen/achievement.ss.php @@ -64,7 +64,7 @@ CLISetup::registerSetup('sql', new class extends SetupScript FROM dbc_achievement a LEFT JOIN dbc_achievement_category ac ON ac.id = a.category LEFT JOIN dbc_spellicon si ON si.id = a.iconId - LEFT JOIN ?_icons i ON LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1)) = i.name + LEFT JOIN ?_icons i ON LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1)) = i.name_source { WHERE a.id IN (?a) }', $ids ?: DBSIMPLE_SKIP ); diff --git a/setup/tools/sqlgen/currencies.ss.php b/setup/tools/sqlgen/currencies.ss.php index cae734fc..3db2ba45 100644 --- a/setup/tools/sqlgen/currencies.ss.php +++ b/setup/tools/sqlgen/currencies.ss.php @@ -62,7 +62,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript DB::Aowow()->query( 'UPDATE ?_currencies c, ?_icons i, dbc_itemdisplayinfo idi SET c.`iconId` = i.`id` - WHERE i.`name` = LOWER(idi.`inventoryIcon1`) AND idi.`id` = ?d AND c.`itemId` = ?d', + WHERE i.`name_source` = LOWER(idi.`inventoryIcon1`) AND idi.`id` = ?d AND c.`itemId` = ?d', $iconId, $itemId ); diff --git a/setup/tools/sqlgen/glyphproperties.ss.php b/setup/tools/sqlgen/glyphproperties.ss.php index b335d600..51fdf7c1 100644 --- a/setup/tools/sqlgen/glyphproperties.ss.php +++ b/setup/tools/sqlgen/glyphproperties.ss.php @@ -23,7 +23,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript DB::Aowow()->query('TRUNCATE ?_glyphproperties'); DB::Aowow()->query('INSERT INTO ?_glyphproperties SELECT id, spellId, typeFlags, 0, iconId FROM dbc_glyphproperties'); - DB::Aowow()->query('UPDATE ?_glyphproperties gp, ?_icons ic, dbc_spellicon si SET gp.iconId = ic.id WHERE gp.iconIdBak = si.id AND ic.name = LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1))'); + DB::Aowow()->query('UPDATE ?_glyphproperties gp, ?_icons ic, dbc_spellicon si SET gp.iconId = ic.id WHERE gp.iconIdBak = si.id AND ic.name_source = LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1))'); return true; } diff --git a/setup/tools/sqlgen/holidays.ss.php b/setup/tools/sqlgen/holidays.ss.php index 03d26604..a9ebbe67 100644 --- a/setup/tools/sqlgen/holidays.ss.php +++ b/setup/tools/sqlgen/holidays.ss.php @@ -43,11 +43,11 @@ CLISetup::registerSetup("sql", new class extends SetupScript ); // set derived icons - DB::Aowow()->query('UPDATE ?_holidays h, ?_icons i SET h.`iconId` = i.`id` WHERE i.`name` LIKE CONCAT(LOWER(h.`textureString`), "%") AND h.`textureString` <> ""'); + DB::Aowow()->query('UPDATE ?_holidays h, ?_icons i SET h.`iconId` = i.`id` WHERE i.`name_source` LIKE CONCAT(LOWER(h.`textureString`), "%") AND h.`textureString` <> ""'); // set custom icons foreach (self::CUSTOM_ICONS as $hId => $iconString) - DB::Aowow()->query('UPDATE ?_holidays h SET h.`iconId` = (SELECT i.`id` FROM ?_icons i WHERE `name` = ?) WHERE `id` = ?d', $iconString, $hId); + DB::Aowow()->query('UPDATE ?_holidays h SET h.`iconId` = (SELECT i.`id` FROM ?_icons i WHERE `name_source` = ?) WHERE `id` = ?d', $iconString, $hId); return true; } diff --git a/setup/tools/sqlgen/icons.ss.php b/setup/tools/sqlgen/icons.ss.php index 6df9b124..87269d88 100644 --- a/setup/tools/sqlgen/icons.ss.php +++ b/setup/tools/sqlgen/icons.ss.php @@ -42,7 +42,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript DB::Aowow()->query('TRUNCATE ?_icons'); DB::Aowow()->query('ALTER TABLE ?_icons AUTO_INCREMENT = 1'); DB::Aowow()->query( - 'INSERT INTO ?_icons (`name`, `name_source`) SELECT x, x FROM + 'INSERT INTO ?_icons (`name`, `name_source`) SELECT REGEXP_REPLACE(x, "\\\\W", "-"), x FROM ( (SELECT LOWER(SUBSTRING_INDEX(`iconPath`, "\\\\", -1)) AS x FROM dbc_spellicon WHERE `iconPath` LIKE "%icons%") UNION (SELECT LOWER(`inventoryIcon1`) AS x FROM dbc_itemdisplayinfo WHERE `inventoryIcon1` <> "") UNION @@ -50,11 +50,6 @@ CLISetup::registerSetup("sql", new class extends SetupScript ) y GROUP BY x' ); - // fix icons with fucked up names - if ($errChars = DB::Aowow()->selectCol('SELECT `id` AS ARRAY_KEY, `name` FROM ?_icons WHERE `name` REGEXP "[^a-z0-9_-]"')) - foreach (preg_replace('/[^a-z0-9_-]/', '-', $errChars) as $id => $fixedName) - DB::Aowow()->query('UPDATE ?_icons SET `name` = ? WHERE `id` = ?d', $fixedName, $id); - // invent class icons foreach (ChrClass::cases() as $cl) DB::Aowow()->query('INSERT INTO ?_icons (`name`, `name_source`) VALUES (?, ?)', 'class_'.$cl->json(), 'class_'.$cl->json()); diff --git a/setup/tools/sqlgen/items.ss.php b/setup/tools/sqlgen/items.ss.php index 0013fc99..80dea78e 100644 --- a/setup/tools/sqlgen/items.ss.php +++ b/setup/tools/sqlgen/items.ss.php @@ -149,7 +149,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript DB::Aowow()->query('UPDATE ?_items i, dbc_itemdisplayinfo idi SET i.model = IF(idi.leftModelName = "", idi.rightModelName, idi.leftModelName) WHERE i.displayId = idi.id'); // get iconId - DB::Aowow()->query('UPDATE ?_items i, dbc_itemdisplayinfo idi, ?_icons ic SET i.iconId = ic.id WHERE i.displayId = idi.id AND LOWER(idi.inventoryIcon1) = ic.name'); + DB::Aowow()->query('UPDATE ?_items i, dbc_itemdisplayinfo idi, ?_icons ic SET i.iconId = ic.id WHERE i.displayId = idi.id AND LOWER(idi.inventoryIcon1) = ic.name_source'); // unify slots: Robes => Chest; Ranged (right) => Ranged DB::Aowow()->query('UPDATE ?_items SET slot = ?d WHERE slotbak = ?d', INVTYPE_RANGED, INVTYPE_RANGEDRIGHT); diff --git a/setup/tools/sqlgen/pet.ss.php b/setup/tools/sqlgen/pet.ss.php index 6095aced..5a6bbd32 100644 --- a/setup/tools/sqlgen/pet.ss.php +++ b/setup/tools/sqlgen/pet.ss.php @@ -43,7 +43,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript 0, 0, 0, 0, -- spell[1-4] 0, 0, 0 -- armor, damage, health FROM dbc_creaturefamily f - LEFT JOIN ?_icons ic ON ic.`name` = LOWER(SUBSTRING_INDEX(f.`iconString`, "\\\\", -1)) + LEFT JOIN ?_icons ic ON ic.`name_source` = LOWER(SUBSTRING_INDEX(f.`iconString`, "\\\\", -1)) WHERE `petTalentType` <> -1' ); diff --git a/setup/tools/sqlgen/races.ss.php b/setup/tools/sqlgen/races.ss.php index ceff4ebc..9927a146 100644 --- a/setup/tools/sqlgen/races.ss.php +++ b/setup/tools/sqlgen/races.ss.php @@ -30,7 +30,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript ); // collect iconIds - DB::Aowow()->query('UPDATE ?_races r, ?_icons i0, ?_icons i1 SET r.iconId0 = i0.id, r.iconId1 = i1.id WHERE i0.name = CONCAT("race_", LOWER(r.fileString), "_male") AND i1.name = CONCAT("race_", LOWER(r.fileString), "_female")'); + DB::Aowow()->query('UPDATE ?_races r, ?_icons i0, ?_icons i1 SET r.`iconId0` = i0.`id`, r.`iconId1` = i1.`id` WHERE i0.`name_source` = CONCAT("race_", LOWER(r.`fileString`), "_male") AND i1.`name_source` = CONCAT("race_", LOWER(r.`fileString`), "_female")'); // add classMask DB::Aowow()->query('UPDATE ?_races r JOIN (SELECT BIT_OR(1 << (`classId` - 1)) AS "classMask", `raceId` FROM dbc_charbaseinfo GROUP BY `raceId`) cbi ON cbi.`raceId` = r.id SET r.`classMask` = cbi.`classMask`'); diff --git a/setup/tools/sqlgen/skillline.ss.php b/setup/tools/sqlgen/skillline.ss.php index 9478b8b0..2c5c9200 100644 --- a/setup/tools/sqlgen/skillline.ss.php +++ b/setup/tools/sqlgen/skillline.ss.php @@ -48,7 +48,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript dbc_spellicon si SET sl.iconId = ic.id WHERE (s.effect1Id IN (25, 26, 40) OR s.effect2Id = 60) AND - ic.name = LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1)) AND + ic.name_source = LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1)) AND s.iconId = si.id AND sla.spellId = s.id AND sl.id = sla.skillLineId' diff --git a/setup/tools/sqlgen/spell.ss.php b/setup/tools/sqlgen/spell.ss.php index cbe69f31..9ecab5df 100644 --- a/setup/tools/sqlgen/spell.ss.php +++ b/setup/tools/sqlgen/spell.ss.php @@ -499,14 +499,14 @@ CLISetup::registerSetup("sql", new class extends SetupScript $itemInfo = DB::World()->select('SELECT entry AS ARRAY_KEY, displayId AS d, Quality AS q FROM item_template WHERE entry IN (?a)', $itemSpells); foreach ($itemSpells as $sId => $itemId) if (isset($itemInfo[$itemId])) - DB::Aowow()->query('UPDATE ?_spell s, ?_icons ic, dbc_itemdisplayinfo idi SET s.iconIdAlt = ic.id, s.cuFlags = s.cuFlags | ?d WHERE ic.name = LOWER(idi.inventoryIcon1) AND idi.id = ?d AND s.id = ?d', ((7 - $itemInfo[$itemId]['q']) << 8), $itemInfo[$itemId]['d'], $sId); + DB::Aowow()->query('UPDATE ?_spell s, ?_icons ic, dbc_itemdisplayinfo idi SET s.iconIdAlt = ic.id, s.cuFlags = s.cuFlags | ?d WHERE ic.name_source = LOWER(idi.inventoryIcon1) AND idi.id = ?d AND s.id = ?d', ((7 - $itemInfo[$itemId]['q']) << 8), $itemInfo[$itemId]['d'], $sId); $itemReqs = DB::World()->selectCol('SELECT entry AS ARRAY_KEY, requiredSpell FROM item_template WHERE requiredSpell NOT IN (?a)', [0, 34090, 34091]); // not riding foreach ($itemReqs AS $itemId => $req) DB::Aowow()->query('UPDATE ?_spell SET reqSpellId = ?d WHERE skillLine1 IN (?a) AND effect1CreateItemId = ?d', $req, [SKILL_BLACKSMITHING, SKILL_LEATHERWORKING, SKILL_TAILORING, SKILL_ENGINEERING], $itemId); // setting icons - DB::Aowow()->query('UPDATE ?_spell s, ?_icons ic, dbc_spellicon si SET s.iconId = ic.id WHERE s.iconIdBak = si.id AND ic.name = LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1))'); + DB::Aowow()->query('UPDATE ?_spell s, ?_icons ic, dbc_spellicon si SET s.iconId = ic.id WHERE s.iconIdBak = si.id AND ic.name_source = LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1))'); // hide internal stuff from listviews // QA*; *DND*; square brackets anything; *(NYI)*; *(TEST)* @@ -661,7 +661,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript 'SELECT s.id, s.name_loc0, s.skillLine1 as skill, ic.id as icon, s.typeCat * s.typeCat AS prio FROM ?_spell s LEFT JOIN dbc_spellicon si ON s.iconIdBak = si.id - LEFT JOIN ?_icons ic ON ic.name = LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1)) + LEFT JOIN ?_icons ic ON ic.name_source = LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1)) WHERE [WHERE] AND (s.cuFlags & ?d) = 0 AND s.typeCat IN (0, 7, -2) -- not triggered; class spells first, talents second, unk last ORDER BY prio DESC';