Files
aowow/setup/tools/sqlgen/emotes.func.php
Sarjuuk 71e44e572a Misc/Misc
* fixed auth against TCs auth table
 * check for real paths when creating emote aliasses
 * races page no longer identifies as classes
 * fixed item comparison tool
 * fixed js error when trying to display spawn maps
2016-02-27 23:23:37 +01:00

95 lines
3.0 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 = [];
DB::Aowow()->query('TRUNCATE ?_emotes_aliasses');
foreach (CLISetup::$localeIds as $lId)
{
foreach (CLISetup::$expectedPaths as $xp => $locId)
{
if ($lId != $locId)
continue;
if ($xp) // if in subDir add trailing slash
$xp .= '/';
$path = sprintf($globStrPath, $xp);
if (CLISetup::fileExists($path))
{
$locPath[$lId] = $path;
continue 2;
}
}
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),
0, -- cuFlags
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'
);
if (!$_)
$allOK = false;
// 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;
}
?>