From feaee59cd07a7cdfec729e18c53f5335134f0562 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Sat, 13 Sep 2014 21:26:11 +0200 Subject: [PATCH] - converted articles for MorePages to use STATIC_URL (also neutralized some self-references) - 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 --- .gitignore | 7 + config/aowow.xml.in | 19 - includes/database.class.php | 2 +- includes/types/basetype.class.php | 4 +- includes/user.class.php | 4 + includes/utilities.php | 4 +- index.php | 2 +- pages/event.php | 2 +- pages/npc.php | 2 +- pages/pet.php | 2 +- pages/quest.php | 2 +- pages/search.php | 17 +- pages/spells.php | 2 +- pages/talent.php | 2 +- setup/tools/dataset/enchants.php | 230 ------------ setup/tools/dataset/gems.php | 106 ------ setup/tools/dataset/glyphs.php | 105 ------ setup/tools/dataset/itemsets.php | 141 -------- setup/tools/dataset/pets.php | 161 --------- setup/tools/dataset/profiler.php | 328 ------------------ setup/tools/dataset/realms.php | 120 ------- setup/tools/dataset/statistics.php | 140 -------- setup/tools/dataset/talent-icons.php | 80 ----- setup/tools/dataset/talents.php | 236 ------------- setup/tools/filegen/enchants.func.php | 224 ++++++++++++ setup/tools/filegen/gems.func.php | 91 +++++ setup/tools/filegen/glyphs.func.php | 90 +++++ setup/tools/filegen/itemsets.func.php | 134 +++++++ setup/tools/filegen/locales.func.php | 53 +++ setup/tools/filegen/mnProfiles.func.php | 73 ++++ setup/tools/filegen/pets.func.php | 119 +++++++ setup/tools/filegen/profiler.func.php | 316 +++++++++++++++++ setup/tools/filegen/realms.func.php | 35 ++ setup/tools/filegen/scriptGen.php | 195 +++++++++++ setup/tools/filegen/statistics.func.php | 152 ++++++++ setup/tools/filegen/talentIcons.func.php | 99 ++++++ setup/tools/filegen/talents.func.php | 207 +++++++++++ setup/tools/filegen/templates/aowow.xml.in | 19 + .../tools/filegen/templates/demo.html.in | 60 ++-- setup/tools/filegen/templates/item-scaling.in | 9 + setup/tools/filegen/templates/locale.js.in | 62 ++++ .../tools/filegen/templates/power.js.in | 17 +- .../filegen/templates}/profile_all.js.in | 2 +- .../tools/filegen/templates/searchbox.html.in | 14 +- .../tools/filegen/templates/searchbox.js.in | 23 +- setup/tools/sql/_itemset.php | 4 +- setup/updates/08_articles_config.sql | 14 + static/download/searchplugins/aowow.xml | 19 - static/js/global.js | 120 +------ static/js/profile_all.js | 7 - template/bricks/contribute.tpl.php | 2 +- template/bricks/head.tpl.php | 1 + template/listviews/pet.tpl.php | 8 +- 53 files changed, 1992 insertions(+), 1895 deletions(-) delete mode 100644 config/aowow.xml.in delete mode 100755 setup/tools/dataset/enchants.php delete mode 100644 setup/tools/dataset/gems.php delete mode 100755 setup/tools/dataset/glyphs.php delete mode 100644 setup/tools/dataset/itemsets.php delete mode 100755 setup/tools/dataset/pets.php delete mode 100644 setup/tools/dataset/profiler.php delete mode 100644 setup/tools/dataset/realms.php delete mode 100755 setup/tools/dataset/statistics.php delete mode 100644 setup/tools/dataset/talent-icons.php delete mode 100644 setup/tools/dataset/talents.php create mode 100644 setup/tools/filegen/enchants.func.php create mode 100644 setup/tools/filegen/gems.func.php create mode 100644 setup/tools/filegen/glyphs.func.php create mode 100644 setup/tools/filegen/itemsets.func.php create mode 100644 setup/tools/filegen/locales.func.php create mode 100644 setup/tools/filegen/mnProfiles.func.php create mode 100644 setup/tools/filegen/pets.func.php create mode 100644 setup/tools/filegen/profiler.func.php create mode 100644 setup/tools/filegen/realms.func.php create mode 100644 setup/tools/filegen/scriptGen.php create mode 100644 setup/tools/filegen/statistics.func.php create mode 100644 setup/tools/filegen/talentIcons.func.php create mode 100644 setup/tools/filegen/talents.func.php create mode 100644 setup/tools/filegen/templates/aowow.xml.in rename static/widgets/power/demo.html => setup/tools/filegen/templates/demo.html.in (52%) create mode 100644 setup/tools/filegen/templates/item-scaling.in create mode 100644 setup/tools/filegen/templates/locale.js.in rename static/widgets/power.js => setup/tools/filegen/templates/power.js.in (97%) rename {config => setup/tools/filegen/templates}/profile_all.js.in (87%) rename static/widgets/searchbox/searchbox.html => setup/tools/filegen/templates/searchbox.html.in (51%) rename static/widgets/searchbox.js => setup/tools/filegen/templates/searchbox.js.in (58%) create mode 100644 setup/updates/08_articles_config.sql delete mode 100644 static/download/searchplugins/aowow.xml delete mode 100644 static/js/profile_all.js diff --git a/.gitignore b/.gitignore index 5faf86ee..ebf6a3fe 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,14 @@ # generated files /static/js/profile_all.js +/static/js/locale.js +/static/widgets/power.js +/static/widgets/power/demo.html +/static/widgets/searchbox.js +/static/widgets/searchbox/searchbox.html +/static/download/searchplugins/aowow.xml /config/config.php +# /datasets/item-scaling # extracted images /static/images/wow/icons/large/* diff --git a/config/aowow.xml.in b/config/aowow.xml.in deleted file mode 100644 index eb98787b..00000000 --- a/config/aowow.xml.in +++ /dev/null @@ -1,19 +0,0 @@ - - - -/*$shortName*/ -/*$name*/ - - - - -/*STATIC_URL*//images/logos/favicon.ico -/*STATIC_URL*//images/icons/favicon.gif - - diff --git a/includes/database.class.php b/includes/database.class.php index 99bc1eb7..fb39bf2e 100644 --- a/includes/database.class.php +++ b/includes/database.class.php @@ -69,7 +69,7 @@ class DB private static function safeGetDB($idx) { - if(!self::isConnected($idx)) + if (!self::isConnected($idx)) self::connect($idx); return self::getDB($idx); diff --git a/includes/types/basetype.class.php b/includes/types/basetype.class.php index f7504f8a..0b8c1f84 100644 --- a/includes/types/basetype.class.php +++ b/includes/types/basetype.class.php @@ -1,6 +1,6 @@ $c) { - switch(getType($c)) + switch (getType($c)) { case 'array': break; diff --git a/includes/user.class.php b/includes/user.class.php index 9af13667..ee55c6de 100644 --- a/includes/user.class.php +++ b/includes/user.class.php @@ -147,6 +147,10 @@ class User } } + // check + if ($loc != LOCALE_EN && !(CFG_LOCALES & (1 << $loc))) + $loc = LOCALE_EN; + // set if ($loc != self::$localeId) { diff --git a/includes/utilities.php b/includes/utilities.php index 43eaef19..63c1dc5c 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -1329,7 +1329,7 @@ class Util ); $str = strtr($str, $accents); $str = trim($str); - $str = preg_replace('/[^a-z0-9]/ig', '-', $str); + $str = preg_replace('/[^a-z0-9]/i', '-', $str); $str = str_replace('--', '-', $str); $str = str_replace('--', '-', $str); @@ -1337,7 +1337,7 @@ class Util $str = rtrim($str, '-'); $str = strtolower($str); - return str; + return $str; } public static function isValidEmail($email) diff --git a/index.php b/index.php index 9e1d3132..9a008328 100644 --- a/index.php +++ b/index.php @@ -126,7 +126,7 @@ switch ($pageCall) case 'build': if (User::isInGroup(U_GROUP_EMPLOYEE)) { - require 'setup/tools/dataset/'.$pageParam.'.php'; + require 'setup/tools/filegen/scriptGen.php'; break; } case 'sql': diff --git a/pages/event.php b/pages/event.php index 4813ef15..f8350d58 100644 --- a/pages/event.php +++ b/pages/event.php @@ -298,7 +298,7 @@ class EventPage extends GenericPage /* finalize related events */ /***************************/ - foreach($this->lvTabs as &$view) + foreach ($this->lvTabs as &$view) { if ($view['file'] != WorldEventList::$brickFile) continue; diff --git a/pages/npc.php b/pages/npc.php index 2df54aae..5859fcc1 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -722,7 +722,7 @@ class NpcPage extends GenericPage { $spilled = new FactionList(array(['parentFactionId', array_keys($spilledParents)])); - foreach($reputation as &$sets) + foreach ($reputation as &$sets) { foreach ($sets[1] as &$row) { diff --git a/pages/pet.php b/pages/pet.php index 8c7e5665..21435b4d 100644 --- a/pages/pet.php +++ b/pages/pet.php @@ -171,7 +171,7 @@ class PetPage extends GenericPage ] ); - switch($this->subject->getField('type')) + switch ($this->subject->getField('type')) { case 0: $conditions[] = ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE0, '&']; break; case 1: $conditions[] = ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE1, '&']; break; diff --git a/pages/quest.php b/pages/quest.php index e759f842..a98dc681 100644 --- a/pages/quest.php +++ b/pages/quest.php @@ -107,7 +107,7 @@ class QuestPage extends GenericPage break; default: $lm = Lang::$quest['loremaster'].Lang::$main['colon'].'[ul]'; - foreach($loremaster->iterate() as $id => $__) + foreach ($loremaster->iterate() as $id => $__) $lm .= '[li][achievement='.$id.'][/li]'; $infobox[] = $lm.'[/ul]'; diff --git a/pages/search.php b/pages/search.php index bfc9fef2..01c7ac5c 100644 --- a/pages/search.php +++ b/pages/search.php @@ -281,8 +281,10 @@ class SearchPage extends GenericPage // this one is funny: we want 10 results, ideally equally distributed over each type $foundTotal = 0; $limit = $this->maxResults; - $names = []; - $info = []; + $result = array( //idx1: names, idx3: resultUrl; idx7: extraInfo + $this->search, + [], [], [], [], [], [], [] + ); foreach ($this->lvTabs as $_) $foundTotal += $_['matches']; @@ -301,9 +303,10 @@ class SearchPage extends GenericPage if (!$data) break; - $hasQ = is_numeric($data['name'][0]) || $data['name'][0] == '@'; - $names[] = ($hasQ ? substr($data['name'], 1) : $data['name']).$set['appendix']; - $extra = [$set['type'], $data['id']]; + $hasQ = is_numeric($data['name'][0]) || $data['name'][0] == '@'; + $result[1][] = ($hasQ ? substr($data['name'], 1) : $data['name']).$set['appendix']; + $result[3][] = HOST_URL.'/?'.Util::$typeStrings[$set['type']].'='.$data['id']; + $extra = [$set['type'], $data['id']]; if (isset($data['param1'])) $extra[] = $data['param1']; @@ -311,14 +314,14 @@ class SearchPage extends GenericPage if (isset($data['param2'])) $extra[] = $data['param2']; - $info[] = $extra; + $result[7][] = $extra; } if ($limit <= 0) break; } - return '["'.Util::jsEscape($this->search).'", '.json_encode($names).', [], [], [], [], [], '.json_encode($info, JSON_NUMERIC_CHECK).']'; + return json_encode($result, JSON_NUMERIC_CHECK); } private function createLookup(array $fields = []) diff --git a/pages/spells.php b/pages/spells.php index 55773d00..bad65f47 100644 --- a/pages/spells.php +++ b/pages/spells.php @@ -428,7 +428,7 @@ class SpellsPage extends GenericPage array_unshift($foo, is_array($_) ? $_[0] : $_); } - if(count($foo) < 2) + if (count($foo) < 2) array_unshift($foo, $this->name); foreach ($foo as $bar) diff --git a/pages/talent.php b/pages/talent.php index a277aa9b..0c695532 100644 --- a/pages/talent.php +++ b/pages/talent.php @@ -14,7 +14,7 @@ class TalentPage extends GenericPage protected $gDataKey = true; protected $js = ['TalentCalc.js']; protected $css = array( - ['path' => 'TalentCalc.css'], + ['path' => 'talentcalc.css'], ['path' => 'talent.css'] ); diff --git a/setup/tools/dataset/enchants.php b/setup/tools/dataset/enchants.php deleted file mode 100755 index da82dbdc..00000000 --- a/setup/tools/dataset/enchants.php +++ /dev/null @@ -1,230 +0,0 @@ -iterate() as $__) - $enchIds[] = $enchantSpells->getField('effect1MiscValue'); - - $enchMisc = []; - $enchJSON = Util::parseItemEnchantment($enchIds, false, $enchMisc); - - echo "script set up in ".Util::execTime()."
\n"; - - foreach ($locales as $lId) - { - set_time_limit(180); - User::useLocale($lId); - Lang::load(Util::$localeStrings[$lId]); - - $enchantsOut = []; - foreach ($enchantSpells->iterate() as $__) - { - // slots have to be recalculated - $slot = 0; - if ($enchantSpells->getField('equippedItemClass') == 4) // armor - { - if ($invType = $enchantSpells->getField('equippedItemInventoryTypeMask')) - $slot = $invType >> 1; - else /* if (equippedItemSubClassMask == 64) */ // shields have it their own way <_< - $slot = (1 << (14 - 1)); - } - else if ($enchantSpells->getField('equippedItemClass') == 2) // weapon - { - foreach ($slotPointer as $i => $sp) - { - if (!$sp) - continue; - - if ((1 << $i) & $enchantSpells->getField('equippedItemSubClassMask')) - { - if ($sp == 13) // also mainHand & offHand *siiigh* - $slot |= ((1 << (21 - 1)) | (1 << (22 - 1))); - - $slot |= (1 << ($sp - 1)); - } - } - } - - $eId = $enchantSpells->getField('effect1MiscValue'); - - // defaults - $ench = array( - 'name' => [], // set by skill or item - 'quality' => -1, // modified if item - 'icon' => strToLower($enchantSpells->getField('iconString')), // item over spell - 'source' => [], // <0: item; >0:spell - 'skill' => -1, // modified if skill - 'slots' => [], // determined per spell but set per item - 'enchantment' => Util::localizedString($enchMisc[$eId]['text'], 'text'), - 'jsonequip' => @$enchJSON[$eId] ?: [], - 'temp' => 0, // always 0 - 'classes' => 0, // modified by item - ); - - if (isset($enchMisc[$eId]['reqskill'])) - $ench['jsonequip']['reqskill'] = $enchMisc[$eId]['reqskill']; - - if (isset($enchMisc[$eId]['reqskillrank'])) - $ench['jsonequip']['reqskill'] = $enchMisc[$eId]['reqskillrank']; - - if (isset($enchMisc[$eId]['requiredLevel'])) - $ench['jsonequip']['requiredLevel'] = $enchMisc[$eId]['requiredLevel']; - - // check if the spell has an entry in skill_line_ability -> Source:Profession - if ($skill = DB::Aowow()->SelectCell('SELECT skillLineId FROM dbc.skilllineability WHERE spellId = ?d', $enchantSpells->id)) - { - $ench['name'][] = $enchantSpells->getField('name', true); - $ench['source'][] = $enchantSpells->id; - $ench['skill'] = $skill; - $ench['slots'][] = $slot; - } - - // check if this spell can be cast via item -> Source:Item - if (!isset($castItems[$enchantSpells->id])) - $castItems[$enchantSpells->id] = new ItemList([['spellId1', $enchantSpells->id], ['name_loc0', 'Scroll of Enchant%', '!']]); // do not reuse enchantment scrolls - - $cI = &$castItems[$enchantSpells->id]; // this construct is a bit .. unwieldy - foreach ($cI->iterate() as $__) - { - $ench['name'][] = $cI->getField('name', true); - $ench['source'][] = -$cI->id; - $ench['icon'] = strTolower($cI->getField('iconString')); - $ench['slots'][] = $slot; - - if ($cI->getField('quality') > $ench['quality']) - $ench['quality'] = $cI->getField('quality'); - - if ($cI->getField('requiredClass') > 0) - { - $ench['classes'] = $cI->getField('requiredClass'); - $ench['jsonequip']['classes'] = $cI->getField('requiredClass'); - } - - if (!isset($ench['jsonequip']['reqlevel'])) - if ($cI->getField('requiredLevel') > 0) - $ench['jsonequip']['reqlevel'] = $cI->getField('requiredLevel'); - } - - // enchant spell not in use - if (empty($ench['source'])) - continue; - - // everything gathered - if (isset($enchantsOut[$eId])) // already found, append data - { - foreach ($enchantsOut[$eId] as $k => $v) - { - if (is_array($v)) - { - while ($pop = array_pop($ench[$k])) - $enchantsOut[$eId][$k][] = $pop; - } - else - { - if ($k == 'quality') // quality:-1 if spells and items are mixed - { - if ($enchantsOut[$eId]['source'][0] > 0 && $ench['source'][0] < 0) - $enchantsOut[$eId][$k] = -1; - else if ($enchantsOut[$eId]['source'][0] < 0 && $ench['source'][0] > 0) - $enchantsOut[$eId][$k] = -1; - else - $enchantsOut[$eId][$k] = $ench[$k]; - } - else if ($enchantsOut[$eId][$k] <= 0) - $enchantsOut[$eId][$k] = $ench[$k]; - } - } - } - else // nothing yet, create new - $enchantsOut[$eId] = $ench; - } - - // walk over each entry and strip single-item arrays - foreach ($enchantsOut as &$ench) - { - foreach ($ench as $k => $v) - if (is_array($v) && count($v) == 1 && $k != 'jsonequip') - $ench[$k] = $v[0]; - } - - $toFile = "var g_enchants = "; - $toFile .= json_encode($enchantsOut, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK); - $toFile .= ";"; - $file = 'datasets/'.User::$localeString.'/enchants'; - - $handle = fOpen($file, "w"); - fWrite($handle, $toFile); - fClose($handle); - - echo "done enchants loc: ".$lId." in ".Util::execTime()."
\n"; - } - - echo "
\nall done"; - - Lang::load(Util::$localeStrings[LOCALE_EN]); - - $stats = DB::Aowow()->getStatistics(); - echo "
\n".$stats['count']." queries in: ".Util::formatTime($stats['time'] * 1000); -?> diff --git a/setup/tools/dataset/gems.php b/setup/tools/dataset/gems.php deleted file mode 100644 index 5c1a51e5..00000000 --- a/setup/tools/dataset/gems.php +++ /dev/null @@ -1,106 +0,0 @@ - 0 - ORDER BY - it.entry DESC - ; - "; - - $gems = DB::Aowow()->Select($gemQuery); - $locales = [LOCALE_EN, LOCALE_FR, LOCALE_DE, LOCALE_ES, LOCALE_RU]; - - // check directory-structure - foreach (Util::$localeStrings as $dir) - if (!is_dir('datasets/'.$dir)) - mkdir('datasets/'.$dir, 0755, true); - - $enchIds = []; - foreach ($gems as $pop) - $enchIds[] = $pop['enchId']; - - $enchMisc = []; - $enchJSON = Util::parseItemEnchantment($enchIds, false, $enchMisc); - - echo "script set up in ".Util::execTime()."
\n"; - - foreach ($locales as $lId) - { - User::useLocale($lId); - Lang::load(Util::$localeStrings[$lId]); - - $gemsOut = []; - foreach ($gems as $pop) - { - $gemsOut[$pop['itemId']] = array( - 'name' => Util::localizedString($pop, 'name'), - 'quality' => $pop['quality'], - 'icon' => strToLower($pop['icon']), - 'enchantment' => Util::localizedString(@$enchMisc[$pop['enchId']]['text'] ?: [], 'text'), - 'jsonequip' => @$enchJSON[$pop['enchId']] ?: [], - 'colors' => $pop['colors'], - 'expansion' => $pop['expansion'] - ); - } - - $toFile = "var g_gems = "; - $toFile .= json_encode($gemsOut, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK); - $toFile .= ";"; - $file = 'datasets/'.User::$localeString.'/gems'; - - $handle = fOpen($file, "w"); - fWrite($handle, $toFile); - fClose($handle); - - echo "done gems loc: ".$lId." in ".Util::execTime()."
\n"; - } - - echo "
\nall done"; - - Lang::load(Util::$localeStrings[LOCALE_EN]); - - $stats = DB::Aowow()->getStatistics(); - echo "
\n".$stats['count']." queries in: ".Util::formatTime($stats['time'] * 1000); -?> diff --git a/setup/tools/dataset/glyphs.php b/setup/tools/dataset/glyphs.php deleted file mode 100755 index 1601b471..00000000 --- a/setup/tools/dataset/glyphs.php +++ /dev/null @@ -1,105 +0,0 @@ -Select($queryGlyphs); - $locales = [LOCALE_EN, LOCALE_FR, LOCALE_DE, LOCALE_ES, LOCALE_RU]; - - // check directory-structure - foreach (Util::$localeStrings as $dir) - if (!is_dir('datasets/'.$dir)) - mkdir('datasets/'.$dir, 0755, true); - - echo "script set up in ".Util::execTime()."
\n"; - - $glyphSpells = new SpellList(array(['s.id', array_keys($glyphList)], CFG_SQL_LIMIT_NONE)); - - foreach ($locales as $lId) - { - User::useLocale($lId); - Lang::load(Util::$localeStrings[$lId]); - - $glyphsOut = []; - foreach ($glyphSpells->iterate() as $__) - { - $pop = $glyphList[$glyphSpells->id]; - - if (!$pop['glyphEffect']) - continue; - - if ($glyphSpells->getField('effect1Id') != 6 && $glyphSpells->getField('effect2Id') != 6 && $glyphSpells->getField('effect3Id') != 6) - continue; - - $glyphsOut[$pop['itemId']] = array( - 'name' => Util::localizedString($pop, 'name'), - 'description' => $glyphSpells->parseText()[0], - 'icon' => $pop['icon'], - 'type' => $pop['type'], - 'classs' => $pop['classs'], - 'skill' => $pop['skillId'], - 'level' => $pop['level'] - ); - } - - $toFile = "var g_glyphs = "; - $toFile .= json_encode($glyphsOut, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK); - $toFile .= ";"; - $file = 'datasets/'.User::$localeString.'/glyphs'; - - $handle = fOpen($file, "w"); - fWrite($handle, $toFile); - fClose($handle); - - echo "done glyphs loc: ".$lId." in ".Util::execTime()."
\n"; - } - - echo "
\nall done"; - - Lang::load(Util::$localeStrings[LOCALE_EN]); - - $stats = DB::Aowow()->getStatistics(); - echo "
\n".$stats['count']." queries in: ".Util::formatTime($stats['time'] * 1000); -?> diff --git a/setup/tools/dataset/itemsets.php b/setup/tools/dataset/itemsets.php deleted file mode 100644 index 982bb3ff..00000000 --- a/setup/tools/dataset/itemsets.php +++ /dev/null @@ -1,141 +0,0 @@ -Select('SELECT * FROM ?_itemset ORDER BY refSetId DESC'); - $locales = [LOCALE_EN, LOCALE_FR, LOCALE_DE, LOCALE_ES, LOCALE_RU]; - $jsonBonus = []; - - // check directory-structure - foreach (Util::$localeStrings as $dir) - if (!is_dir('datasets/'.$dir)) - mkdir('datasets/'.$dir, 0755, true); - - echo "script set up in ".Util::execTime()."
\n"; - - foreach ($locales as $lId) - { - User::useLocale($lId); - Lang::load(Util::$localeStrings[$lId]); - - $itemsetOut = []; - foreach ($setList as $set) - { - set_time_limit(15); - - $setOut = array( - 'id' => $set['id'], - 'name' => (7 - $set['quality']).Util::jsEscape(Util::localizedString($set, 'name')), - 'pieces' => [], - 'heroic' => DB::Aowow()->SelectCell('SELECT IF (Flags & 0x8, "true", "false") FROM item_template WHERE entry = ?d', $set['item1']), - 'maxlevel' => $set['maxLevel'], - 'minlevel' => $set['minLevel'], - 'type' => $set['type'], - 'setbonus' => [] - ); - - if ($set['classMask']) - { - $setOut['reqclass'] = $set['classMask']; - $setOut['classes'] = []; - - for ($i = 0; $i < 12; $i++) - if ($set['classMask'] & (1 << ($i - 1))) - $setOut['classes'][] = $i; - } - - if ($set['contentGroup']) - $setOut['note'] = $set['contentGroup']; - - if ($set['id'] < 0) - $setOut['idbak'] = $set['refSetId']; - - for ($i = 1; $i < 11; $i++) - if ($set['item'.$i]) - $setOut['pieces'][] = $set['item'.$i]; - - for ($i = 1; $i < 9; $i++) - { - if (!$set['bonus'.$i] || !$set['spell'.$i]) - continue; - - // costy and locale-independant -> cache - if (!isset($jsonBonus[$set['spell'.$i]])) - $jsonBonus[$set['spell'.$i]] = (new SpellList(array(['s.id', (int)$set['spell'.$i]])))->getStatGain()[$set['spell'.$i]]; - - if (!isset($setOut['setbonus'][$set['bonus'.$i]])) - $setOut['setbonus'][$set['bonus'.$i]] = $jsonBonus[$set['spell'.$i]]; - else - foreach ($jsonBonus[$set['spell'.$i]] as $k => $v) - @$setOut['setbonus'][$set['bonus'.$i]][$k] += $v; - } - - foreach ($setOut['setbonus'] as $k => $v) - { - if (empty($v)) - unset($setOut['setbonus'][$k]); - else - { - foreach ($v as $sk => $sv) - { - if ($str = Util::$itemMods[$sk]) - { - $setOut['setbonus'][$k][$str] = $sv; - unset($setOut['setbonus'][$k][$sk]); - } - } - } - } - - if (empty($setOut['setbonus'])) - unset($setOut['setbonus']); - - $itemsetOut[$setOut['id']] = $setOut; - } - - $toFile = "var g_itemsets = "; - $toFile .= json_encode($itemsetOut, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK); - $toFile .= ";"; - $file = 'datasets/'.User::$localeString.'/itemsets'; - - $handle = fOpen($file, "w"); - fWrite($handle, $toFile); - fClose($handle); - - echo "done itemsets loc: ".$lId." in ".Util::execTime()."
\n"; - } - - echo "
\nall done"; - - Lang::load(Util::$localeStrings[LOCALE_EN]); - - $stats = DB::Aowow()->getStatistics(); - echo "
\n".$stats['count']." queries in: ".Util::formatTime($stats['time'] * 1000); -?> diff --git a/setup/tools/dataset/pets.php b/setup/tools/dataset/pets.php deleted file mode 100755 index 272ccf93..00000000 --- a/setup/tools/dataset/pets.php +++ /dev/null @@ -1,161 +0,0 @@ - isInZone; white => notInZone - // Since i'm lacking other options this will probably be reimplemented. - - /* Example data - 30: { - id:30, - name:'Forest Spider', - minlevel:5, - maxlevel:6, - location:[12], // master-AreaTableId's (?) - react:[-1,-1], - classification:0, // 0:"Normal", 1:"Elite", 2:"Rar Elite", 3:"Boss", 4:"Rar" - family:3, // creatureFamily - displayId:382, - skin:'TarantulaSkinOrange', - icon:'Ability_Hunter_Pet_Spider', // from creatureFamily.dbc - type:2 // 0:Ferocity, 1:Tenacity, 2:Cunning - }, - */ - - $petQuery = ' - SELECT - ct.entry AS id, - ct.name, - lc.*, - ct.minlevel, - ct.maxlevel, - CONCAT("[", ft.A, ", ", ft.H, "]") AS react, - ct.rank AS classification, - ct.family, - ct.modelId1 AS displayId, - cdi.skin1 AS skin, - SUBSTRING_INDEX(cf.iconFile, "\\\\", -1) AS icon, - cf.petTalentType AS type - FROM - creature_template ct - JOIN - ?_factiontemplate ft ON - ft.Id = ct.faction - JOIN - dbc.creaturefamily cf ON - cf.Id = ct.family - LEFT JOIN - locales_creature lc ON - lc.entry = ct.entry - JOIN - dbc.creaturedisplayinfo cdi ON - cdi.id = ct.modelId1 - WHERE - cf.petTalentType <> -1 AND - ct.type_flags & 0x1 - ORDER BY - ct.entry ASC; - '; - - $queryZones = ' - SELECT DISTINCT - z.id - FROM - creature c - JOIN - ?_zones z ON - z.xMin < c.position_x AND - z.xMax > c.position_x AND - z.yMin < c.position_y AND - z.yMax > c.position_y AND - z.mapId = c.map - WHERE - c.id = ?d; - '; - - $queryInstanceZone = ' - SELECT DISTINCT - z.id - FROM - creature c, - ?_zones z - WHERE - z.mapId = c.map AND - c.id = ?d; - '; - - $petList = DB::Aowow()->Select($petQuery); - $locales = [LOCALE_EN, LOCALE_FR, LOCALE_DE, LOCALE_ES, LOCALE_RU]; - $locations = []; - - // check directory-structure - foreach (Util::$localeStrings as $dir) - if (!is_dir('datasets/'.$dir)) - mkdir('datasets/'.$dir, 0755, true); - - echo "script set up in ".Util::execTime()."
\n"; - - foreach ($locales as $lId) - { - User::useLocale($lId); - Lang::load(Util::$localeStrings[$lId]); - - $petsOut = []; - foreach ($petList as $pet) - { - // get locations - // again: caching will save you time and nerves - if (!isset($locations[$pet['id']])) - { - $locations[$pet['id']] = DB::Aowow()->SelectCol($queryZones, $pet['id']); - - // probably instanced, map <=> areaId _should_ be bijective - if (empty($locations[$pet['id']])) - if ($z = DB::Aowow()->SelectCell($queryInstanceZone, $pet['id'])) - $locations[$pet['id']][] = $z; - } - - $petsOut[$pet['id']] = array( - 'id' => $pet['id'], - 'name' => Util::localizedString($pet, 'name'), - 'minlevel' => $pet['minlevel'], - 'maxlevel' => $pet['maxlevel'], - 'location' => $locations[$pet['id']], - 'react' => $pet['react'], - 'classification' => $pet['classification'], - 'family' => $pet['family'], - 'displayId' => $pet['displayId'], - 'skin' => $pet['skin'], - 'icon' => $pet['icon'], - 'type' => $pet['type'] - ); - } - - $toFile = "var g_pets = "; - $toFile .= json_encode($petsOut, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK); - $toFile .= ";"; - $file = 'datasets/'.User::$localeString.'/pets'; - - $handle = fOpen($file, "w"); - fWrite($handle, $toFile); - fClose($handle); - - echo "done pets loc: ".$lId." in ".Util::execTime()."
\n"; - } - - echo "
\nall done"; - - Lang::load(Util::$localeStrings[LOCALE_EN]); - - $stats = DB::Aowow()->getStatistics(); - echo "
\n".$stats['count']." queries in: ".Util::formatTime($stats['time'] * 1000); -?> diff --git a/setup/tools/dataset/profiler.php b/setup/tools/dataset/profiler.php deleted file mode 100644 index c2ac7d78..00000000 --- a/setup/tools/dataset/profiler.php +++ /dev/null @@ -1,328 +0,0 @@ -
\n\n"; - - /**********/ - /* Quests */ - /**********/ - { - $cnd = [ - 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($cnd); - - $_ = []; - $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]); - $handle = fOpen('datasets/'.User::$localeString.'/p-quests', "w"); - if (!$handle) - die('could not create quests file '.$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"; - - fWrite($handle, $buff); - fClose($handle); - - echo "done quests loc: ".$l." in ".Util::execTime()."
\n"; - } - - echo "
\n"; - } - - /****************/ - /* Achievements */ - /****************/ - { - set_time_limit(10); - - $cnd = array( - CFG_SQL_LIMIT_NONE, - [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], - [['flags', 1, '&'], 0], // no statistics - ); - $achievez = new AchievementList($cnd); - foreach ($locales as $l) - { - User::useLocale($l); - Lang::load(Util::$localeStrings[$l]); - $handle = fOpen('datasets/'.User::$localeString.'/p-achievements', "w"); - if (!$handle) - die('could not create achievements file '.$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"; - - fWrite($handle, $buff); - fClose($handle); - - echo "done achievements loc: ".$l." in ".Util::execTime()."
\n"; - } - - echo "
\n"; - } - - /**********/ - /* Titles */ - /**********/ - { - set_time_limit(10); - - $cnd = array( - CFG_SQL_LIMIT_NONE, - [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], - ); - $titlez = new TitleList($cnd); - foreach ($locales as $l) - { - foreach ([0, 1] as $g) // gender - { - User::useLocale($l); - Lang::load(Util::$localeStrings[$l]); - $handle = fOpen('datasets/'.User::$localeString.'/p-titles-'.$g, "w"); - if (!$handle) - die('could not create titles file '.$l.' '.$g); - - $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"; - } - fWrite($handle, $buff); - fClose($handle); - - echo "done titles loc: ".$l.", gender: ".$g." in ".Util::execTime()."
\n"; - } - } - - echo "
\n"; - } - - /**********/ - /* Mounts */ - /**********/ - { - set_time_limit(10); - - $cnd = array( - CFG_SQL_LIMIT_NONE, - [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], - ['typeCat', -5] - ); - $mountz = new SpellList($cnd); - foreach ($locales as $l) - { - User::useLocale($l); - Lang::load(Util::$localeStrings[$l]); - $handle = fOpen('datasets/'.User::$localeString.'/p-mounts', "w"); - if (!$handle) - die('could not create mounts file '.$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"; - } - - fWrite($handle, $buff); - fClose($handle); - - echo "done mounts loc: ".$l." in ".Util::execTime()."
\n"; - } - - echo "
\n"; - } - - /**************/ - /* Companions */ - /**************/ - { - set_time_limit(10); - - $cnd = array( - CFG_SQL_LIMIT_NONE, - [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], - ['typeCat', -6] - ); - $companionz = new SpellList($cnd); - foreach ($locales as $l) - { - User::useLocale($l); - Lang::load(Util::$localeStrings[$l]); - $handle = fOpen('datasets/'.User::$localeString.'/p-companions', "w"); - if (!$handle) - die('could not create companions file '.$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"; - } - - fWrite($handle, $buff); - fClose($handle); - - echo "done companions loc: ".$l." in ".Util::execTime()."
\n"; - } - - echo "
\n"; - } - - /************/ - /* Factions */ - /************/ - { - set_time_limit(10); - - // todo (med): exclude non-gaining reputation-header - $cnd = array( - CFG_SQL_LIMIT_NONE, - [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0] - ); - $factionz = new FactionList($cnd); - foreach ($locales as $l) - { - User::useLocale($l); - Lang::load(Util::$localeStrings[$l]); - $handle = fOpen('datasets/'.User::$localeString.'/p-factions', "w"); - if (!$handle) - die('could not create factions file '.$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"; - - fWrite($handle, $buff); - fClose($handle); - - echo "done factions loc: ".$l." in ".Util::execTime()."
\n"; - } - - echo "
\n"; - } - - /***********/ - /* Recipes */ - /***********/ - { - // special case: secondary skills are always requested, so put them in one single file (185, 129, 356); also it contains g_skill_order - $skills = [171, 164, 333, 202, 182, 773, 755, 165, 186, 393, 197, [185, 129, 356]]; - $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) - { - set_time_limit(20); - - $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) - { - 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) - { - echo " - file: ".$file." has no content => skipping
\n"; - continue; - } - - $handle = fOpen('datasets/'.User::$localeString.'/p-recipes-'.$file, "w"); - if (!$handle) - die('could not create '.$file.' file '.$l); - - $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"; - - fWrite($handle, $buff); - fClose($handle); - - echo "done ".$file." loc: ".$l." in ".Util::execTime()."
\n"; - } - } - - echo "
\n"; - } - - echo "
\nall done"; - - Lang::load(Util::$localeStrings[LOCALE_EN]); - - $stats = DB::Aowow()->getStatistics(); - echo "
\n".$stats['count']." queries in: ".Util::formatTime($stats['time'] * 1000); -?> diff --git a/setup/tools/dataset/realms.php b/setup/tools/dataset/realms.php deleted file mode 100644 index f9c4401f..00000000 --- a/setup/tools/dataset/realms.php +++ /dev/null @@ -1,120 +0,0 @@ - 'www.wowarmory.com', - eu => 'eu.wowarmory.com' - }; - */ - - /* Examples - 1 => { - name:'Eldre\'Thalas', - battlegroup:'Reckoning', - region:'us' - }, - - var mn_profiles = [ - ["us","US & Oceanic",,[ - ["bloodlust","Bloodlust",,[ - ["amanthul","Aman'Thul"], - ["barthilas","Barthilas"] - ]], - ["cyclone","Cyclone",,[ - ["azjol-nerub","Azjol-Nerub"], - ["bloodscalp","Bloodscalp"] - ]] - ]], - ["eu","Europe",,[ - ["blackout","Blackout",,[ - ["agamaggan","Agamaggan"], - ["aggramar","Aggramar"] - ]], - ["blutdurst","Blutdurst",,[ - ["aegwynn","Aegwynn"], - ["destromath","Destromath"] - ]] - ]] - ]; - */ - - function urlize($str) - { - $pairs = [ - "ß" => "ss", - "á" => "a", "ä" => "a", "à" => "a", "â" => "a", - "è" => "e", "ê" => "e", "é" => "e", "ë" => "e", - "í" => "i", "î" => "i", "ì" => "i", "ï" => "i", - "ñ" => "n", - "ò" => "o", "ó" => "o", "ö" => "o", "ô" => "o", - "ú" => "u", "ü" => "u", "û" => "u", "ù" => "u", - "œ" => "oe", - "Á" => "A", "Ä" => "A", "À" => "A", "Â" => "A", - "È" => "E", "Ê" => "E", "É" => "E", "Ë" => "E", - "Í" => "I", "Î" => "I", "Ì" => "I", "Ï" => "I", - "Ñ" => "N", - "Ò" => "O", "Ó" => "O", "Ö" => "O", "Ô" => "O", - "Ú" => "U", "Ü" => "U", "Û" => "U", "Ù" => "U", - "œ" => "Oe", - " " => "-" - ]; - - return preg_replace('/[^\d\w\-]/', '', strtr(strToLower($str), $pairs)); - } - - if (!file_exists('config/profile_all.js.in')) - die('profile_all source file is missing; cannot create realm file'); - - $menu = [ - ["us", "US & Oceanic", null,[ - [urlize(CFG_BATTLEGROUP), CFG_BATTLEGROUP, null, []] - ]], - ["eu", "Europe", null,[ - [urlize(CFG_BATTLEGROUP), CFG_BATTLEGROUP, null, []] - ]] - ]; - - $rows = DB::Auth()->select('SELECT id AS ARRAY_KEY, name, ? AS battlegroup, IF(timezone IN (8, 9, 10, 11, 12), "eu", "us") AS region FROM realmlist WHERE allowedSecurityLevel = 0', CFG_BATTLEGROUP); - $str = 'var g_realms = '.json_encode($rows, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE).';'; - - $handle = fOpen('datasets/realms', "w"); - fWrite($handle, $str); - fClose($handle); - - $set = 0x0; - foreach ($rows as $row) - { - if ($row['region'] == 'eu') - { - $set |= 0x1; - $menu[1][3][0][3][] = [urlize($row['name']),$row['name']]; - } - else if ($row['region'] == 'us') - { - $set |= 0x2; - $menu[0][3][0][3][] = [urlize($row['name']),$row['name']]; - } - } - - if (!($set & 0x1)) - array_pop($menu); - - if (!($set & 0x2)) - array_shift($menu); - - $file = file_get_contents('config/profile_all.js.in'); - $dest = fOpen('template/js/profile_all.js', "w"); - - fWrite($dest, str_replace('[/*setup:realms*/]', json_encode($menu, JSON_UNESCAPED_UNICODE), $file)); - fClose($dest); - - echo 'all done'; -?> diff --git a/setup/tools/dataset/statistics.php b/setup/tools/dataset/statistics.php deleted file mode 100755 index 6bc056e2..00000000 --- a/setup/tools/dataset/statistics.php +++ /dev/null @@ -1,140 +0,0 @@ - [[-20, 2, 0, 3], [-10, 0, 1, 1], null, 0.9560, 3.6640, 88.129021, 5, 47.003525, 5, 0, 0], - 2 => [[-20, 2, 0, 3], [-10, 0, 1, 0], null, 0.9560, 3.4943, 88.129021, 5, 47.003525, 5, 0, 0], - 3 => [[-20, 1, 1, 2], [-10, 0, 2, 2], null, 0.9880, -4.0873, 145.560408, 5, 145.560408, 0, 0, 0], - 4 => [[-20, 1, 1, 2], [-10, 0, 1, 1], null, 0.9880, 2.0957, 145.560408, 5, 145.560408, 0, 0, 0], - 5 => [[-10, 1, 0, 0], [-10, 0, 1, 0], null, 0.9830, 3.4178, 150.375940, 0, 0.0, 0, 0, 0], - 6 => [[-20, 2, 0, 3], [-10, 0, 1, 0], null, 0.9560, 3.6640, 88.129021, 5, 47.003525, 0, 0, ['parryrtng' => [0.25, 'percentOf', 'str']]], // Forcefull Deflection (49410) - 7 => [[-20, 1, 1, 2], [-10, 0, 1, 0], null, 0.9880, 2.1080, 145.560408, 0, 145.560408, 5, 0, 0], - 8 => [[-10, 1, 0, 0], [-10, 0, 1, 0], null, 0.9830, 3.6587, 150.375940, 0, 0.0, 0, 0, 0], - 9 => [[-10, 1, 0, 0], [-10, 0, 1, 0], null, 0.9830, 2.4211, 150.375940, 0, 0.0, 0, 0, 0], - 11 => [[-20, 2, 0, 0], [-10, 0, 1, 0], null, 0.9720, 5.6097, 116.890707, 0, 0.0, 0, 0, 0] - ); - - foreach ($dataz as $class => &$data) - $data[2] = array_values(DB::Aowow()->selectRow('SELECT mle.chance*100 cMle, spl.chance*100 cSpl FROM dbc.gtchancetomeleecritbase mle, dbc.gtchancetospellcritbase spl WHERE mle.idx = spl.idx AND mle.idx = ?d', $class - 1)); - - return $dataz; - } - - function race() - { - // { str, agi, sta, int, spi, hp, mana, directMod1, directMod2 } - - return array( - 1 => [20, 20, 20, 20, 20, 0, ['spi' => [0.05, 'percentOf', 'spi']]], // The Human Spirit (20598) - 2 => [23, 17, 22, 17, 23, 0, 0], - 3 => [22, 16, 23, 19, 19, 0, 0], - 4 => [17, 25, 19, 20, 20, 0, 0], - 5 => [19, 18, 21, 18, 25, 0, 0], - 6 => [25, 15, 22, 15, 22, 0, ['health' => [0.05, 'functionOf', '$function(p) { return g_statistics.combo[p.classs][p.level][5]; }']]], // Endurance (20550) ... if you are looking for something elegant, look away! - 7 => [15, 23, 19, 24, 20, 0, ['int' => [0.05, 'percentOf', 'int']]], // Expansive Mind (20591) - 8 => [21, 22, 21, 16, 21, 0, ['healthrgn' => [0.1, 'percentOf', 'healthrgn']]], // Regeneration (20555) - 10 => [17, 22, 18, 24, 19, 0, 0], - 11 => [21, 17, 19, 21, 22, 0, 0] // ['mlehitpct' => [1, 'add'], 'splhitpct' => [1, 'add'], 'rgdhitpct' => [1, 'add']] // Heroic Presence (6562, 28878) (not actually shown..?) - ); - } - - function combo() - { - $result = []; - $critToDodge = array( - 1 => 0.85/1.15, 2 => 1.00/1.15, 3 => 1.11/1.15, - 4 => 2.00/1.15, 5 => 1.00/1.15, 6 => 0.85/1.15, - 7 => 1.60/1.15, 8 => 1.00/1.15, 9 => 0.97/1.15, 11 => 2.00/1.15 - ); - - // TrinityCore claims, DodgePerAgi per level and class can be constituted from critPerAgi (and level (and class)) - // who am i to argue - // rebase stats to a specific race. chosen human as all stats are 20 - // level:{ str, agi, sta, int, spi, hp, mana, mleCrt%Agi, splCrt%Int, dodge%Agi, HealthRegenModToBaseStat, HealthRegenModToBonusStat } - - foreach ($critToDodge as $class => $mod) - { - // humans can't be hunter, shaman, druids (use tauren here) - if (in_array($class, [3, 7, 11])) - $offset = [25, 15, 22, 15, 22]; - else - $offset = [20, 20, 20, 20, 20]; - - $rows = DB::Aowow()->select('SELECT pls.level AS ARRAY_KEY, str-?d, agi-?d, sta-?d, inte-?d, spi-?d, basehp, IF(basemana <> 0, basemana, 100), mlecrt.chance*100, splcrt.chance*100, mlecrt.chance*100 * ?f, baseHP5.ratio*1, extraHP5.ratio*1 ' . - 'FROM player_levelstats pls JOIN player_classlevelstats pcls ON pls.level = pcls.level AND pls.class = pcls.class JOIN' . - ' dbc.gtchancetomeleecrit mlecrt ON mlecrt.idx = ((pls.class - 1) * 100) + (pls.level - 1) JOIN' . - ' dbc.gtchancetospellcrit splcrt ON splcrt.idx = ((pls.class - 1) * 100) + (pls.level - 1) JOIN' . - ' dbc.gtoctregenhp baseHP5 ON baseHP5.idx = ((pls.class - 1) * 100) + (pls.level - 1) JOIN' . - ' dbc.gtregenhpperspt extraHP5 ON extraHP5.idx = ((pls.class - 1) * 100) + (pls.level - 1) ' . - 'WHERE pls.race = ?d AND pls.class = ?d ORDER BY pls.level ASC', - $offset[0], $offset[1], $offset[2], $offset[3], $offset[4], - $mod, - in_array($class, [3, 7, 11]) ? 6 : 1, - $class - ); - - $result[$class] = []; - foreach ($rows as $k => $row) - $result[$class][$k] = array_values($row); - } - - return $result; - } - - function level() - { - // base mana regeneration per level - // identical across classes (just use one, that acutally has mana (offset: 100)) - // content of gtRegenMPPerSpt.dbc - - return DB::Aowow()->selectCol('SELECT idx-99 AS ARRAY_KEY, ratio FROM dbc.gtregenmpperspt WHERE idx >= 100 AND idx < 100 + ?d', MAX_LEVEL); - } - - function skills() - { - // profession perks (skinning => +crit, mining => +stam) and maybe some others; skillId:{rankNo:someJSON, ..}? - - return []; - } - - // todo: x - $sub = ['classs', 'race', 'combo', 'level', 'skills']; - $out = []; - - foreach($sub as $s) - $out[$s] = $s(); - - $json = json_encode($out, JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); - $json = preg_replace('/"\$([^$"]+)"/', '\1', $json); - - $handle = fOpen('datasets/statistics', "w"); - fWrite($handle, 'g_statistics = '.$json.';'); - fClose($handle); - - echo 'all done'; -?> \ No newline at end of file diff --git a/setup/tools/dataset/talent-icons.php b/setup/tools/dataset/talent-icons.php deleted file mode 100644 index fa4e33a2..00000000 --- a/setup/tools/dataset/talent-icons.php +++ /dev/null @@ -1,80 +0,0 @@ -\n"; - - foreach ($filenames as $k => $v) - { - if (!$v) - continue; - - set_time_limit(10); - - for ($tree = 0; $tree < 3; $tree++) - { - $what = $k ? 'classMask' : 'creatureFamilyMask'; - $set = $k ? 1 << ($k - 1) : 1 << $tree; - $subset = $k ? $tree : 0; - $path = $k ? 'talents/icons' : 'hunterpettalents'; - - $icons = DB::Aowow()->SelectCol($query, $what, $set, $subset); - - if (empty($icons)) - die('error: query for '.$v.' tree: '.$k.' empty'); - - $res = imageCreateTrueColor(count($icons) * $dims, 2 * $dims); - - for($i = 0; $i < count($icons); $i++) - { - $im = @imagecreatefromjpeg('static/images/wow/icons/medium/'.strtolower($icons[$i]).'.jpg'); - if(!$im) - die('error: raw image '.$icons[$i]. ' not found'); - - // colored - imagecopymerge($res, $im, $i * $dims, 0, 0, 0, imageSX($im), imageSY($im), 100); - - // grayscale - if (imageistruecolor($im)) - imagetruecolortopalette($im, false, 256); - - for ($j = 0; $j < imagecolorstotal($im); $j++) - { - $color = imagecolorsforindex($im, $j); - $gray = round(0.299 * $color['red'] + 0.587 * $color['green'] + 0.114 * $color['blue']); - imagecolorset($im, $j, $gray, $gray, $gray); - } - imagecopymerge($res, $im, $i * $dims, $dims, 0, 0, imageSX($im), imageSY($im), 100); - - if (@!imagejpeg($res, 'static/images/wow/'.$path.'/'.$v.'_'.($tree + 1).'.jpg')) - die('error: '.$v.'_'.($tree + 1).'.jpg could not be written!'); - } - } - - echo "textures for ".($k ? ucFirst($v) : "Pet")." done in ".Util::execTime()."
\n"; - } - - echo "
\nall done"; - - $stats = DB::Aowow()->getStatistics(); - echo "
\n".$stats['count']." queries in: ".Util::formatTime($stats['time'] * 1000); - -?> diff --git a/setup/tools/dataset/talents.php b/setup/tools/dataset/talents.php deleted file mode 100644 index 67bf4239..00000000 --- a/setup/tools/dataset/talents.php +++ /dev/null @@ -1,236 +0,0 @@ -select(' - SELECT - * - FROM - dbc.talenttab - WHERE - classMask = ?d - ORDER BY - `tabNumber`, `creatureFamilyMask`', - $mask - ); - - $result = []; - - for ($l = 0; $l < count($tabs); $l++) - { - $talents = DB::Aowow()->select(' - SELECT - t.id AS tId, - t.*, - s.* - FROM - dbc.talent t, - ?_spell s - WHERE - t.`tabId`= ?d AND - s.`Id` = t.`rank1` - ORDER by t.`row`, t.`column` - ', - $tabs[$l]['Id'] - ); - - $result[$l] = array( - 'n' => Util::localizedString($tabs[$l], 'name'), - 't' => [] - ); - - if (!$class) - { - $petFamId = log($tabs[$l]['creatureFamilyMask'], 2); - $result[$l]['icon'] = $petFamIcons[$petFamId]; - $petCategories = DB::Aowow()->SelectCol('SELECT Id AS ARRAY_KEY, category FROM ?_pet WHERE type = ?d', $petFamId); - $result[$l]['f'] = array_keys($petCategories); - } - - // talent dependencies go here - $depLinks = []; - $tNums = []; - - for($j = 0; $j < count($talents); $j++) - { - $tNums[$talents[$j]['tId']] = $j; - - $d = []; - $s = []; - $i = $talents[$j]['tId']; - $n = Util::localizedString($talents[$j], 'name'); - $x = $talents[$j]['column']; - $y = $talents[$j]['row']; - $r = null; - $t = []; - $icon = $talents[$j]['iconString']; - $m = $talents[$j]['rank2'] == 0 ? 1 : ( - $talents[$j]['rank3'] == 0 ? 2 : ( - $talents[$j]['rank4'] == 0 ? 3 : ( - $talents[$j]['rank5'] == 0 ? 4 : 5 - ) - ) - ); - - // duplet handling - $f = []; - foreach ($petCategories as $k => $v) - { - // cant handle 64bit integer .. split - if ($v >= 32 && ((1 << ($v - 32)) & $talents[$j]['petCategory2'])) - $f[] = $k; - else if ($v < 32 && ((1 << $v) & $talents[$j]['petCategory1'])) - $f[] = $k; - } - - for ($k = 0; $k <= ($m - 1); $k++) - { - if (!$tSpells->getEntry($talents[$j]['rank'.($k + 1)])) - continue; - - $d[] = $tSpells->parseText()[0]; - $s[] = $talents[$j]['rank'.($k + 1)]; - - if ($talents[$j]['talentSpell']) - $t[] = $tSpells->getTalentHeadForCurrent(); - } - - if ($talents[$j]['reqTalent']) - { - // we didn't encounter the required talent yet => create reference - if (!isset($tNums[$talents[$j]['reqTalent']])) - $depLinks[$talents[$j]['reqTalent']] = $j; - - $r = @[$tNums[$talents[$j]['reqTalent']], $talents[$j]['reqRank'] + 1]; - } - - $result[$l]['t'][$j] = array( - 'i' => $i, - 'n' => $n, - 'm' => $m, - 'd' => $d, - 's' => $s, - 'x' => $x, - 'y' => $y, - ); - - if (isset($r)) - $result[$l]['t'][$j]['r'] = $r; - - if (!empty($t)) - $result[$l]['t'][$j]['t'] = $t; - - if (!empty($f)) - $result[$l]['t'][$j]['f'] = $f; - - if ($class) - $result[$l]['t'][$j]['iconname'] = $icon; - - // If this talent is a reference, add it to the array of talent dependencies - if (isset($depLinks[$talents[$j]['tId']])) - { - $result[$l]['t'][$depLinks[$talents[$j]['tId']]]['r'][0] = $j; - unset($depLinks[$talents[$j]['tId']]); - } - } - - // Remove all dependencies for which the talent has not been found - foreach ($depLinks as $dep_link) - unset($result[$l]['t'][$dep_link]['r']); - } - - return $result; - }; - - $classes = [CLASS_WARRIOR, CLASS_PALADIN, CLASS_HUNTER, CLASS_ROGUE, CLASS_PRIEST, CLASS_DEATHKNIGHT, CLASS_SHAMAN, CLASS_MAGE, CLASS_WARLOCK, CLASS_DRUID]; - $locales = [LOCALE_EN, LOCALE_FR, LOCALE_DE, LOCALE_ES, LOCALE_RU]; - // my neighbour is noisy as fuck and my head hurts, so .. - $petFamIcons = ['Ability_Druid_KingoftheJungle', 'Ability_Druid_DemoralizingRoar', 'Ability_EyeOfTheOwl']; // .. i've no idea where to fetch these from - $petIcons = ''; - - // check directory-structure - foreach (Util::$localeStrings as $dir) - if (!is_dir('datasets/'.$dir)) - mkdir('datasets/'.$dir, 0755, true); - - $tSpellIds = DB::Aowow()->selectCol('SELECT rank1 FROM dbc.talent UNION SELECT rank2 FROM dbc.talent UNION SELECT rank3 FROM dbc.talent UNION SELECT rank4 FROM dbc.talent UNION SELECT rank5 FROM dbc.talent'); - $tSpells = new SpellList(array(['s.id', $tSpellIds], CFG_SQL_LIMIT_NONE)); - - echo "script set up in ".Util::execTime()."
\n"; - - foreach ($locales as $lId) - { - User::useLocale($lId); - Lang::load(Util::$localeStrings[$lId]); - - // TalentCalc - foreach ($classes as $cMask) - { - set_time_limit(20); - - $cId = log($cMask, 2) + 1; - $file = 'datasets/'.User::$localeString.'/talents-'.$cId; - $toFile = '$WowheadTalentCalculator.registerClass('.$cId.', '.json_encode($buildTree($cId), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK).')'; - - $handle = fOpen($file, "w"); - fWrite($handle, $toFile); - fClose($handle); - - echo "done class: ".$cId." loc: ".$lId." in ".Util::execTime()."
\n"; - } - - // PetCalc - if (empty($petIcons)) - { - $pets = DB::Aowow()->SelectCol('SELECT Id AS ARRAY_KEY, iconString FROM ?_pet'); - $petIcons = json_encode($pets, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK); - } - - $toFile = "var g_pet_icons = ".$petIcons."\n\n"; - $toFile .= 'var g_pet_talents = '.json_encode($buildTree(0), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK); - $file = 'datasets/'.User::$localeString.'/pet-talents'; - - $handle = fOpen($file, "w"); - fWrite($handle, $toFile); - fClose($handle); - - echo "done pets loc: ".$lId." in ".Util::execTime()."
\n"; - } - - echo "
\nall done"; - - Lang::load(Util::$localeStrings[LOCALE_EN]); - - $stats = DB::Aowow()->getStatistics(); - echo "
\n".$stats['count']." queries in: ".Util::formatTime($stats['time'] * 1000); -?> diff --git a/setup/tools/filegen/enchants.func.php b/setup/tools/filegen/enchants.func.php new file mode 100644 index 00000000..2974a393 --- /dev/null +++ b/setup/tools/filegen/enchants.func.php @@ -0,0 +1,224 @@ +iterate() as $__) + $enchIds[] = $enchantSpells->getField('effect1MiscValue'); + + $enchMisc = []; + $enchJSON = Util::parseItemEnchantment($enchIds, false, $enchMisc); + + foreach ($locales as $lId) + { + set_time_limit(120); + + User::useLocale($lId); + Lang::load(Util::$localeStrings[$lId]); + + $enchantsOut = []; + foreach ($enchantSpells->iterate() as $__) + { + // slots have to be recalculated + $slot = 0; + if ($enchantSpells->getField('equippedItemClass') == 4) // armor + { + if ($invType = $enchantSpells->getField('equippedItemInventoryTypeMask')) + $slot = $invType >> 1; + else /* if (equippedItemSubClassMask == 64) */ // shields have it their own way <_< + $slot = (1 << (14 - 1)); + } + else if ($enchantSpells->getField('equippedItemClass') == 2) // weapon + { + foreach ($slotPointer as $i => $sp) + { + if (!$sp) + continue; + + if ((1 << $i) & $enchantSpells->getField('equippedItemSubClassMask')) + { + if ($sp == 13) // also mainHand & offHand *siiigh* + $slot |= ((1 << (21 - 1)) | (1 << (22 - 1))); + + $slot |= (1 << ($sp - 1)); + } + } + } + + $eId = $enchantSpells->getField('effect1MiscValue'); + + // defaults + $ench = array( + 'name' => [], // set by skill or item + 'quality' => -1, // modified if item + 'icon' => strToLower($enchantSpells->getField('iconString')), // item over spell + 'source' => [], // <0: item; >0:spell + 'skill' => -1, // modified if skill + 'slots' => [], // determined per spell but set per item + 'enchantment' => Util::localizedString($enchMisc[$eId]['text'], 'text'), + 'jsonequip' => @$enchJSON[$eId] ?: [], + 'temp' => 0, // always 0 + 'classes' => 0, // modified by item + ); + + if (isset($enchMisc[$eId]['reqskill'])) + $ench['jsonequip']['reqskill'] = $enchMisc[$eId]['reqskill']; + + if (isset($enchMisc[$eId]['reqskillrank'])) + $ench['jsonequip']['reqskill'] = $enchMisc[$eId]['reqskillrank']; + + if (isset($enchMisc[$eId]['requiredLevel'])) + $ench['jsonequip']['requiredLevel'] = $enchMisc[$eId]['requiredLevel']; + + // check if the spell has an entry in skill_line_ability -> Source:Profession + if ($skill = DB::Aowow()->SelectCell('SELECT skillLineId FROM dbc.skilllineability WHERE spellId = ?d', $enchantSpells->id)) + { + $ench['name'][] = $enchantSpells->getField('name', true); + $ench['source'][] = $enchantSpells->id; + $ench['skill'] = $skill; + $ench['slots'][] = $slot; + } + + // check if this spell can be cast via item -> Source:Item + if (!isset($castItems[$enchantSpells->id])) + $castItems[$enchantSpells->id] = new ItemList([['spellId1', $enchantSpells->id], ['name_loc0', 'Scroll of Enchant%', '!']]); // do not reuse enchantment scrolls + + $cI = &$castItems[$enchantSpells->id]; // this construct is a bit .. unwieldy + foreach ($cI->iterate() as $__) + { + $ench['name'][] = $cI->getField('name', true); + $ench['source'][] = -$cI->id; + $ench['icon'] = strTolower($cI->getField('iconString')); + $ench['slots'][] = $slot; + + if ($cI->getField('quality') > $ench['quality']) + $ench['quality'] = $cI->getField('quality'); + + if ($cI->getField('requiredClass') > 0) + { + $ench['classes'] = $cI->getField('requiredClass'); + $ench['jsonequip']['classes'] = $cI->getField('requiredClass'); + } + + if (!isset($ench['jsonequip']['reqlevel'])) + if ($cI->getField('requiredLevel') > 0) + $ench['jsonequip']['reqlevel'] = $cI->getField('requiredLevel'); + } + + // enchant spell not in use + if (empty($ench['source'])) + continue; + + // everything gathered + if (isset($enchantsOut[$eId])) // already found, append data + { + foreach ($enchantsOut[$eId] as $k => $v) + { + if (is_array($v)) + { + while ($pop = array_pop($ench[$k])) + $enchantsOut[$eId][$k][] = $pop; + } + else + { + if ($k == 'quality') // quality:-1 if spells and items are mixed + { + if ($enchantsOut[$eId]['source'][0] > 0 && $ench['source'][0] < 0) + $enchantsOut[$eId][$k] = -1; + else if ($enchantsOut[$eId]['source'][0] < 0 && $ench['source'][0] > 0) + $enchantsOut[$eId][$k] = -1; + else + $enchantsOut[$eId][$k] = $ench[$k]; + } + else if ($enchantsOut[$eId][$k] <= 0) + $enchantsOut[$eId][$k] = $ench[$k]; + } + } + } + else // nothing yet, create new + $enchantsOut[$eId] = $ench; + } + + // walk over each entry and strip single-item arrays + foreach ($enchantsOut as &$ench) + foreach ($ench as $k => $v) + if (is_array($v) && count($v) == 1 && $k != 'jsonequip') + $ench[$k] = $v[0]; + + $toFile = "var g_enchants = "; + $toFile .= json_encode($enchantsOut, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK); + $toFile .= ";"; + $file = 'datasets/'.User::$localeString.'/enchants'; + + if (!writeFile($file, $toFile, $log)) + $success = false; + } + + return $successs; + } + +?> diff --git a/setup/tools/filegen/gems.func.php b/setup/tools/filegen/gems.func.php new file mode 100644 index 00000000..b9a5141d --- /dev/null +++ b/setup/tools/filegen/gems.func.php @@ -0,0 +1,91 @@ +Select( + 'SELECT it.entry AS itemId, + it.name, + li.*, + IF (it.entry < 36000 OR it.ItemLevel < 70, 1 , 2) AS expansion, + it.Quality AS quality, + i.inventoryicon1 AS icon, + gp.spellItemEnchantmentId AS enchId, + gp.colorMask AS colors + FROM item_template it + LEFT JOIN locales_item li ON li.entry = it.entry + JOIN dbc.gemproperties gp ON gp.Id = it.GemProperties + JOIN dbc.itemdisplayinfo i ON i.Id = it.displayid + WHERE it.GemProperties <> 0 + ORDER BY it.entry DESC'); + $success = true; + + + // check directory-structure + foreach (Util::$localeStrings as $dir) + if (!writeDir('datasets/'.$dir, $log)) + $success = false; + + $enchIds = []; + foreach ($gems as $pop) + $enchIds[] = $pop['enchId']; + + $enchMisc = []; + $enchJSON = Util::parseItemEnchantment($enchIds, false, $enchMisc); + + foreach ($locales as $lId) + { + set_time_limit(5); + + User::useLocale($lId); + Lang::load(Util::$localeStrings[$lId]); + + $gemsOut = []; + foreach ($gems as $pop) + { + $gemsOut[$pop['itemId']] = array( + 'name' => Util::localizedString($pop, 'name'), + 'quality' => $pop['quality'], + 'icon' => strToLower($pop['icon']), + 'enchantment' => Util::localizedString(@$enchMisc[$pop['enchId']]['text'] ?: [], 'text'), + 'jsonequip' => @$enchJSON[$pop['enchId']] ?: [], + 'colors' => $pop['colors'], + 'expansion' => $pop['expansion'] + ); + } + + $toFile = "var g_gems = "; + $toFile .= json_encode($gemsOut, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK); + $toFile .= ";"; + $file = 'datasets/'.User::$localeString.'/gems'; + + if (!writeFile($file, $toFile, $log)) + $success = false; + } + + return $success; + } + +?> diff --git a/setup/tools/filegen/glyphs.func.php b/setup/tools/filegen/glyphs.func.php new file mode 100644 index 00000000..a75a81d0 --- /dev/null +++ b/setup/tools/filegen/glyphs.func.php @@ -0,0 +1,90 @@ +Select( + 'SELECT i.id AS itemId, + i.*, + IF (g.typeFlags & 0x1, 2, 1) AS type, + i.subclass AS classs, + i.requiredLevel AS level, + s1.Id AS glyphSpell, + s1.iconStringAlt AS icon, + s1.skillLine1 AS skillId, + s2.Id AS glyphEffect, + s2.Id AS ARRAY_KEY + FROM ?_items i + JOIN ?_spell s1 ON s1.Id = i.spellid1 + JOIN ?_glyphproperties g ON g.Id = s1.effect1MiscValue + JOIN ?_spell s2 ON s2.Id = g.spellId + WHERE i.classBak = 16'); + + // check directory-structure + foreach (Util::$localeStrings as $dir) + if (!writeDir('datasets/'.$dir, $log)) + $success = false; + + $glyphSpells = new SpellList(array(['s.id', array_keys($glyphList)], CFG_SQL_LIMIT_NONE)); + + foreach ($locales as $lId) + { + set_time_limit(30); + + User::useLocale($lId); + Lang::load(Util::$localeStrings[$lId]); + + $glyphsOut = []; + foreach ($glyphSpells->iterate() as $__) + { + $pop = $glyphList[$glyphSpells->id]; + + if (!$pop['glyphEffect']) + continue; + + if ($glyphSpells->getField('effect1Id') != 6 && $glyphSpells->getField('effect2Id') != 6 && $glyphSpells->getField('effect3Id') != 6) + continue; + + $glyphsOut[$pop['itemId']] = array( + 'name' => Util::localizedString($pop, 'name'), + 'description' => $glyphSpells->parseText()[0], + 'icon' => $pop['icon'], + 'type' => $pop['type'], + 'classs' => $pop['classs'], + 'skill' => $pop['skillId'], + 'level' => $pop['level'] + ); + } + + $toFile = "var g_glyphs = "; + $toFile .= json_encode($glyphsOut, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK); + $toFile .= ";"; + $file = 'datasets/'.User::$localeString.'/glyphs'; + + if (!writeFile($file, $toFile, $log)) + $success = false; + } + + return $success; + } +?> diff --git a/setup/tools/filegen/itemsets.func.php b/setup/tools/filegen/itemsets.func.php new file mode 100644 index 00000000..6da11853 --- /dev/null +++ b/setup/tools/filegen/itemsets.func.php @@ -0,0 +1,134 @@ +Select('SELECT * FROM ?_itemset ORDER BY refSetId DESC'); + $jsonBonus = []; + + // check directory-structure + foreach (Util::$localeStrings as $dir) + if (!writeDir('datasets/'.$dir, $log)) + $success = false; + + foreach ($locales as $lId) + { + User::useLocale($lId); + Lang::load(Util::$localeStrings[$lId]); + + $itemsetOut = []; + foreach ($setList as $set) + { + set_time_limit(15); + + $setOut = array( + 'id' => $set['id'], + 'name' => (7 - $set['quality']).Util::jsEscape(Util::localizedString($set, 'name')), + 'pieces' => [], + 'heroic' => DB::Aowow()->SelectCell('SELECT IF (Flags & 0x8, "true", "false") FROM item_template WHERE entry = ?d', $set['item1']), + 'maxlevel' => $set['maxLevel'], + 'minlevel' => $set['minLevel'], + 'type' => $set['type'], + 'setbonus' => [] + ); + + if ($set['classMask']) + { + $setOut['reqclass'] = $set['classMask']; + $setOut['classes'] = []; + + for ($i = 0; $i < 12; $i++) + if ($set['classMask'] & (1 << ($i - 1))) + $setOut['classes'][] = $i; + } + + if ($set['contentGroup']) + $setOut['note'] = $set['contentGroup']; + + if ($set['id'] < 0) + $setOut['idbak'] = $set['refSetId']; + + for ($i = 1; $i < 11; $i++) + if ($set['item'.$i]) + $setOut['pieces'][] = $set['item'.$i]; + + for ($i = 1; $i < 9; $i++) + { + if (!$set['bonus'.$i] || !$set['spell'.$i]) + continue; + + // costy and locale-independant -> cache + if (!isset($jsonBonus[$set['spell'.$i]])) + $jsonBonus[$set['spell'.$i]] = (new SpellList(array(['s.id', (int)$set['spell'.$i]])))->getStatGain()[$set['spell'.$i]]; + + if (!isset($setOut['setbonus'][$set['bonus'.$i]])) + $setOut['setbonus'][$set['bonus'.$i]] = $jsonBonus[$set['spell'.$i]]; + else + foreach ($jsonBonus[$set['spell'.$i]] as $k => $v) + @$setOut['setbonus'][$set['bonus'.$i]][$k] += $v; + } + + foreach ($setOut['setbonus'] as $k => $v) + { + if (empty($v)) + unset($setOut['setbonus'][$k]); + else + { + foreach ($v as $sk => $sv) + { + if ($str = Util::$itemMods[$sk]) + { + $setOut['setbonus'][$k][$str] = $sv; + unset($setOut['setbonus'][$k][$sk]); + } + } + } + } + + if (empty($setOut['setbonus'])) + unset($setOut['setbonus']); + + $itemsetOut[$setOut['id']] = $setOut; + } + + $toFile = "var g_itemsets = "; + $toFile .= json_encode($itemsetOut, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK); + $toFile .= ";"; + $file = 'datasets/'.User::$localeString.'/itemsets'; + + if (!writeFile($file, $toFile, $log)) + $success = false; + } + + return $success; + } +?> diff --git a/setup/tools/filegen/locales.func.php b/setup/tools/filegen/locales.func.php new file mode 100644 index 00000000..1ce9f2d7 --- /dev/null +++ b/setup/tools/filegen/locales.func.php @@ -0,0 +1,53 @@ + " 0: { // English\r\n" . + " id: LOCALE_ENUS,\r\n" . + " name: 'enus',\r\n" . + " domain: 'www',\r\n" . + " description: 'English'\r\n" . + " }", + LOCALE_FR => " 2: { // French\r\n" . + " id: LOCALE_FRFR,\r\n" . + " name: 'frfr',\r\n" . + " domain: 'fr',\r\n" . + " description: 'Fran' + String.fromCharCode(231) + 'ais'\r\n" . + " }", + LOCALE_DE => " 3: { // German\r\n" . + " id: LOCALE_DEDE,\r\n" . + " name: 'dede',\r\n" . + " domain: 'de',\r\n" . + " description: 'Deutsch'\r\n" . + " }", + LOCALE_ES => " 6: { // Spanish\r\n" . + " id: LOCALE_ESES,\r\n" . + " name: 'eses',\r\n" . + " domain: 'es',\r\n" . + " description: 'Espa' + String.fromCharCode(241) + 'ol'\r\n" . + " }", + LOCALE_RU => " 8: { // Russian\r\n" . + " id: LOCALE_RURU,\r\n" . + " name: 'ruru',\r\n" . + " domain: 'ru',\r\n" . + " description: String.fromCharCode(1056, 1091, 1089, 1089, 1082, 1080, 1081)\r\n" . + " }", + ); + + foreach ($locales as $l) + if (isset($available[$l])) + $result[] = $available[$l]; + + return implode(",\r\n", $result); + } + +?> diff --git a/setup/tools/filegen/mnProfiles.func.php b/setup/tools/filegen/mnProfiles.func.php new file mode 100644 index 00000000..8e68a3c4 --- /dev/null +++ b/setup/tools/filegen/mnProfiles.func.php @@ -0,0 +1,73 @@ +select('SELECT name, IF(timezone IN (8, 9, 10, 11, 12), "eu", "us") AS region FROM realmlist WHERE allowedSecurityLevel = 0'); + $set = 0x0; + + foreach ($rows as $row) + { + if ($row['region'] == 'eu') + { + $set |= 0x1; + $menu[1][3][0][3][] = [Util::urlize($row['name']),$row['name']]; + } + else if ($row['region'] == 'us') + { + $set |= 0x2; + $menu[0][3][0][3][] = [Util::urlize($row['name']),$row['name']]; + } + } + + if (!($set & 0x1)) + array_pop($menu); + + if (!($set & 0x2)) + array_shift($menu); + + return json_encode($menu, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); +} + +?> diff --git a/setup/tools/filegen/pets.func.php b/setup/tools/filegen/pets.func.php new file mode 100644 index 00000000..6df1e67c --- /dev/null +++ b/setup/tools/filegen/pets.func.php @@ -0,0 +1,119 @@ + isInZone; white => notInZone + // Since i'm lacking other options this will probably be reimplemented. + + /* Example data + 30: { + id:30, + name:'Forest Spider', + minlevel:5, + maxlevel:6, + location:[12], // master-AreaTableId's (?) + react:[-1,-1], + classification:0, // 0:"Normal", 1:"Elite", 2:"Rar Elite", 3:"Boss", 4:"Rar" + family:3, // creatureFamily + displayId:382, + skin:'TarantulaSkinOrange', + icon:'Ability_Hunter_Pet_Spider', // from creatureFamily.dbc + type:2 // 0:Ferocity, 1:Tenacity, 2:Cunning + }, + */ + + function pets(&$log, $locales) + { + $success = true; + $locations = []; + $qZones = 'SELECT DISTINCT z.id + FROM creature c + JOIN ?_zones z ON z.xMin < c.position_x AND z.xMax > c.position_x AND z.yMin < c.position_y AND z.yMax > c.position_y AND z.mapId = c.map + WHERE c.id = ?d'; + $qInstances = 'SELECT DISTINCT z.id + FROM creature c, ?_zones z + WHERE z.mapId = c.map AND c.id = ?d'; + + $petList = DB::Aowow()->Select( + 'SELECT ct.entry AS id, + ct.name, + lc.*, + ct.minlevel, + ct.maxlevel, + CONCAT("[", ft.A, ", ", ft.H, "]") AS react, + ct.rank AS classification, + ct.family, + ct.modelId1 AS displayId, + cdi.skin1 AS skin, + SUBSTRING_INDEX(cf.iconFile, "\\\\", -1) AS icon, + cf.petTalentType AS type + FROM creature_template ct + JOIN ?_factiontemplate ft ON ft.Id = ct.faction + JOIN dbc.creaturefamily cf ON cf.Id = ct.family + LEFT JOIN locales_creature lc ON lc.entry = ct.entry + JOIN dbc.creaturedisplayinfo cdi ON cdi.id = ct.modelId1 + WHERE cf.petTalentType <> -1 AND ct.type_flags & 0x1 + ORDER BY ct.entry ASC'); + + // check directory-structure + foreach (Util::$localeStrings as $dir) + if (!writeDir('datasets/'.$dir, $log)) + $success = false; + + foreach ($locales as $lId) + { + User::useLocale($lId); + Lang::load(Util::$localeStrings[$lId]); + + $petsOut = []; + foreach ($petList as $pet) + { + // get locations + // again: caching will save you time and nerves + if (!isset($locations[$pet['id']])) + { + $locations[$pet['id']] = DB::Aowow()->SelectCol($qZones, $pet['id']); + + // probably instanced, map <=> areaId _should_ be bijective + if (empty($locations[$pet['id']])) + if ($z = DB::Aowow()->SelectCell($qInstances, $pet['id'])) + $locations[$pet['id']][] = $z; + } + + $petsOut[$pet['id']] = array( + 'id' => $pet['id'], + 'name' => Util::localizedString($pet, 'name'), + 'minlevel' => $pet['minlevel'], + 'maxlevel' => $pet['maxlevel'], + 'location' => $locations[$pet['id']], + 'react' => $pet['react'], + 'classification' => $pet['classification'], + 'family' => $pet['family'], + 'displayId' => $pet['displayId'], + 'skin' => $pet['skin'], + 'icon' => $pet['icon'], + 'type' => $pet['type'] + ); + } + + $toFile = "var g_pets = "; + $toFile .= json_encode($petsOut, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK); + $toFile .= ";"; + $file = 'datasets/'.User::$localeString.'/pets'; + + if (!writeFile($file, $toFile, $log)) + $success = false; + } + + return $success; + } +?> diff --git a/setup/tools/filegen/profiler.func.php b/setup/tools/filegen/profiler.func.php new file mode 100644 index 00000000..69654048 --- /dev/null +++ b/setup/tools/filegen/profiler.func.php @@ -0,0 +1,316 @@ +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; + } + +?> diff --git a/setup/tools/filegen/realms.func.php b/setup/tools/filegen/realms.func.php new file mode 100644 index 00000000..201a0dd5 --- /dev/null +++ b/setup/tools/filegen/realms.func.php @@ -0,0 +1,35 @@ + 'www.wowarmory.com', + eu => 'eu.wowarmory.com' + }; + */ + + /* Examples + 1 => { + name:'Eldre\'Thalas', + battlegroup:'Reckoning', + region:'us' + }, + */ + + function realms(&$log) + { + $file = 'datasets/realms'; + $rows = DB::Auth()->select('SELECT id AS ARRAY_KEY, name, ? AS battlegroup, IF(timezone IN (8, 9, 10, 11, 12), "eu", "us") AS region FROM realmlist WHERE allowedSecurityLevel = 0', CFG_BATTLEGROUP); + $str = 'var g_realms = '.json_encode($rows, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE).';'; + + return writeFile($file, $str, $log); + } + +?> diff --git a/setup/tools/filegen/scriptGen.php b/setup/tools/filegen/scriptGen.php new file mode 100644 index 00000000..09db76c2 --- /dev/null +++ b/setup/tools/filegen/scriptGen.php @@ -0,0 +1,195 @@ + CFG_NAME, + 'CFG_NAME_SHORT' => CFG_NAME_SHORT, + 'HOST_URL' => HOST_URL, + 'STATIC_URL' => STATIC_URL +); +$tplFiles = array( + 'searchplugin' => ['aowow.xml', 'static/download/searchplugins/'], + 'power' => ['power.js', 'static/widgets/' ], + 'searchboxScript' => ['searchbox.js', 'static/widgets/' ], + 'demo' => ['demo.html', 'static/widgets/power/' ], + 'searchboxBody' => ['searchbox.html', 'static/widgets/searchbox/' ], + 'realmMenu' => ['profile_all.js', 'static/js/' ], + 'locales' => ['locale.js', 'static/js/' ], +// 'itemScaling => ['item-scaling', 'datasets/' ], # provided 'as is', as dbc-content doesn't usualy change +); +$nullFiles = array( + 'realms', 'statistics', 'profiler', // profiler related + 'talents', 'talentIcons', 'glyphs', // talentCalc related + 'itemsets', 'enchants', 'gems', // comparison related + 'pets', +); + + +// restrict actual locales +foreach (Util::$localeStrings as $idx => $str) + if ($str && (CFG_LOCALES & (1 << $idx))) + $locales[] = $idx; + + +// check $pageParam; limit to real scriptNames +$scList = array_merge(array_keys($tplFiles), $nullFiles); +if ($pageParam) + $scList = array_intersect(explode(';', $pageParam), $scList); + + +if ($scList) +{ + // start + $log[] = [time(), 'begin generation of '. implode(', ', $scList)]; + $log[] = null; + + // files with template + foreach ($tplFiles as $name => list($file, $destPath)) + { + if ($scList && !in_array($name, $scList)) + continue; + + if (!file_exists($tplPath.$file.'.in')) + { + $log[] = [time(), sprintf(ERR_MISSING_FILE, $tplPath.$file.'.in')]; + continue; + } + + if (!writeDir($destPath, $log)) + continue; + + if ($content = file_get_contents($tplPath.$file.'.in')) + { + if ($dest = @fOpen($destPath.$file, "w")) + { + // replace constants + $content = strtr($content, $pairs); + + // must generate content + // PH format: /*setup:*/ + if (preg_match('/\/\*setup:([\w\d_-]+)\*\//i', $content, $m)) + { + $res = ''; + if (file_exists('setup/tools/filegen/'.$m[1].'.func.php')) + { + include 'setup/tools/filegen/'.$m[1].'.func.php'; + $res = $m[1]($log, $locales); + } + else + $log[] = [time(), sprintf(ERR_MISSING_INCL, $m[1], 'setup/tools/filegen/'.$m[1].'.func.php')]; + + $content = str_replace('/*setup:'.$m[1].'*/', $res, $content); + } + + if (fWrite($dest, $content)) + { + fClose($dest); + $log[] = [time(), sprintf(ERR_NONE, $destPath.$file)]; + } + else + { + $log[] = [time(), sprintf(ERR_WRITE_FILE, $destPath.$file)]; + fClose($dest); + continue; + } + } + else + { + $log[] = [time(), sprintf(ERR_CREATE_FILE, $destPath.$file)]; + continue; + } + } + else + { + $log[] = [time(), sprintf(ERR_READ_FILE, $tplPath.$file.'.in')]; + continue; + } + } + + // files without template + foreach ($nullFiles as $file) + { + if ($scList && !in_array($file, $scList)) + continue; + + if (file_exists('setup/tools/filegen/'.$file.'.func.php')) + { + include 'setup/tools/filegen/'.$file.'.func.php'; + if ($file($log, $locales)) + $log[] = [time(), ' - subscript returned sucessfully']; + else + $log[] = [time(), ' - subscript returned with errors']; + + set_time_limit(30); // reset to default for the next script + } + else + $log[] = [time(), sprintf(ERR_MISSING_INCL, $file, 'setup/tools/filegen/'.$file.'.func.php')]; + } + + // end + $log[] = null; + $log[] = [time(), 'finished file generation']; +} +else + $log[] = [time(), 'no valid script names supplied']; + + +// print accumulated log +echo "
\n";
+foreach ($log as $l)
+    if ($l)
+        echo date('H:i:s', $l[0]) . ' ' . $l[1]."\n";
+    else
+        echo "\n";
+echo "
\n"; + + +?> \ No newline at end of file diff --git a/setup/tools/filegen/statistics.func.php b/setup/tools/filegen/statistics.func.php new file mode 100644 index 00000000..288fa571 --- /dev/null +++ b/setup/tools/filegen/statistics.func.php @@ -0,0 +1,152 @@ + [[-20, 2, 0, 3], [-10, 0, 1, 1], null, 0.9560, 3.6640, 88.129021, 5, 47.003525, 5, 0, 0], + 2 => [[-20, 2, 0, 3], [-10, 0, 1, 0], null, 0.9560, 3.4943, 88.129021, 5, 47.003525, 5, 0, 0], + 3 => [[-20, 1, 1, 2], [-10, 0, 2, 2], null, 0.9880, -4.0873, 145.560408, 5, 145.560408, 0, 0, 0], + 4 => [[-20, 1, 1, 2], [-10, 0, 1, 1], null, 0.9880, 2.0957, 145.560408, 5, 145.560408, 0, 0, 0], + 5 => [[-10, 1, 0, 0], [-10, 0, 1, 0], null, 0.9830, 3.4178, 150.375940, 0, 0.0, 0, 0, 0], + 6 => [[-20, 2, 0, 3], [-10, 0, 1, 0], null, 0.9560, 3.6640, 88.129021, 5, 47.003525, 0, 0, ['parryrtng' => [0.25, 'percentOf', 'str']]], // Forcefull Deflection (49410) + 7 => [[-20, 1, 1, 2], [-10, 0, 1, 0], null, 0.9880, 2.1080, 145.560408, 0, 145.560408, 5, 0, 0], + 8 => [[-10, 1, 0, 0], [-10, 0, 1, 0], null, 0.9830, 3.6587, 150.375940, 0, 0.0, 0, 0, 0], + 9 => [[-10, 1, 0, 0], [-10, 0, 1, 0], null, 0.9830, 2.4211, 150.375940, 0, 0.0, 0, 0, 0], + 11 => [[-20, 2, 0, 0], [-10, 0, 1, 0], null, 0.9720, 5.6097, 116.890707, 0, 0.0, 0, 0, 0] + ); + + foreach ($dataz as $class => &$data) + $data[2] = array_values(DB::Aowow()->selectRow('SELECT mle.chance*100 cMle, spl.chance*100 cSpl FROM dbc.gtchancetomeleecritbase mle, dbc.gtchancetospellcritbase spl WHERE mle.idx = spl.idx AND mle.idx = ?d', $class - 1)); + + return $dataz; + }; + + $race = function() + { + // { str, agi, sta, int, spi, hp, mana, directMod1, directMod2 } + + return array( + 1 => [20, 20, 20, 20, 20, 0, ['spi' => [0.05, 'percentOf', 'spi']]], // The Human Spirit (20598) + 2 => [23, 17, 22, 17, 23, 0, 0], + 3 => [22, 16, 23, 19, 19, 0, 0], + 4 => [17, 25, 19, 20, 20, 0, 0], + 5 => [19, 18, 21, 18, 25, 0, 0], + 6 => [25, 15, 22, 15, 22, 0, ['health' => [0.05, 'functionOf', '$function(p) { return g_statistics.combo[p.classs][p.level][5]; }']]], // Endurance (20550) ... if you are looking for something elegant, look away! + 7 => [15, 23, 19, 24, 20, 0, ['int' => [0.05, 'percentOf', 'int']]], // Expansive Mind (20591) + 8 => [21, 22, 21, 16, 21, 0, ['healthrgn' => [0.1, 'percentOf', 'healthrgn']]], // Regeneration (20555) + 10 => [17, 22, 18, 24, 19, 0, 0], + 11 => [21, 17, 19, 21, 22, 0, 0] // ['mlehitpct' => [1, 'add'], 'splhitpct' => [1, 'add'], 'rgdhitpct' => [1, 'add']] // Heroic Presence (6562, 28878) (not actually shown..?) + ); + }; + + $combo = function() + { + $result = []; + $critToDodge = array( + 1 => 0.85/1.15, 2 => 1.00/1.15, 3 => 1.11/1.15, + 4 => 2.00/1.15, 5 => 1.00/1.15, 6 => 0.85/1.15, + 7 => 1.60/1.15, 8 => 1.00/1.15, 9 => 0.97/1.15, 11 => 2.00/1.15 + ); + + // TrinityCore claims, DodgePerAgi per level and class can be constituted from critPerAgi (and level (and class)) + // who am i to argue + // rebase stats to a specific race. chosen human as all stats are 20 + // level:{ str, agi, sta, int, spi, hp, mana, mleCrt%Agi, splCrt%Int, dodge%Agi, HealthRegenModToBaseStat, HealthRegenModToBonusStat } + + foreach ($critToDodge as $class => $mod) + { + // humans can't be hunter, shaman, druids (use tauren here) + if (in_array($class, [3, 7, 11])) + $offset = [25, 15, 22, 15, 22]; + else + $offset = [20, 20, 20, 20, 20]; + + $rows = DB::Aowow()->select('SELECT pls.level AS ARRAY_KEY, str-?d, agi-?d, sta-?d, inte-?d, spi-?d, basehp, IF(basemana <> 0, basemana, 100), mlecrt.chance*100, splcrt.chance*100, mlecrt.chance*100 * ?f, baseHP5.ratio*1, extraHP5.ratio*1 ' . + 'FROM player_levelstats pls JOIN player_classlevelstats pcls ON pls.level = pcls.level AND pls.class = pcls.class JOIN' . + ' dbc.gtchancetomeleecrit mlecrt ON mlecrt.idx = ((pls.class - 1) * 100) + (pls.level - 1) JOIN' . + ' dbc.gtchancetospellcrit splcrt ON splcrt.idx = ((pls.class - 1) * 100) + (pls.level - 1) JOIN' . + ' dbc.gtoctregenhp baseHP5 ON baseHP5.idx = ((pls.class - 1) * 100) + (pls.level - 1) JOIN' . + ' dbc.gtregenhpperspt extraHP5 ON extraHP5.idx = ((pls.class - 1) * 100) + (pls.level - 1) ' . + 'WHERE pls.race = ?d AND pls.class = ?d ORDER BY pls.level ASC', + $offset[0], $offset[1], $offset[2], $offset[3], $offset[4], + $mod, + in_array($class, [3, 7, 11]) ? 6 : 1, + $class + ); + + $result[$class] = []; + foreach ($rows as $k => $row) + $result[$class][$k] = array_values($row); + } + + return $result; + }; + + $level = function() + { + // base mana regeneration per level + // identical across classes (just use one, that acutally has mana (offset: 100)) + // content of gtRegenMPPerSpt.dbc + + return DB::Aowow()->selectCol('SELECT idx-99 AS ARRAY_KEY, ratio FROM dbc.gtregenmpperspt WHERE idx >= 100 AND idx < 100 + ?d', MAX_LEVEL); + }; + + $skills = function() + { + // profession perks (skinning => +crit, mining => +stam) and maybe some others; skillId:{rankNo:someJSON, ..}? + + return []; + }; + + // todo: x + $sub = ['classs', 'race', 'combo', 'level', 'skills']; + $out = []; + $success = true; + + foreach ($sub as $s) + { + $res = $$s(); + $out[$s] = $res; + if (!$res) + { + $log[] = [time(), ' error: statistics - generator $'.$s.'() returned empty']; + $success = false; + } + } + + $json = json_encode($out, JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); + $toFile = 'g_statistics = '.preg_replace('/"\$([^$"]+)"/', '\1', $json).';'; + + if (!writeFile('datasets/statistics', $toFile, $log)) + $success = false; + + return $success; + } + +?> \ No newline at end of file diff --git a/setup/tools/filegen/talentIcons.func.php b/setup/tools/filegen/talentIcons.func.php new file mode 100644 index 00000000..ca8a26b5 --- /dev/null +++ b/setup/tools/filegen/talentIcons.func.php @@ -0,0 +1,99 @@ + $v) + { + if (!$v) + continue; + + set_time_limit(10); + + for ($tree = 0; $tree < 3; $tree++) + { + $what = $k ? 'classMask' : 'creatureFamilyMask'; + $set = $k ? 1 << ($k - 1) : 1 << $tree; + $subset = $k ? $tree : 0; + $path = $k ? 'talents/icons' : 'hunterpettalents'; + $outFile = 'static/images/wow/'.$path.'/'.$v.'_'.($tree + 1).'.jpg'; + $icons = DB::Aowow()->SelectCol($query, $what, $set, $subset); + + if (empty($icons)) + { + $log[] = [time(), ' error: talentIcons - query for '.$v.' tree: '.$k.' empty']; + $success = false; + continue; + } + + if ($res = imageCreateTrueColor(count($icons) * $dims, 2 * $dims)) + { + for ($i = 0; $i < count($icons); $i++) + { + $imgFile = 'static/images/wow/icons/medium/'.strtolower($icons[$i]).'.jpg'; + if (!file_exists($imgFile)) + { + $log[] = [time(), ' error: talentIcons - raw image '.$imgFile. ' not found']; + $success = false; + break; + } + + $im = imagecreatefromjpeg($imgFile); + + // colored + imagecopymerge($res, $im, $i * $dims, 0, 0, 0, imageSX($im), imageSY($im), 100); + + // grayscale + if (imageistruecolor($im)) + imagetruecolortopalette($im, false, 256); + + for ($j = 0; $j < imagecolorstotal($im); $j++) + { + $color = imagecolorsforindex($im, $j); + $gray = round(0.299 * $color['red'] + 0.587 * $color['green'] + 0.114 * $color['blue']); + imagecolorset($im, $j, $gray, $gray, $gray); + } + imagecopymerge($res, $im, $i * $dims, $dims, 0, 0, imageSX($im), imageSY($im), 100); + } + + if (@imagejpeg($res, $outFile)) + $log[] = [time(), sprintf(ERR_NONE, $outFile)]; + else + { + $success = false; + $log[] = [time(), ' error: talentIcons - '.$outFile.'.jpg could not be written!']; + } + } + else + { + $success = false; + $log[] = [time(), ' error: talentIcons - image resource not created']; + continue; + } + } + } + + return $success; + } + +?> diff --git a/setup/tools/filegen/talents.func.php b/setup/tools/filegen/talents.func.php new file mode 100644 index 00000000..efc656c7 --- /dev/null +++ b/setup/tools/filegen/talents.func.php @@ -0,0 +1,207 @@ +select('SELECT * FROM dbc.talenttab WHERE classMask = ?d ORDER BY `tabNumber`, `creatureFamilyMask`', $mask); + $result = []; + + for ($l = 0; $l < count($tabs); $l++) + { + $talents = DB::Aowow()->select(' + SELECT t.id AS tId, t.*, s.* + FROM dbc.talent t, ?_spell s + WHERE t.`tabId`= ?d AND s.`Id` = t.`rank1` + ORDER by t.`row`, t.`column`', + $tabs[$l]['Id'] + ); + + $result[$l] = array( + 'n' => Util::localizedString($tabs[$l], 'name'), + 't' => [] + ); + + if (!$class) + { + $petFamId = log($tabs[$l]['creatureFamilyMask'], 2); + $result[$l]['icon'] = $petFamIcons[$petFamId]; + $petCategories = DB::Aowow()->SelectCol('SELECT Id AS ARRAY_KEY, category FROM ?_pet WHERE type = ?d', $petFamId); + $result[$l]['f'] = array_keys($petCategories); + } + + // talent dependencies go here + $depLinks = []; + $tNums = []; + + for ($j = 0; $j < count($talents); $j++) + { + $tNums[$talents[$j]['tId']] = $j; + + $d = []; + $s = []; + $i = $talents[$j]['tId']; + $n = Util::localizedString($talents[$j], 'name'); + $x = $talents[$j]['column']; + $y = $talents[$j]['row']; + $r = null; + $t = []; + $icon = $talents[$j]['iconString']; + $m = $talents[$j]['rank2'] == 0 ? 1 : ( + $talents[$j]['rank3'] == 0 ? 2 : ( + $talents[$j]['rank4'] == 0 ? 3 : ( + $talents[$j]['rank5'] == 0 ? 4 : 5 + ) + ) + ); + + // duplet handling + $f = []; + foreach ($petCategories as $k => $v) + { + // cant handle 64bit integer .. split + if ($v >= 32 && ((1 << ($v - 32)) & $talents[$j]['petCategory2'])) + $f[] = $k; + else if ($v < 32 && ((1 << $v) & $talents[$j]['petCategory1'])) + $f[] = $k; + } + + for ($k = 0; $k <= ($m - 1); $k++) + { + if (!$tSpells->getEntry($talents[$j]['rank'.($k + 1)])) + continue; + + $d[] = $tSpells->parseText()[0]; + $s[] = $talents[$j]['rank'.($k + 1)]; + + if ($talents[$j]['talentSpell']) + $t[] = $tSpells->getTalentHeadForCurrent(); + } + + if ($talents[$j]['reqTalent']) + { + // we didn't encounter the required talent yet => create reference + if (!isset($tNums[$talents[$j]['reqTalent']])) + $depLinks[$talents[$j]['reqTalent']] = $j; + + $r = @[$tNums[$talents[$j]['reqTalent']], $talents[$j]['reqRank'] + 1]; + } + + $result[$l]['t'][$j] = array( + 'i' => $i, + 'n' => $n, + 'm' => $m, + 'd' => $d, + 's' => $s, + 'x' => $x, + 'y' => $y, + ); + + if (isset($r)) + $result[$l]['t'][$j]['r'] = $r; + + if (!empty($t)) + $result[$l]['t'][$j]['t'] = $t; + + if (!empty($f)) + $result[$l]['t'][$j]['f'] = $f; + + if ($class) + $result[$l]['t'][$j]['iconname'] = $icon; + + // If this talent is a reference, add it to the array of talent dependencies + if (isset($depLinks[$talents[$j]['tId']])) + { + $result[$l]['t'][$depLinks[$talents[$j]['tId']]]['r'][0] = $j; + unset($depLinks[$talents[$j]['tId']]); + } + } + + // Remove all dependencies for which the talent has not been found + foreach ($depLinks as $dep_link) + unset($result[$l]['t'][$dep_link]['r']); + } + + return $result; + }; + + // my neighbour is noisy as fuck and my head hurts, so .. + $petFamIcons = ['Ability_Druid_KingoftheJungle', 'Ability_Druid_DemoralizingRoar', 'Ability_EyeOfTheOwl']; // .. i've no idea where to fetch these from + $classes = [CLASS_WARRIOR, CLASS_PALADIN, CLASS_HUNTER, CLASS_ROGUE, CLASS_PRIEST, CLASS_DEATHKNIGHT, CLASS_SHAMAN, CLASS_MAGE, CLASS_WARLOCK, CLASS_DRUID]; + $petIcons = ''; + + // check directory-structure + foreach (Util::$localeStrings as $dir) + if (!writeDir('datasets/'.$dir, $log)) + $success = false; + + $tSpellIds = DB::Aowow()->selectCol('SELECT rank1 FROM dbc.talent UNION SELECT rank2 FROM dbc.talent UNION SELECT rank3 FROM dbc.talent UNION SELECT rank4 FROM dbc.talent UNION SELECT rank5 FROM dbc.talent'); + $tSpells = new SpellList(array(['s.id', $tSpellIds], CFG_SQL_LIMIT_NONE)); + + foreach ($locales as $lId) + { + User::useLocale($lId); + Lang::load(Util::$localeStrings[$lId]); + + // TalentCalc + foreach ($classes as $cMask) + { + set_time_limit(20); + + $cId = log($cMask, 2) + 1; + $file = 'datasets/'.User::$localeString.'/talents-'.$cId; + $toFile = '$WowheadTalentCalculator.registerClass('.$cId.', '.json_encode($buildTree($cId), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK).')'; + + if (!writeFile($file, $toFile, $log)) + $success = false; + } + + // PetCalc + if (empty($petIcons)) + { + $pets = DB::Aowow()->SelectCol('SELECT Id AS ARRAY_KEY, iconString FROM ?_pet'); + $petIcons = json_encode($pets, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK); + } + + $toFile = "var g_pet_icons = ".$petIcons.";\n\n"; + $toFile .= 'var g_pet_talents = '.json_encode($buildTree(0), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK).';'; + $file = 'datasets/'.User::$localeString.'/pet-talents'; + + if (!writeFile($file, $toFile, $log)) + $success = false; + } + + return $success; + } +?> diff --git a/setup/tools/filegen/templates/aowow.xml.in b/setup/tools/filegen/templates/aowow.xml.in new file mode 100644 index 00000000..b1e7d6fd --- /dev/null +++ b/setup/tools/filegen/templates/aowow.xml.in @@ -0,0 +1,19 @@ + + + +CFG_NAME_SHORT +CFG_NAME_SHORT Search Plugin + + + + +STATIC_URL/images/logos/favicon.ico +STATIC_URL/images/icons/favicon.gif + + diff --git a/static/widgets/power/demo.html b/setup/tools/filegen/templates/demo.html.in similarity index 52% rename from static/widgets/power/demo.html rename to setup/tools/filegen/templates/demo.html.in index d405db25..a29b0469 100644 --- a/static/widgets/power/demo.html +++ b/setup/tools/filegen/templates/demo.html.in @@ -2,7 +2,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -'Powered by Wowhead' Demo +'Powered by CFG_NAME_SHORT' Demo @@ -21,51 +21,51 @@ h2 small { font-size: 13px; font-weight: normal } -

'Powered by Wowhead' Demo
« Return to the site

+

'Powered by CFG_NAME_SHORT' Demo
« Return to the site

Items

-Skyshatter Cover
-Lightbringer Faceguard

+Skyshatter Cover
+Lightbringer Faceguard

-Repurposed Lava Dredger (Level 42 scaling)

+Repurposed Lava Dredger (Level 42 scaling)

Abacus of Violent Odds (Custom URL)
-Atiesh, Greatstaff of the Guardian (Level 80 conversions)
-Felstalker Bracers (Enchant, gem, set bonus)
-Dark Band of Agility (Random enchantment, enchant)
-Surestrike Goggles v2.0 (Enchant, gems)

+Atiesh, Greatstaff of the Guardian (Level 80 conversions)
+Felstalker Bracers (Enchant, gem, set bonus)
+Dark Band of Agility (Random enchantment, enchant)
+Surestrike Goggles v2.0 (Enchant, gems)


Spells

-Swiftmend
-Shadow Word: Pain
-Blacksmithing: Bulwark of the Ancient Kings

+Swiftmend
+Shadow Word: Pain
+Blacksmithing: Bulwark of the Ancient Kings

-Mark of the Wild (Buff)

+Mark of the Wild (Buff)


Quests

-Zalazane
-Wanted: Arcatraz Sentinels
-An Apexis Relic
-Kalynna's Request

+Zalazane
+Wanted: Arcatraz Sentinels
+An Apexis Relic
+Kalynna's Request


Achievements

-'Tis the Season
-100 Fish (Earned)

+'Tis the Season
+100 Fish (Earned)


Profiles

-Drekdarok
-DPS

+Drekdarok
+DPS

Drekdarok (Custom URL)
DPS (Custom URL)
@@ -79,9 +79,9 @@ h2 small { font-size: 13px; font-weight: normal } Image Map

-Sun -Mercury -Venus +Sun +Mercury +Venus @@ -101,14 +101,14 @@ h2 small { font-size: 13px; font-weight: normal }
-Item #30301
-Item #99999 +Item #30301
+Item #99999
-Item #30319 -Item #22589 -Item #8171 -Item #6479! +Item #30319 +Item #22589 +Item #8171 +Item #6479! diff --git a/setup/tools/filegen/templates/item-scaling.in b/setup/tools/filegen/templates/item-scaling.in new file mode 100644 index 00000000..25ab3991 --- /dev/null +++ b/setup/tools/filegen/templates/item-scaling.in @@ -0,0 +1,9 @@ +$WH.g_convertRatingToPercent.RB = {/*setup:gtCombatRatings*/}; + +$WH.g_convertScalingFactor.SV = {/*setup:scalingStatValues*/}; + +$WH.g_convertScalingFactor.SD = {/*setup:scalingStatDistribution*/}; + +if ($WH.isset('$WowheadPower')) { + $WowheadPower.loadScales(3); +} diff --git a/setup/tools/filegen/templates/locale.js.in b/setup/tools/filegen/templates/locale.js.in new file mode 100644 index 00000000..7c4933b0 --- /dev/null +++ b/setup/tools/filegen/templates/locale.js.in @@ -0,0 +1,62 @@ +/* +Locale class +*/ + +var LOCALE_ENUS = 0; +var LOCALE_FRFR = 2; +var LOCALE_DEDE = 3; +var LOCALE_ESES = 6; +var LOCALE_RURU = 8; + +var Locale = { + + current: {}, + + // All + locales: { +/*setup:locales*/ + }, + + getAll: function() { + var result = []; + + for (var id in Locale.locales) { + result.push(Locale.locales[id]); + } + + return result; + }, + + getAllByName: function() { + var result = Locale.getAll(); + + result.sort(function(a, b) { + return $WH.strcmp(a.description, b.description); + }); + + return result; + }, + + getId: function() { + return Locale.current.id; + }, + + getName: function() { + var localeId = Locale.getId(); + + return Locale.locales[localeId].name; + }, + + get: function() { + var localeId = Locale.getId(); + + return Locale.locales[localeId]; + }, + + set: function(localeId) { + $.extend(Locale.current, Locale.locales[localeId]); + } + +}; + +Locale.set(LOCALE_ENUS); // Default diff --git a/static/widgets/power.js b/setup/tools/filegen/templates/power.js.in similarity index 97% rename from static/widgets/power.js rename to setup/tools/filegen/templates/power.js.in index 9cf86398..ad74112e 100644 --- a/static/widgets/power.js +++ b/setup/tools/filegen/templates/power.js.in @@ -2,17 +2,8 @@ if (typeof $WH == "undefined") { $WH = { wowheadRemote: true }; /* custom */ - for (i in document.scripts) { - if (!document.scripts[i].src) - continue; - - var match = document.scripts[i].src.match(/(https?:\/\/[^\/]+)((\/[\w\d-_%]+)*)\/widgets\/power\.js/i); - if (match) { - var g_host = match[1]; // todo: probably incorrect for most cases :/ - var g_staticUrl = match[1] + match[2]; - break; - } - } + var g_host = 'HOST_URL'; + var g_staticUrl = 'STATIC_URL'; } if (typeof $WowheadPower == "undefined") { @@ -258,10 +249,10 @@ if (typeof $WowheadPower == "undefined") { if (t.href.indexOf("http://") == 0 || t.href.indexOf("https://") == 0) { i0 = 1; // url = t.href.match(/^https?:\/\/(.+?)?\.?wowhead\.com(?:\:\d+)?\/\??(item|quest|spell|achievement|npc|object)=([0-9]+)/); - url = t.href.match(/^http:\/\/(.*)\/\??(item|quest|spell|achievement|npc|object)=([0-9]+)/); + url = t.href.match(/^https?:\/\/(.*)\/?\??(item|quest|spell|achievement|npc|object)=([0-9]+)/); if (url == null) { // url = t.href.match(/^http:\/\/(.+?)?\.?wowhead\.com\/\?(profile)=([^&#]+)/) - url = t.href.match(/^http:\/\/(.*)\/\??(profile)=([^&#]+)/); + url = t.href.match(/^https?:\/\/(.*)\/?\??(profile)=([^&#]+)/); } showLogo = 0; diff --git a/config/profile_all.js.in b/setup/tools/filegen/templates/profile_all.js.in similarity index 87% rename from config/profile_all.js.in rename to setup/tools/filegen/templates/profile_all.js.in index 34d89146..f7ca0eda 100644 --- a/config/profile_all.js.in +++ b/setup/tools/filegen/templates/profile_all.js.in @@ -1,4 +1,4 @@ -var mn_profiles = [/*setup:realms*/]; +var mn_profiles = /*setup:mnProfiles*/; var mn_guilds = $.extend(true,[],mn_profiles); var mn_arenateams = $.extend(true,[],mn_profiles); diff --git a/static/widgets/searchbox/searchbox.html b/setup/tools/filegen/templates/searchbox.html.in similarity index 51% rename from static/widgets/searchbox/searchbox.html rename to setup/tools/filegen/templates/searchbox.html.in index 7948c0f5..9fed143b 100644 --- a/static/widgets/searchbox/searchbox.html +++ b/setup/tools/filegen/templates/searchbox.html.in @@ -1,23 +1,23 @@ - Aowow + CFG_NAME_SHORT - + - - diff --git a/static/widgets/searchbox.js b/setup/tools/filegen/templates/searchbox.js.in similarity index 58% rename from static/widgets/searchbox.js rename to setup/tools/filegen/templates/searchbox.js.in index c3da70df..951897d2 100644 --- a/static/widgets/searchbox.js +++ b/setup/tools/filegen/templates/searchbox.js.in @@ -1,27 +1,6 @@ (function () { function create(w, h) { - var - scripts = document.getElementsByTagName('SCRIPT'), - body; - - /* sarjuuk: workaround to avoid hardcoding the url of the body */ - if (scripts && scripts.length > 0) { - for (var i in scripts) { - if (!scripts[i].src) { - continue; - } - - var m = scripts[i].src.match(/(.*)\/widgets\/searchbox\.js$/); - if (!m) { - continue; - } - - body = m[1] + '/widgets/searchbox/searchbox.html'; - break; - } - } - /* end */ - + var body = 'STATIC_URL/widgets/searchbox/searchbox.html';; var buff = '