mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
* added emotes to DB .. why? just because! * also added to search * cross-linked achievements and emotes * data is generated via: php aowow --sql=emotes * setup requires GlobalStrings.lua (see README.md)
90 lines
2.9 KiB
PHP
90 lines
2.9 KiB
PHP
<?php
|
|
|
|
if (!defined('AOWOW_REVISION'))
|
|
die('illegal access');
|
|
|
|
if (!CLI)
|
|
die('not in cli mode');
|
|
|
|
|
|
$customData = array(
|
|
);
|
|
$reqDBC = ['emotes', 'emotestext', 'emotestextdata' /*, 'emotestextsound' */];
|
|
|
|
function emotes(/*array $ids = [] */)
|
|
{
|
|
$globStrPath = CLISetup::$srcDir.'%sInterface/FrameXML/GlobalStrings.lua';
|
|
$allOK = true;
|
|
$locPath = [];
|
|
|
|
foreach (CLISetup::$localeIds as $lId)
|
|
{
|
|
DB::Aowow()->query('TRUNCATE ?_emotes_aliasses');
|
|
|
|
$path = sprintf($globStrPath, Util::$localeStrings[$lId].'/');
|
|
if (CLISetup::fileExists($path))
|
|
{
|
|
$locPath[$lId] = $path;
|
|
continue;
|
|
}
|
|
|
|
// locale not found, try base mpqData
|
|
$path = sprintf($globStrPath, '');
|
|
if (CLISetup::fileExists($path))
|
|
{
|
|
$locPath[$lId] = $path;
|
|
continue;
|
|
}
|
|
|
|
CLISetup::log('GlobalStrings.lua not found for selected locale '.CLISetup::bold(Util::$localeStrings[$lId]), CLISetup::LOG_WARN);
|
|
$allOK = false;
|
|
}
|
|
|
|
DB::Aowow()->query('REPLACE INTO ?_emotes SELECT
|
|
et.Id,
|
|
LOWER(et.command),
|
|
IF(e.animationId, 1, 0),
|
|
etdT.text_loc0, etdT.text_loc2, etdT.text_loc3, etdT.text_loc6, etdT.text_loc8,
|
|
etdNT.text_loc0, etdNT.text_loc2, etdNT.text_loc3, etdNT.text_loc6, etdNT.text_loc8,
|
|
etdS.text_loc0, etdS.text_loc2, etdS.text_loc3, etdS.text_loc6, etdS.text_loc8
|
|
FROM
|
|
dbc_emotestext et
|
|
LEFT JOIN
|
|
dbc_emotes e ON e.Id = et.emoteId
|
|
LEFT JOIN
|
|
dbc_emotestextdata etdT ON etdT.Id = et.targetId
|
|
LEFT JOIN
|
|
dbc_emotestextdata etdNT ON etdNT.Id = et.noTargetId
|
|
LEFT JOIN
|
|
dbc_emotestextdata etdS ON etdS.Id = et.selfId'
|
|
);
|
|
|
|
// i have no idea, how the indexing in this file works.
|
|
// sometimes the \d+ after EMOTE is the emoteTextId, but not nearly often enough
|
|
$aliasses = [];
|
|
foreach ($locPath as $lId => $path)
|
|
foreach (file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line)
|
|
if (preg_match('/^EMOTE(\d+)_CMD\d+\s=\s\"\/([^"]+)\";$/', $line, $m))
|
|
$aliasses[$m[1]][] = [$lId, $m[2]];
|
|
|
|
|
|
$emotes = DB::Aowow()->selectCol('SELECT id AS ARRAY_KEY, cmd FROM ?_emotes');
|
|
|
|
foreach($emotes as $eId => $cmd)
|
|
{
|
|
foreach ($aliasses as $gsId => $data)
|
|
{
|
|
if (in_array($cmd, array_column($data, 1)))
|
|
{
|
|
foreach ($data as $d)
|
|
DB::Aowow()->query('INSERT IGNORE INTO ?_emotes_aliasses VALUES (?d, ?d, ?) ON DUPLICATE KEY UPDATE locales = locales | ?d', $eId, (1 << $d[0]), strtolower($d[1]), (1 << $d[0]));
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
return $allOK;
|
|
}
|
|
|
|
?>
|