From ac34b47c26e45ed070497d11e0d91a3c78b6ac6b Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Thu, 31 Aug 2023 14:54:23 +0200 Subject: [PATCH] Spells/Sounds * get sounds from ScreenEffect.dbc and link to type Spell and type Sound * resolve ScreenEffect name in SpellDetailPage Fixup * fix warning in UI escape sequence parsing --- includes/shared.php | 2 +- localization/lang.class.php | 2 +- pages/sound.php | 16 ++++++++++++++++ pages/spell.php | 14 ++++++++++++-- setup/db_structure.sql | 20 +++++++++++++++++++- setup/tools/dbc.class.php | 2 ++ setup/tools/sqlgen/sounds.func.php | 23 ++++++++++++++++++++++- setup/updates/1693485224_01.sql | 12 ++++++++++++ 8 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 setup/updates/1693485224_01.sql diff --git a/includes/shared.php b/includes/shared.php index a5fc5594..84fb0ade 100644 --- a/includes/shared.php +++ b/includes/shared.php @@ -1,6 +1,6 @@ |4:[:]; $var = preg_replace_callback('/([\d\.\,]+)([^\d]*)\|4([^:]*):([^:;]+)(?::([^;]+))?;/i', function ($m) { - [$_, $num, $pad, $singular, $plural1, $plural2] = $m; + [$_, $num, $pad, $singular, $plural1, $plural2] = array_pad($m, 6, null); if (self::$locId != LOCALE_RU || !$plural2) return $num . $pad . ($num == 1 ? $singular : $plural1); diff --git a/pages/sound.php b/pages/sound.php index 873e2e02..c3415a69 100644 --- a/pages/sound.php +++ b/pages/sound.php @@ -131,6 +131,14 @@ class SoundPage extends GenericPage impactarea = ?d ', $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId); + $seMiscValues = DB::Aowow()->selectCol(' + SELECT `id` FROM ?_screeneffect_sounds WHERE + `ambienceDay` = ?d OR + `ambienceNight` = ?d OR + `musicDay` = ?d OR + `musicNight` = ?d + ', $this->typeId, $this->typeId, $this->typeId, $this->typeId); + $cnd = array( 'OR', ['AND', ['effect1Id', 132], ['effect1MiscValue', $this->typeId]], @@ -141,6 +149,14 @@ class SoundPage extends GenericPage if ($displayIds) $cnd[] = ['spellVisualId', $displayIds]; + if ($seMiscValues) + $cnd[] = array( + 'OR', + ['AND', ['effect1AuraId', 260], ['effect1MiscValue', $seMiscValues]], + ['AND', ['effect2AuraId', 260], ['effect2MiscValue', $seMiscValues]], + ['AND', ['effect3AuraId', 260], ['effect3MiscValue', $seMiscValues]] + ); + $spells = new SpellList($cnd); if (!$spells->error) { diff --git a/pages/spell.php b/pages/spell.php index 3a8f4c6b..8578dfa6 100644 --- a/pages/spell.php +++ b/pages/spell.php @@ -1170,11 +1170,17 @@ class SpellPage extends GenericPage } // tab: sounds + $data = []; + $seSounds = []; + for ($i = 1; $i < 4; $i++) // sounds from screen effect + if ($this->subject->getField('effect'.$i.'AuraId') == 260) + $seSounds = DB::Aowow()->selectRow('SELECT `ambienceDay`, `ambienceNight`, `musicDay`, `musicNight` FROM ?_screeneffect_sounds WHERE `id` = ?d', $this->subject->getField('effect'.$i.'MiscValue')); + $activitySounds = DB::Aowow()->selectRow('SELECT * FROM ?_spell_sounds WHERE id = ?d', $this->subject->getField('spellVisualId')); array_shift($activitySounds); // remove id-column - if ($activitySounds) + if ($soundIDs = $activitySounds + $seSounds) { - $sounds = new SoundList(array(['id', $activitySounds])); + $sounds = new SoundList(array(['id', $soundIDs])); if (!$sounds->error) { $data = $sounds->getListviewData(); @@ -2165,6 +2171,10 @@ class SpellPage extends GenericPage $bar = ' ('.Lang::game('npc').' #'.$effMV.')'; if ($n = CreatureList::getName($effMV)) $bar = ' ('.$n.')'; + break; + case 260: // Screen Effect + if ($_ = DB::Aowow()->selectCell('SELECT `name` FROM ?_screeneffect_sounds WHERE `id` = ?d', $effMV)) + $bar = User::isInGroup(U_GROUP_EMPLOYEE | U_GROUP_TESTER) ? sprintf(Util::$dfnString, 'MiscValue'.Lang::main('colon').$effMV, $_) : $_; } $foo['name'] .= strstr($bar, 'href') || strstr($bar, '#') ? $bar : ($bar ? ' ('.$bar.')' : null); diff --git a/setup/db_structure.sql b/setup/db_structure.sql index f67cb379..d7cf5ce9 100644 --- a/setup/db_structure.sql +++ b/setup/db_structure.sql @@ -2363,6 +2363,24 @@ CREATE TABLE `aowow_scalingstatvalues` ( ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `aowow_screeneffect_sounds` +-- + +DROP TABLE IF EXISTS `aowow_screeneffect_sounds`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `aowow_screeneffect_sounds` ( + `id` smallint(5) unsigned NOT NULL, + `name` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL, + `ambienceDay` smallint(5) unsigned NOT NULL, + `ambienceNight` smallint(5) unsigned NOT NULL, + `musicDay` smallint(5) unsigned NOT NULL, + `musicNight` smallint(5) unsigned NOT NULL, + KEY `id` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `aowow_screenshots` -- @@ -3232,7 +3250,7 @@ UNLOCK TABLES; LOCK TABLES `aowow_dbversion` WRITE; /*!40000 ALTER TABLE `aowow_dbversion` DISABLE KEYS */; -INSERT INTO `aowow_dbversion` VALUES (1692289952,0,NULL,NULL); +INSERT INTO `aowow_dbversion` VALUES (1693485225,0,NULL,NULL); /*!40000 ALTER TABLE `aowow_dbversion` ENABLE KEYS */; UNLOCK TABLES; diff --git a/setup/tools/dbc.class.php b/setup/tools/dbc.class.php index bfe0e28d..e72d4e80 100644 --- a/setup/tools/dbc.class.php +++ b/setup/tools/dbc.class.php @@ -108,6 +108,7 @@ class DBC 'randproppoints' => 'niiiiiiiiiiiiiii', 'scalingstatdistribution' => 'niiiiiiiiiiiiiiiiiiiii', 'scalingstatvalues' => 'xniiiiiiiiiiiiiiiiiiiiii', + 'screeneffect' => 'nsxxxxxxii', 'skillline' => 'nixsxsssxsxsxxxxxxxxsxsssxsxsxxxxxxxxixxxxxxxxxxxxxxxxxx', 'skilllineability' => 'niiiixxixiiixx', 'skilllinecategory' => 'nsxsssxsxsxxxxxxxxi', @@ -215,6 +216,7 @@ class DBC 'randproppoints' => 'id,epic1,epic2,epic3,epic4,epic5,rare1,rare2,rare3,rare4,rare5,uncommon1,uncommon2,uncommon3,uncommon4,uncommon5', 'scalingstatdistribution' => 'id,statMod1,statMod2,statMod3,statMod4,statMod5,statMod6,statMod7,statMod8,statMod9,statMod10,modifier1,modifier2,modifier3,modifier4,modifier5,modifier6,modifier7,modifier8,modifier9,modifier10,maxLevel', 'scalingstatvalues' => 'id,shoulderMultiplier,trinketMultiplier,weaponMultiplier,rangedMultiplier,clothShoulderArmor,leatherShoulderArmor,mailShoulderArmor,plateShoulderArmor,weaponDPS1H,weaponDPS2H,casterDPS1H,casterDPS2H,rangedDPS,wandDPS,spellPower,primBudged,tertBudged,clothCloakArmor,clothChestArmor,leatherChestArmor,mailChestArmor,plateChestArmor', + 'screeneffect' => 'id,name,soundAmbienceId,zoneMusicId', 'skillline' => 'id,categoryId,name_loc0,name_loc2,name_loc3,name_loc4,name_loc6,name_loc8,description_loc0,description_loc2,description_loc3,description_loc4,description_loc6,description_loc8,iconId', 'skilllineability' => 'id,skillLineId,spellId,reqRaceMask,reqClassMask,reqSkillLevel,acquireMethod,skillLevelGrey,skillLevelYellow', 'skilllinecategory' => 'id,name_loc0,name_loc2,name_loc3,name_loc4,name_loc6,name_loc8,index', diff --git a/setup/tools/sqlgen/sounds.func.php b/setup/tools/sqlgen/sounds.func.php index 2c5ab2a0..db558890 100644 --- a/setup/tools/sqlgen/sounds.func.php +++ b/setup/tools/sqlgen/sounds.func.php @@ -19,7 +19,7 @@ SqlGen::register(new class extends SetupScript // creatures 'npcsounds', 'creaturesounddata', 'creaturedisplayinfo', 'creaturemodeldata', // spells - 'spell', 'spellvisual', 'spellvisualkit', + 'spell', 'spellvisual', 'spellvisualkit', 'screeneffect', // zones 'soundambience', 'zonemusic', 'zoneintromusictable', 'worldstatezonesounds', 'areatable', // items @@ -423,6 +423,27 @@ SqlGen::register(new class extends SetupScript subClassMask = subClassMask | (1 << isc.subClass) '); + + /************************/ + /* Screen Effect Sounds */ + /************************/ + + CLI::write(' - linking to screen effects'); + + DB::Aowow()->query('TRUNCATE ?_screeneffect_sounds'); + DB::Aowow()->query(' + INSERT INTO + ?_screeneffect_sounds + SELECT + se.id, se.name, IFNULL(sa.soundIdDay, 0), IFNULL(sa.soundIdNight, 0), IFNULL(zm.soundIdDay, 0), IFNULL(zm.soundIdNight, 0) + FROM + dbc_screeneffect se + LEFT JOIN + dbc_soundambience sa ON se.soundAmbienceId = sa.id + LEFT JOIN + dbc_zonemusic zm ON se.zoneMusicId = zm.id + '); + $this->reapplyCCFlags('sounds', Type::SOUND); return true; diff --git a/setup/updates/1693485224_01.sql b/setup/updates/1693485224_01.sql new file mode 100644 index 00000000..3db61fd4 --- /dev/null +++ b/setup/updates/1693485224_01.sql @@ -0,0 +1,12 @@ +DROP TABLE IF EXISTS `aowow_screeneffect_sounds`; +CREATE TABLE `aowow_screeneffect_sounds` ( + `id` SMALLINT(5) unsigned NOT NULL, + `name` VARCHAR(40) COLLATE utf8mb4_unicode_ci NOT NULL, + `ambienceDay` SMALLINT(5) unsigned NOT NULL, + `ambienceNight` SMALLINT(5) unsigned NOT NULL, + `musicDay` SMALLINT(5) unsigned NOT NULL, + `musicNight` SMALLINT(5) unsigned NOT NULL, + KEY `id` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +UPDATE `aowow_dbversion` SET `sql` = CONCAT(IFNULL(`sql`, ''), ' sounds');