From 73c1118601f7a58de9c681bc56f521cbc99cb20f Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Thu, 3 Mar 2022 18:55:04 +0100 Subject: [PATCH] Setup/Update * reapply flags for community content when rebuilding DB fixes associated filters and meta page 'missing screenshots' --- setup/tools/setupScript.class.php | 15 +++++++++++++++ setup/tools/sqlgen/achievement.func.php | 2 ++ setup/tools/sqlgen/areatrigger.func.php | 2 ++ setup/tools/sqlgen/classes.func.php | 2 ++ setup/tools/sqlgen/creature.func.php | 2 ++ setup/tools/sqlgen/currencies.func.php | 2 ++ setup/tools/sqlgen/emotes.func.php | 2 ++ setup/tools/sqlgen/events.func.php | 2 ++ setup/tools/sqlgen/factions.func.php | 2 ++ setup/tools/sqlgen/icons.func.php | 2 ++ setup/tools/sqlgen/itemenchantment.func.php | 2 ++ setup/tools/sqlgen/items.func.php | 2 ++ setup/tools/sqlgen/itemset.func.php | 2 ++ setup/tools/sqlgen/objects.func.php | 2 ++ setup/tools/sqlgen/pet.func.php | 2 ++ setup/tools/sqlgen/quests.func.php | 2 ++ setup/tools/sqlgen/races.func.php | 2 ++ setup/tools/sqlgen/skillline.func.php | 2 ++ setup/tools/sqlgen/sounds.func.php | 2 ++ setup/tools/sqlgen/spell.func.php | 2 ++ setup/tools/sqlgen/titles.func.php | 2 ++ setup/tools/sqlgen/zones.func.php | 2 ++ 22 files changed, 57 insertions(+) diff --git a/setup/tools/setupScript.class.php b/setup/tools/setupScript.class.php index 80b22870..f55cf024 100644 --- a/setup/tools/setupScript.class.php +++ b/setup/tools/setupScript.class.php @@ -84,6 +84,21 @@ abstract class SetupScript { return $this->command; } + + protected function reapplyCCFlags(string $tbl, int $type) : void + { + // reaply flags for community content as these are lost when the table is rebuild + + if (preg_match('/[^a-z]/i', $tbl)) + { + trigger_error('SetupScript::reapplyCCFlags() - invalid table name'); + return; + } + + DB::Aowow()->query('UPDATE ?_'.$tbl.' x, ?_comments y SET x.`cuFlags` = x.`cuFlags` | ?d WHERE x.`id` = y.`typeId` AND y.`type` = ?d AND y.`flags` & ?d', CUSTOM_HAS_COMMENT, $type, CC_FLAG_APPROVED); + DB::Aowow()->query('UPDATE ?_'.$tbl.' x, ?_screenshots y SET x.`cuFlags` = x.`cuFlags` | ?d WHERE x.`id` = y.`typeId` AND y.`type` = ?d AND y.`status` & ?d', CUSTOM_HAS_SCREENSHOT, $type, CC_FLAG_APPROVED); + DB::Aowow()->query('UPDATE ?_'.$tbl.' x, ?_videos y SET x.`cuFlags` = x.`cuFlags` | ?d WHERE x.`id` = y.`typeId` AND y.`type` = ?d AND y.`status` & ?d', CUSTOM_HAS_VIDEO, $type, CC_FLAG_APPROVED); + } } ?> \ No newline at end of file diff --git a/setup/tools/sqlgen/achievement.func.php b/setup/tools/sqlgen/achievement.func.php index 90fce06c..87196b30 100644 --- a/setup/tools/sqlgen/achievement.func.php +++ b/setup/tools/sqlgen/achievement.func.php @@ -123,6 +123,8 @@ SqlGen::register(new class extends SetupScript if ($criteria = DB::World()->selectCol('SELECT entry FROM disables WHERE sourceType = 4')) DB::Aowow()->query('UPDATE aowow_achievement a JOIN aowow_achievementcriteria ac ON a.id = ac.refAchievementId SET a.cuFlags = ?d WHERE ac.id IN (?a)', CUSTOM_DISABLED, $criteria); + $this->reapplyCCFlags('achievement', TYPE_ACHIEVEMENT); + return true; } }); diff --git a/setup/tools/sqlgen/areatrigger.func.php b/setup/tools/sqlgen/areatrigger.func.php index 7916904e..cc0e3a0e 100644 --- a/setup/tools/sqlgen/areatrigger.func.php +++ b/setup/tools/sqlgen/areatrigger.func.php @@ -80,6 +80,8 @@ SqlGen::register(new class extends SetupScript foreach ($addData as $id => $ad) DB::Aowow()->query('UPDATE ?_areatrigger SET ?a WHERE id = ?d', $ad, $id); + $this->reapplyCCFlags('areatrigger', TYPE_AREATRIGGER); + return true; } }); diff --git a/setup/tools/sqlgen/classes.func.php b/setup/tools/sqlgen/classes.func.php index de0b83f8..2675c73f 100644 --- a/setup/tools/sqlgen/classes.func.php +++ b/setup/tools/sqlgen/classes.func.php @@ -37,6 +37,8 @@ SqlGen::register(new class extends SetupScript foreach ($classes as $cl) DB::Aowow()->query('REPLACE INTO ?_classes (?#) VALUES (?a)', array_keys($cl), array_values($cl)); + $this->reapplyCCFlags('classes', TYPE_CLASS); + return true; } }); diff --git a/setup/tools/sqlgen/creature.func.php b/setup/tools/sqlgen/creature.func.php index 7cc7bc04..8d322290 100644 --- a/setup/tools/sqlgen/creature.func.php +++ b/setup/tools/sqlgen/creature.func.php @@ -182,6 +182,8 @@ SqlGen::register(new class extends SetupScript // apply cuFlag: exCludeFromListview [for nameparts indicating internal usage] DB::Aowow()->query('UPDATE ?_creature SET cuFlags = cuFlags | ?d WHERE name_loc0 LIKE "%[%" OR name_loc0 LIKE "%(%" OR name_loc0 LIKE "%visual%" OR name_loc0 LIKE "%trigger%" OR name_loc0 LIKE "%credit%" OR name_loc0 LIKE "%marker%"', CUSTOM_EXCLUDE_FOR_LISTVIEW); + $this->reapplyCCFlags('creature', TYPE_NPC); + return true; } }); diff --git a/setup/tools/sqlgen/currencies.func.php b/setup/tools/sqlgen/currencies.func.php index 29fa2be7..3ccfbeb4 100644 --- a/setup/tools/sqlgen/currencies.func.php +++ b/setup/tools/sqlgen/currencies.func.php @@ -75,6 +75,8 @@ SqlGen::register(new class extends SetupScript c.itemId = ?d ', $iconId, $itemId); + $this->reapplyCCFlags('currencies', TYPE_CURRENCY); + return true; } }); diff --git a/setup/tools/sqlgen/emotes.func.php b/setup/tools/sqlgen/emotes.func.php index bd8eb042..fdfa427f 100644 --- a/setup/tools/sqlgen/emotes.func.php +++ b/setup/tools/sqlgen/emotes.func.php @@ -95,6 +95,8 @@ SqlGen::register(new class extends SetupScript } } + $this->reapplyCCFlags('emotes', TYPE_EMOTE); + return $allOK; } }); diff --git a/setup/tools/sqlgen/events.func.php b/setup/tools/sqlgen/events.func.php index 4290381a..57c19b01 100644 --- a/setup/tools/sqlgen/events.func.php +++ b/setup/tools/sqlgen/events.func.php @@ -42,6 +42,8 @@ SqlGen::register(new class extends SetupScript foreach ($events as $e) DB::Aowow()->query('REPLACE INTO ?_events VALUES (?a)', array_values($e)); + $this->reapplyCCFlags('events', TYPE_WORLDEVENT); + return true; } }); diff --git a/setup/tools/sqlgen/factions.func.php b/setup/tools/sqlgen/factions.func.php index 1e051606..890244db 100644 --- a/setup/tools/sqlgen/factions.func.php +++ b/setup/tools/sqlgen/factions.func.php @@ -96,6 +96,8 @@ SqlGen::register(new class extends SetupScript foreach ($pairs as $p) DB::Aowow()->query($recursiveUpdateQuery, $p[0], $p[1], $p[0]); + $this->reapplyCCFlags('factions', TYPE_FACTION); + return true; } }); diff --git a/setup/tools/sqlgen/icons.func.php b/setup/tools/sqlgen/icons.func.php index 91468e88..70444489 100644 --- a/setup/tools/sqlgen/icons.func.php +++ b/setup/tools/sqlgen/icons.func.php @@ -34,6 +34,8 @@ SqlGen::register(new class extends SetupScript DB::Aowow()->query($baseQuery); + $this->reapplyCCFlags('icons', TYPE_ICON); + return true; } }); diff --git a/setup/tools/sqlgen/itemenchantment.func.php b/setup/tools/sqlgen/itemenchantment.func.php index 14560bd2..85236e10 100644 --- a/setup/tools/sqlgen/itemenchantment.func.php +++ b/setup/tools/sqlgen/itemenchantment.func.php @@ -34,6 +34,8 @@ SqlGen::register(new class extends SetupScript DB::Aowow()->query('UPDATE ?_itemenchantment SET cuFlags = ?d WHERE type1 = 0 AND type2 = 0 AND type3 = 0', CUSTOM_EXCLUDE_FOR_LISTVIEW); DB::Aowow()->query('UPDATE ?_itemenchantment SET cuFlags = ?d WHERE name_loc0 LIKE "%test%"', CUSTOM_EXCLUDE_FOR_LISTVIEW); + $this->reapplyCCFlags('itemenchantment', TYPE_ENCHANTMENT); + return true; } }); diff --git a/setup/tools/sqlgen/items.func.php b/setup/tools/sqlgen/items.func.php index 6674d157..862d1047 100644 --- a/setup/tools/sqlgen/items.func.php +++ b/setup/tools/sqlgen/items.func.php @@ -243,6 +243,8 @@ 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))'); + $this->reapplyCCFlags('items', TYPE_ITEM); + return true; } }); diff --git a/setup/tools/sqlgen/itemset.func.php b/setup/tools/sqlgen/itemset.func.php index 9adb9d5f..360d1152 100644 --- a/setup/tools/sqlgen/itemset.func.php +++ b/setup/tools/sqlgen/itemset.func.php @@ -318,6 +318,8 @@ SqlGen::register(new class extends SetupScript } } + $this->reapplyCCFlags('itemset', TYPE_ITEMSET); + return true; } }); diff --git a/setup/tools/sqlgen/objects.func.php b/setup/tools/sqlgen/objects.func.php index 0e6012bd..bc3e458d 100644 --- a/setup/tools/sqlgen/objects.func.php +++ b/setup/tools/sqlgen/objects.func.php @@ -120,6 +120,8 @@ SqlGen::register(new class extends SetupScript // apply typeCat and reqSkill depending on locks DB::Aowow()->query($updateQuery, $ids ?: DBSIMPLE_SKIP); + $this->reapplyCCFlags('objects', TYPE_OBJECT); + return true; } }); diff --git a/setup/tools/sqlgen/pet.func.php b/setup/tools/sqlgen/pet.func.php index fd620cdf..412aced6 100644 --- a/setup/tools/sqlgen/pet.func.php +++ b/setup/tools/sqlgen/pet.func.php @@ -119,6 +119,8 @@ SqlGen::register(new class extends SetupScript foreach ($res as $pId => $row) DB::Aowow()->query('UPDATE ?_pet SET ?a WHERE id = ?d', $row, $pId); + $this->reapplyCCFlags('pet', TYPE_PET); + return true; } }); diff --git a/setup/tools/sqlgen/quests.func.php b/setup/tools/sqlgen/quests.func.php index dd9e093e..12bf49ee 100644 --- a/setup/tools/sqlgen/quests.func.php +++ b/setup/tools/sqlgen/quests.func.php @@ -260,6 +260,8 @@ SqlGen::register(new class extends SetupScript // dungeon quests to Misc/Dungeon Finder DB::Aowow()->query('UPDATE ?_quests SET zoneOrSort = ?d WHERE (specialFlags & ?d OR id IN (?a)){ AND id IN (?a)}', -1010, QUEST_FLAG_SPECIAL_DUNGEON_FINDER, [24789, 24791, 24923], $ids ?: DBSIMPLE_SKIP); + $this->reapplyCCFlags('quests', TYPE_QUEST); + return true; } }); diff --git a/setup/tools/sqlgen/races.func.php b/setup/tools/sqlgen/races.func.php index 5f503ce9..d8e8a1d6 100644 --- a/setup/tools/sqlgen/races.func.php +++ b/setup/tools/sqlgen/races.func.php @@ -37,6 +37,8 @@ SqlGen::register(new class extends SetupScript // add cuFlags DB::Aowow()->query('UPDATE ?_races SET cuFlags = ?d WHERE flags & ?d', CUSTOM_EXCLUDE_FOR_LISTVIEW, 0x1); + $this->reapplyCCFlags('races', TYPE_RACE); + return true; } }); diff --git a/setup/tools/sqlgen/skillline.func.php b/setup/tools/sqlgen/skillline.func.php index d16f3b4c..0abcc0eb 100644 --- a/setup/tools/sqlgen/skillline.func.php +++ b/setup/tools/sqlgen/skillline.func.php @@ -58,6 +58,8 @@ SqlGen::register(new class extends SetupScript DB::Aowow()->query('UPDATE ?_skillline sl, ?_icons ic SET sl.iconId = ic.id WHERE ic.name = ? AND sl.id = ?d', 'inv_misc_pelt_wolf_01', 393); DB::Aowow()->query('UPDATE ?_skillline sl, ?_icons ic SET sl.iconId = ic.id WHERE ic.name = ? AND sl.id = ?d', 'inv_misc_key_03', 633); + $this->reapplyCCFlags('skillline', TYPE_SKILL); + return true; } }); diff --git a/setup/tools/sqlgen/sounds.func.php b/setup/tools/sqlgen/sounds.func.php index de5b396f..b170ddf4 100644 --- a/setup/tools/sqlgen/sounds.func.php +++ b/setup/tools/sqlgen/sounds.func.php @@ -422,6 +422,8 @@ SqlGen::register(new class extends SetupScript subClassMask = subClassMask | (1 << isc.subClass) '); + $this->reapplyCCFlags('sounds', TYPE_SOUND); + return true; } }); diff --git a/setup/tools/sqlgen/spell.func.php b/setup/tools/sqlgen/spell.func.php index 0a309b8c..9771e19d 100644 --- a/setup/tools/sqlgen/spell.func.php +++ b/setup/tools/sqlgen/spell.func.php @@ -726,6 +726,8 @@ SqlGen::register(new class extends SetupScript // hide unused glyphs DB::Aowow()->query('UPDATE ?_spell SET skillLine1 = 0, iconIdAlt = 0, cuFlags = cuFlags | ?d WHERE id IN (?a)', CUSTOM_EXCLUDE_FOR_LISTVIEW, [60460, 58166, 58239, 58240, 58261, 58262, 54910]); + $this->reapplyCCFlags('spell', TYPE_SPELL); + return true; } }); diff --git a/setup/tools/sqlgen/titles.func.php b/setup/tools/sqlgen/titles.func.php index a93e5524..2b5ee48b 100644 --- a/setup/tools/sqlgen/titles.func.php +++ b/setup/tools/sqlgen/titles.func.php @@ -94,6 +94,8 @@ SqlGen::register(new class extends SetupScript DB::Aowow()->query('UPDATE ?_titles SET side = 2 WHERE id <= 28 OR id IN (118, 119, 116, 117, 110, 127)'); DB::Aowow()->query('UPDATE ?_titles SET side = 1 WHERE id <= 14 OR id IN (111, 115, 112, 114, 126)'); + $this->reapplyCCFlags('titles', TYPE_TITLE); + return true; } }); diff --git a/setup/tools/sqlgen/zones.func.php b/setup/tools/sqlgen/zones.func.php index 7f4fe906..d2c45337 100644 --- a/setup/tools/sqlgen/zones.func.php +++ b/setup/tools/sqlgen/zones.func.php @@ -217,6 +217,8 @@ SqlGen::register(new class extends SetupScript DB::Aowow()->query('UPDATE ?_zones SET ?a WHERE mapId = ?d', $update, $mapId); } + $this->reapplyCCFlags('zones', TYPE_ZONE); + return true; } });