mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
- added config-option to restrict available locales - fixed opensearch suggestions by generating strict json - include TalentCalc.css as lowerCase (fixes display under *nix) - some minor formating - Setup: * added some additional files to be generated (they required STATIC_URL or HOST_URL to be set) * moved class Locale from global.js to own template and generate it with CFG_LOCALES * changed urlParam (?build=script): may be empty (builds everything) or specific scriptNames chained together with ; (?build=script1;script2) you are required to run the following command to regenerate files affected by these cahnges ?build=demo;power;realmMenu;searchboxBody;searchboxScript;searchplugin;locales
317 lines
12 KiB
PHP
317 lines
12 KiB
PHP
<?php
|
|
|
|
if (!defined('AOWOW_REVISION'))
|
|
die('illegal access');
|
|
|
|
|
|
// gatheres quasi-static data used in profiler: all available quests, achievements, titles, mounts, companions, factions, recipes
|
|
// this script requires a fully set up database and is expected to be run last
|
|
|
|
function profiler(&$log, $locales)
|
|
{
|
|
$success = true;
|
|
$scripts = [];
|
|
|
|
/**********/
|
|
/* Quests */
|
|
/**********/
|
|
$scripts[] = function(&$log) use ($locales)
|
|
{
|
|
$success = true;
|
|
$condition = [
|
|
CFG_SQL_LIMIT_NONE,
|
|
'AND',
|
|
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW], 0],
|
|
[['flags', QUEST_FLAG_DAILY | QUEST_FLAG_WEEKLY | QUEST_FLAG_REPEATABLE | QUEST_FLAG_AUTO_REWARDED, '&'], 0],
|
|
[['specialFlags', QUEST_FLAG_SPECIAL_REPEATABLE | QUEST_FLAG_SPECIAL_DUNGEON_FINDER | QUEST_FLAG_SPECIAL_MONTHLY, '&'], 0]
|
|
];
|
|
$questz = new QuestList($condition);
|
|
|
|
$_ = [];
|
|
$currencies = array_column($questz->rewards, TYPE_CURRENCY);
|
|
foreach ($currencies as $curr)
|
|
foreach ($curr as $cId => $qty)
|
|
$_[] = $cId;
|
|
|
|
$relCurr = new CurrencyList(array(['id', $_]));
|
|
|
|
foreach ($locales as $l)
|
|
{
|
|
set_time_limit(20);
|
|
|
|
User::useLocale($l);
|
|
Lang::load(Util::$localeStrings[$l]);
|
|
|
|
$buff = "var _ = g_gatheredcurrencies;\n";
|
|
foreach ($relCurr->getListviewData() as $id => $data)
|
|
$buff .= '_['.$id.'] = '.json_encode($data, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK).";\n";
|
|
|
|
$buff .= "\n\nvar _ = g_quests;\n";
|
|
foreach ($questz->getListviewData() as $id => $data)
|
|
$buff .= '_['.$id.'] = '.json_encode($data, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK).";\n";
|
|
|
|
$buff .= "\ng_quest_catorder = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n";
|
|
|
|
if (!writeFile('datasets/'.User::$localeString.'/p-quests', $buff, $log))
|
|
$success = false;
|
|
}
|
|
|
|
return $success;
|
|
};
|
|
|
|
/****************/
|
|
/* Achievements */
|
|
/****************/
|
|
$scripts[] = function(&$log) use ($locales)
|
|
{
|
|
$success = true;
|
|
$condition = array(
|
|
CFG_SQL_LIMIT_NONE,
|
|
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0],
|
|
[['flags', 1, '&'], 0], // no statistics
|
|
);
|
|
$achievez = new AchievementList($condition);
|
|
|
|
foreach ($locales as $l)
|
|
{
|
|
set_time_limit(5);
|
|
|
|
User::useLocale($l);
|
|
Lang::load(Util::$localeStrings[$l]);
|
|
|
|
$sumPoints = 0;
|
|
$buff = "var _ = g_achievements;\n";
|
|
foreach ($achievez->getListviewData(ACHIEVEMENTINFO_PROFILE) as $id => $data)
|
|
{
|
|
$sumPoints += $data['points'];
|
|
$buff .= '_['.$id.'] = '.json_encode($data, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK).";\n";
|
|
}
|
|
|
|
// categories to sort by
|
|
$buff .= "\ng_achievement_catorder = [92, 14863, 97, 169, 170, 171, 172, 14802, 14804, 14803, 14801, 95, 161, 156, 165, 14806, 14921, 96, 201, 160, 14923, 14808, 14805, 14778, 14865, 14777, 14779, 155, 14862, 14861, 14864, 14866, 158, 162, 14780, 168, 14881, 187, 14901, 163, 14922, 159, 14941, 14961, 14962, 14981, 15003, 15002, 15001, 15041, 15042, 81]";
|
|
// sum points
|
|
$buff .= "\ng_achievement_points = [".$sumPoints."];\n";
|
|
|
|
if (!writeFile('datasets/'.User::$localeString.'/p-achievements', $buff, $log))
|
|
$success = false;
|
|
}
|
|
|
|
return $success;
|
|
};
|
|
|
|
/**********/
|
|
/* Titles */
|
|
/**********/
|
|
$scripts[] = function(&$log) use ($locales)
|
|
{
|
|
$success = true;
|
|
$condition = array(
|
|
CFG_SQL_LIMIT_NONE,
|
|
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0],
|
|
);
|
|
$titlez = new TitleList($condition);
|
|
|
|
foreach ($locales as $l)
|
|
{
|
|
set_time_limit(5);
|
|
|
|
User::useLocale($l);
|
|
Lang::load(Util::$localeStrings[$l]);
|
|
|
|
foreach ([0, 1] as $g) // gender
|
|
{
|
|
$buff = "var _ = g_titles;\n";
|
|
foreach ($titlez->getListviewData() as $id => $data)
|
|
{
|
|
$data['name'] = Util::localizedString($titlez->getEntry($id), $g ? 'female' : 'male');
|
|
unset($data['namefemale']);
|
|
$buff .= '_['.$id.'] = '.json_encode($data, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK).";\n";
|
|
}
|
|
|
|
if (!writeFile('datasets/'.User::$localeString.'/p-titles-'.$g, $buff, $log))
|
|
$success = false;
|
|
}
|
|
}
|
|
|
|
return $success;
|
|
};
|
|
|
|
/**********/
|
|
/* Mounts */
|
|
/**********/
|
|
$scripts[] = function(&$log) use ($locales)
|
|
{
|
|
$success = true;
|
|
$condition = array(
|
|
CFG_SQL_LIMIT_NONE,
|
|
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0],
|
|
['typeCat', -5]
|
|
);
|
|
$mountz = new SpellList($condition);
|
|
|
|
foreach ($locales as $l)
|
|
{
|
|
set_time_limit(5);
|
|
|
|
User::useLocale($l);
|
|
Lang::load(Util::$localeStrings[$l]);
|
|
|
|
$buff = "var _ = g_spells;\n";
|
|
foreach ($mountz->getListviewData(ITEMINFO_MODEL) as $id => $data)
|
|
{
|
|
$data['quality'] = $data['name'][0];
|
|
$data['name'] = substr($data['name'], 1);
|
|
$buff .= '_['.$id.'] = '.json_encode($data, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK).";\n";
|
|
}
|
|
|
|
if (!writeFile('datasets/'.User::$localeString.'/p-mounts', $buff, $log))
|
|
$success = false;
|
|
}
|
|
|
|
return $success;
|
|
};
|
|
|
|
/**************/
|
|
/* Companions */
|
|
/**************/
|
|
$scripts[] = function(&$log) use ($locales)
|
|
{
|
|
$success = true;
|
|
$condition = array(
|
|
CFG_SQL_LIMIT_NONE,
|
|
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0],
|
|
['typeCat', -6]
|
|
);
|
|
$companionz = new SpellList($condition);
|
|
|
|
foreach ($locales as $l)
|
|
{
|
|
set_time_limit(5);
|
|
|
|
User::useLocale($l);
|
|
Lang::load(Util::$localeStrings[$l]);
|
|
|
|
$buff = "var _ = g_spells;\n";
|
|
foreach ($companionz->getListviewData(ITEMINFO_MODEL) as $id => $data)
|
|
{
|
|
$data['quality'] = $data['name'][0];
|
|
$data['name'] = substr($data['name'], 1);
|
|
$buff .= '_['.$id.'] = '.json_encode($data, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK).";\n";
|
|
}
|
|
|
|
if (!writeFile('datasets/'.User::$localeString.'/p-companions', $buff, $log))
|
|
$success = false;
|
|
}
|
|
|
|
return $success;
|
|
};
|
|
|
|
/************/
|
|
/* Factions */
|
|
/************/
|
|
$scripts[] = function(&$log) use ($locales)
|
|
{
|
|
$success = true;
|
|
$condition = array( // todo (med): exclude non-gaining reputation-header
|
|
CFG_SQL_LIMIT_NONE,
|
|
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]
|
|
);
|
|
$factionz = new FactionList($condition);
|
|
|
|
foreach ($locales as $l)
|
|
{
|
|
set_time_limit(5);
|
|
|
|
User::useLocale($l);
|
|
Lang::load(Util::$localeStrings[$l]);
|
|
|
|
$buff = "var _ = g_factions;\n";
|
|
foreach ($factionz->getListviewData() as $id => $data)
|
|
$buff .= '_['.$id.'] = '.json_encode($data, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK).";\n";
|
|
|
|
$buff .= "\ng_faction_order = [0, 469, 891, 1037, 1118, 67, 1052, 892, 936, 1117, 169, 980, 1097];\n";
|
|
|
|
if (!writeFile('datasets/'.User::$localeString.'/p-factions', $buff, $log))
|
|
$success = false;
|
|
}
|
|
|
|
return $success;
|
|
};
|
|
|
|
/***********/
|
|
/* Recipes */
|
|
/***********/
|
|
$scripts[] = function(&$log) use ($locales)
|
|
{
|
|
// special case: secondary skills are always requested, so put them in one single file (185, 129, 356); it also contains g_skill_order
|
|
$skills = [171, 164, 333, 202, 182, 773, 755, 165, 186, 393, 197, [185, 129, 356]];
|
|
$success = true;
|
|
$baseCnd = array(
|
|
CFG_SQL_LIMIT_NONE,
|
|
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0],
|
|
['effect1Id', [6, 45, 57, 127, 33, 158, 99, 28, 95], '!'], // aura, tradeSkill, Tracking, Prospecting, Decipher, Milling, Disenchant, Summon (Engineering), Skinning
|
|
['effect2Id', [118, 60], '!'], // not the skill itself
|
|
['OR', ['typeCat', 9], ['typeCat', 11]]
|
|
);
|
|
|
|
foreach ($skills as $s)
|
|
{
|
|
$file = is_array($s) ? 'sec' : (string)$s;
|
|
$cnd = array_merge($baseCnd, [['skillLine1', $s]]);
|
|
$recipez = new SpellList($cnd);
|
|
$created = '';
|
|
foreach ($recipez->iterate() as $__)
|
|
{
|
|
foreach ($recipez->canCreateItem() as $idx)
|
|
{
|
|
$id = $recipez->getField('effect'.$idx.'CreateItemId');
|
|
$created .= "g_items.add(".$id.", {'icon':'".$recipez->relItems->getEntry($id)['iconString']."'});\n";
|
|
}
|
|
}
|
|
|
|
foreach ($locales as $l)
|
|
{
|
|
set_time_limit(10);
|
|
|
|
User::useLocale($l);
|
|
Lang::load(Util::$localeStrings[$l]);
|
|
|
|
$buff = '';
|
|
foreach ($recipez->getListviewData() as $id => $data)
|
|
$buff .= '_['.$id.'] = '.json_encode($data, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK).";\n";
|
|
|
|
if (!$buff)
|
|
{
|
|
// this behaviour is intended, do not create an error
|
|
$log[] = [time(), ' notice: profiler - file datasets/'.User::$localeString.'/p-recipes-'.$file.' has no content => skipping'];
|
|
continue;
|
|
}
|
|
|
|
$buff = $created."\nvar _ = g_spells;\n".$buff;
|
|
|
|
if (is_array($s))
|
|
$buff .= "\ng_skill_order = [171, 164, 333, 202, 182, 773, 755, 165, 186, 393, 197, 185, 129, 356];\n";
|
|
|
|
if (!writeFile('datasets/'.User::$localeString.'/p-recipes-'.$file, $buff, $log))
|
|
$success = false;
|
|
}
|
|
}
|
|
|
|
return $success;
|
|
};
|
|
|
|
// check directory-structure
|
|
foreach (Util::$localeStrings as $dir)
|
|
if (!writeDir('datasets/'.$dir, $log))
|
|
$success = false;
|
|
|
|
// run scripts
|
|
foreach ($scripts as $func)
|
|
if (!$func($log))
|
|
$success = false;
|
|
|
|
return $success;
|
|
}
|
|
|
|
?>
|