implementation of Sound DB

Client sounds are cross-referenced with as many other DB-Types as possible. Including, but not limited to:
 * Character VOs (Errors, Emotes)
 * Creature VOs (Boss Dialogue)
 * Zone Music and Ambience
 * Sounds triggerd by spells
 * Sounds from general item/spell usage, creature behavior

Restrictions:
 * only one locale is supported. Choose wisely!
This commit is contained in:
Sarjuuk
2017-03-06 15:16:34 +01:00
committed by GitHub
parent 8fcd8ea429
commit 20a1829317
54 changed files with 3454 additions and 169 deletions

View File

@@ -352,6 +352,16 @@ abstract class BaseType
return $value;
}
public function getAllFields($field, $localized = false, $silent = false)
{
$data = [];
foreach ($this->iterate() as $__)
$data[$this->id] = $this->getField($field, $localized, $silent);
return $data;
}
public function getRandomId()
{
// ORDER BY RAND() is not optimal, so if anyone has an alternative idea..
@@ -668,7 +678,7 @@ trait spawnHelper
public function getSpawns($mode)
{
// ony Creatures and GOs can be spawned
if (!self::$type || (self::$type != TYPE_NPC && self::$type != TYPE_OBJECT))
if (!self::$type || (self::$type != TYPE_NPC && self::$type != TYPE_OBJECT && self::$type != TYPE_SOUND))
return [];
switch ($mode)

View File

@@ -24,6 +24,7 @@ define('TYPE_CLASS', 13);
define('TYPE_RACE', 14);
define('TYPE_SKILL', 15);
define('TYPE_CURRENCY', 17);
define('TYPE_SOUND', 19);
// internal types (not published to js)
define('TYPE_USER', 500);
define('TYPE_EMOTE', 501);
@@ -42,7 +43,7 @@ define('SEARCH_TYPE_REGULAR', 0x10000000);
define('SEARCH_TYPE_OPEN', 0x20000000);
define('SEARCH_TYPE_JSON', 0x40000000);
define('SEARCH_MASK_OPEN', 0x007DC1FF); // open search
define('SEARCH_MASK_ALL', 0x07FFFFFF); // normal search
define('SEARCH_MASK_ALL', 0x0FFFFFFF); // normal search
// Databases
define('DB_AOWOW', 0);
@@ -158,6 +159,7 @@ define('BUTTON_LINKS', 4);
define('BUTTON_FORUM', 5);
define('BUTTON_TALENT', 6);
define('BUTTON_EQUIP', 7);
define('BUTTON_PLAYLIST', 8);
// generic filter handler
define('FILTER_CR_BOOLEAN', 1);
@@ -200,6 +202,9 @@ define('CC_FLAG_DELETED', 0x2);
define('CC_FLAG_OUTDATED', 0x4);
define('CC_FLAG_APPROVED', 0x8);
define('SOUND_TYPE_OGG', 1);
define('SOUND_TYPE_MP3', 2);
/*
* Game
*/

View File

@@ -0,0 +1,137 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
class SoundList extends BaseType
{
use spawnHelper;
public static $type = TYPE_SOUND;
public static $brickFile = 'sound';
public static $dataTable = '?_sounds';
protected $queryBase = 'SELECT *, s.id AS ARRAY_KEY FROM ?_sounds s';
private $fileBuffer = [];
private static $fileTypes = array(
SOUND_TYPE_OGG => 'audio/ogg; codecs="vorbis"',
SOUND_TYPE_MP3 => 'audio/mpeg'
);
public function __construct($conditions = [])
{
parent::__construct($conditions);
// post processing
foreach ($this->iterate() as $id => &$_curTpl)
{
$_curTpl['files'] = [];
for ($i = 1; $i < 11; $i++)
{
if ($_curTpl['soundFile'.$i])
{
$this->fileBuffer[$_curTpl['soundFile'.$i]] = null;
$_curTpl['files'][] = &$this->fileBuffer[$_curTpl['soundFile'.$i]];
}
unset($_curTpl['soundFile'.$i]);
}
}
if ($this->fileBuffer)
{
$files = DB::Aowow()->select('SELECT id AS ARRAY_KEY, `id`, `file` AS title, `type` FROM ?_sounds_files sf WHERE id IN (?a)', array_keys($this->fileBuffer));
foreach ($files as $id => $data)
{
// skipp file extension
$data['title'] = substr($data['title'], 0, -4);
// enum to string
$data['type'] = self::$fileTypes[$data['type']];
// get real url
$data['url'] = STATIC_URL . '/wowsounds/' . $data['id'];
// v push v
$this->fileBuffer[$id] = $data;
}
}
}
public static function getName($id)
{
$this->getEntry($id);
return $this->getField('name');
}
public function getListviewData()
{
$data = [];
foreach ($this->iterate() as $__)
{
$data[$this->id] = array(
'id' => $this->id,
'type' => $this->getField('cat'),
'name' => $this->getField('name'),
'files' => array_values(array_filter($this->getField('files')))
);
}
return $data;
}
public function getJSGlobals($addMask = 0)
{
$data = [];
foreach ($this->iterate() as $__)
$data[self::$type][$this->id] = array(
'name' => Util::jsEscape($this->getField('name', true)),
'type' => $this->getField('cat'),
'files' => array_values(array_filter($this->getField('files')))
);
return $data;
}
public function renderTooltip() { }
}
class SoundListFilter extends Filter
{
// we have no criteria for this one...
protected function createSQLForCriterium(&$cr)
{
unset($cr);
$this->error = true;
return [1];
}
protected function createSQLForValues()
{
$parts = [];
$_v = &$this->fiData['v'];
// name [str]
if (isset($_v['na']))
if ($_ = $this->modularizeString(['name']))
$parts[] = $_;
// type [list]
if (isset($_v['ty']))
{
if ($_ = array_intersect((array)$_v['ty'], [1, 2, 3, 4, 6, 9, 10, 12, 13, 14, 16, 17, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 50, 52, 53]))
$parts[] = ['cat', $_];
else
{
$this->error = true;
unset($_v['ty']);
}
}
return $parts;
}
}
?>

View File

@@ -1998,6 +1998,11 @@ class SpellList extends BaseType
for ($i = 0; $i < 11; $i++)
if ($mask & (1 << $i))
$data[TYPE_RACE][$i + 1] = $i + 1;
// play sound effect
for ($i = 1; $i < 4; $i++)
if ($this->getField('effect'.$i.'Id') == 132)
$data[TYPE_SOUND][$this->getField('effect'.$i.'MiscValue')] = $this->getField('effect'.$i.'MiscValue');
}
if ($addMask & GLOBALINFO_SELF)

View File

@@ -39,7 +39,7 @@ class Util
public static $typeClasses = array(
null, 'CreatureList', 'GameObjectList', 'ItemList', 'ItemsetList', 'QuestList', 'SpellList',
'ZoneList', 'FactionList', 'PetList', 'AchievementList', 'TitleList', 'WorldEventList', 'CharClassList',
'CharRaceList', 'SkillList', null, 'CurrencyList',
'CharRaceList', 'SkillList', null, 'CurrencyList', null, 'SoundList',
TYPE_EMOTE => 'EmoteList',
TYPE_ENCHANTMENT => 'EnchantmentList'
);
@@ -47,6 +47,7 @@ class Util
public static $typeStrings = array( // zero-indexed
null, 'npc', 'object', 'item', 'itemset', 'quest', 'spell', 'zone', 'faction',
'pet', 'achievement', 'title', 'event', 'class', 'race', 'skill', null, 'currency',
null, 'sound',
TYPE_USER => 'user',
TYPE_EMOTE => 'emote',
TYPE_ENCHANTMENT => 'enchantment'