From 0620a0081dd7363a0a15ba4556b8f109610d4548 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Fri, 19 Sep 2014 18:31:23 +0200 Subject: [PATCH] - Caching: also prevent caching in AjaxHandler - Util: initialize enchantments even if it has no usable stats - NPCs: * added tamability to infobox * added pet-spells to controlled spells tab * fixed displaying texts for zero-length strings, also adapted TrinityCore:master/e567ab95972508adc85a36f867723114a04fe227 * hide listview column 'type', when displaying one specific type - Utility - missing-screenshots: reduced list-size to 200 - fixed copypasta-typo in locale_eses.js - Skill: fixed error in detail page title --- includes/ajaxHandler.class.php | 7 ++++ includes/utilities.php | 3 ++ localization/locale_dede.php | 2 + localization/locale_enus.php | 2 + localization/locale_eses.php | 2 + localization/locale_frfr.php | 2 + localization/locale_ruru.php | 2 + pages/npc.php | 76 +++++++++++++++++++++++++--------- pages/npcs.php | 3 ++ pages/skill.php | 2 +- pages/utility.php | 4 +- static/js/locale_eses.js | 2 +- template/pages/npc.tpl.php | 4 +- 13 files changed, 87 insertions(+), 24 deletions(-) diff --git a/includes/ajaxHandler.class.php b/includes/ajaxHandler.class.php index b2d1c462..9299527d 100644 --- a/includes/ajaxHandler.class.php +++ b/includes/ajaxHandler.class.php @@ -30,6 +30,13 @@ class AjaxHandler if (!$what || !method_exists($this, $f)) return null; + // see GenericPage::display() + header('Expires: Sat, 01 Jan 2000 01:00:00 GMT'); + header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + header('Cache-Control: no-store, no-cache, must-revalidate'); + header('Cache-Control: post-check=0, pre-check=0', false); + header('Pragma: no-cache'); + return $this->$f(); } diff --git a/includes/utilities.php b/includes/utilities.php index 63c1dc5c..8324db0f 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -1186,9 +1186,12 @@ class Util if ($raw) $result[$eId] = $jsonStats; else + { + $result[$eId] = []; foreach ($jsonStats as $k => $v) // check if we use these mods if ($str = Util::$itemMods[$k]) $result[$eId][$str] = $v; + } } return $result; diff --git a/localization/locale_dede.php b/localization/locale_dede.php index 3bc23c62..ba5d5eb5 100644 --- a/localization/locale_dede.php +++ b/localization/locale_dede.php @@ -369,7 +369,9 @@ $lang = array( 'ranged' => "Fernkampf", 'armor' => "Rüstung", 'foundIn' => "Dieser NPC befindet sich in", + 'tameable' => "Zähmbar (%s)", 'rank' => [0 => "Normal", 1 => "Elite", 4 => "Rar", 2 => "Rar Elite", 3 => "Boss"], + 'textRanges' => [null, "an das Gebiet gesendet", "an die Zone gesendet", "an die Map gesendet", "an die Welt gesendet"], 'textTypes' => [null, "schreit", "sagt", "flüstert"], 'modes' => array( 1 => ["Normal", "Heroisch"], diff --git a/localization/locale_enus.php b/localization/locale_enus.php index ed00bf8e..220314cb 100644 --- a/localization/locale_enus.php +++ b/localization/locale_enus.php @@ -364,7 +364,9 @@ $lang = array( 'ranged' => "Ranged", 'armor' => "Armor", 'foundIn' => "This NPC can be found in", + 'tameable' => "Tameable (%s)", 'rank' => [0 => "Normal", 1 => "Elite", 4 => "Rare", 2 => "Rare Elite", 3 => "Boss"], + 'textRanges' => [null, "sent to area", "sent to zone", "sent to map", "sent to world"], 'textTypes' => [null, "yells", "says", "whispers"], 'modes' => array( 1 => ["Normal", "Heroic"], diff --git a/localization/locale_eses.php b/localization/locale_eses.php index 5587c168..0de5255a 100644 --- a/localization/locale_eses.php +++ b/localization/locale_eses.php @@ -368,7 +368,9 @@ $lang = array( 'melee' => "Cuerpo a cuerpo", 'ranged' => "Ataque a distancia", 'armor' => "Armadura", + 'tameable' => "Domesticable (%s)", 'rank' => [0 => "Normal", 1 => "Élite", 4 => "Raro", 2 => "Élite raro", 3 => "Jefe"], + 'textRanges' => [null, "[sent to area]", "[sent to zone]", "[sent to map]", "[sent to world]"], 'textTypes' => [null, "grita", "dice", "susurra"], 'modes' => array( 1 => ["Normal", "Heroico"], diff --git a/localization/locale_frfr.php b/localization/locale_frfr.php index c37c460c..6ec1b102 100644 --- a/localization/locale_frfr.php +++ b/localization/locale_frfr.php @@ -367,7 +367,9 @@ $lang = array( 'melee' => "de mêlée", 'ranged' => "à distance", 'armor' => "Armure", + 'tameable' => "Domptable (%s)", 'rank' => [0 => "Standard", 1 => "Élite", 4 => "Rare", 2 => "Élite rare", 3 =>"Boss"], + 'textRanges' => [null, "[sent to area]", "[sent to zone]", "[sent to map]", "[sent to world]"], 'textTypes' => [null, "crie", "dit", "chuchote"], 'modes' => array( 1 => ["Normal", "Héroïque"], diff --git a/localization/locale_ruru.php b/localization/locale_ruru.php index 0c499ed8..c9b5be28 100644 --- a/localization/locale_ruru.php +++ b/localization/locale_ruru.php @@ -367,7 +367,9 @@ $lang = array( 'melee' => "Ближнего боя", 'ranged' => "Дальнего боя", 'armor' => "Броня", + 'tameable' => "Можно приручить (%s)", 'rank' => [0 => "Обычный", 1 => "Элитный", 4 => "Редкий", 2 => "Редкий элитный", 3 =>"Босс"], + 'textRanges' => [null, "[sent to area]", "[sent to zone]", "[sent to map]", "[sent to world]"], 'textTypes' => [null, "кричит", "говорит", "шепчет"], 'modes' => array( 1 => ["Обычный", "Героический"], diff --git a/pages/npc.php b/pages/npc.php index 5859fcc1..bb01f8bb 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -137,6 +137,11 @@ class NpcPage extends GenericPage $this->extendGlobalIds(TYPE_FACTION, $this->subject->getField('factionId')); $infobox[] = Util::ucFirst(Lang::$game['faction']).Lang::$main['colon'].'[faction='.$this->subject->getField('factionId').']'; + // Tameable + if ($_typeFlags & 0x1) + if ($_ = $this->subject->getField('family')) + $infobox[] = sprintf(Lang::$npc['tameable'], '[url=pet='.$_.']'.Lang::$game['fa'][$_].'[/url]'); + // Wealth if ($_ = intVal(($this->subject->getField('minGold') + $this->subject->getField('maxGold')) / 2)) $infobox[] = Lang::$npc['worth'].Lang::$main['colon'].'[tooltip=tooltip_avgmoneydropped][money='.$_.'][/tooltip]'; @@ -255,7 +260,7 @@ class NpcPage extends GenericPage /**************/ // tab: SAI - // hmm, how should this loot like + // hmm, how should this look like // tab: abilities / tab_controlledabilities (dep: VehicleId) // SMART_SCRIPT_TYPE_CREATURE = 0; SMART_ACTION_CAST = 11; SMART_ACTION_ADD_AURA = 75; SMART_ACTION_INVOKER_CAST = 85; SMART_ACTION_CROSS_CAST = 86 @@ -273,24 +278,55 @@ class NpcPage extends GenericPage if ($smartSpells) $conditions[] = ['id', $smartSpells]; - if ($tplSpells || $smartSpells) + // Pet-Abilities + if ($_typeFlags & 0x1 && ($_ = $this->subject->getField('family'))) + { + $skill = 0; + $mask = 0x0; + foreach (Util::$skillLineMask[-1] as $idx => $pair) + { + if ($pair[0] != $_) + continue; + + $skill = $pair[1]; + $mask = 1 << $idx; + break; + } + $conditions[] = [ + 'AND', + ['s.typeCat', -3], + [ + 'OR', + ['skillLine1', $skill], + ['AND', ['skillLine1', 0, '>'], ['skillLine2OrMask', $skill]], + ['AND', ['skillLine1', -1], ['skillLine2OrMask', $mask, '&']] + ] + ]; + } + + if (count($conditions) > 1) { $abilities = new SpellList($conditions); if (!$abilities->error) { $this->extendGlobalData($abilities->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); - $normal = $abilities->getListviewData(); - $controled = []; + $controled = $abilities->getListviewData(); + $normal = []; - if ($this->subject->getField('vehicleId')) // not quite right. All seats should be checked for allowed-to-cast-flag-something + foreach ($controled as $id => $values) { - foreach ($normal as $id => $values) + if (in_array($id, $smartSpells)) { - if (in_array($id, $smartSpells)) - continue; + $normal[$id] = $values; + unset($controled[$id]); + continue; + } - $controled[$id] = $values; - unset($normal[$id]); + // not quite right. All seats should be checked for allowed-to-cast-flag-something + if (!$this->subject->getField('vehicleId') && in_array($id, $tplSpells)) + { + $normal[$id] = $values; + unset($controled[$id]); } } @@ -762,12 +798,13 @@ class NpcPage extends GenericPage $quoteQuery = ' SELECT ct.groupid AS ARRAY_KEY, ct.id as ARRAY_KEY2, ct.`type`, + ct.TextRange AS `range`, IFNULL(bct.`Language`, ct.`language`) AS lang, - IFNULL(bct.MaleText, IFNULL(bct.FemaleText, ct.`text`)) AS text_loc0, - IFNULL(lbct.MaleText_loc2, IFNULL(lbct.FemaleText_loc2, lct.text_loc2)) AS text_loc2, - IFNULL(lbct.MaleText_loc3, IFNULL(lbct.FemaleText_loc3, lct.text_loc3)) AS text_loc3, - IFNULL(lbct.MaleText_loc6, IFNULL(lbct.FemaleText_loc6, lct.text_loc6)) AS text_loc6, - IFNULL(lbct.MaleText_loc8, IFNULL(lbct.FemaleText_loc8, lct.text_loc8)) AS text_loc8 + IFNULL(NULLIF(bct.MaleText, ""), IFNULL(NULLIF(bct.FemaleText, ""), IFNULL(ct.`text`, ""))) AS text_loc0, + IFNULL(NULLIF(lbct.MaleText_loc2, ""), IFNULL(NULLIF(lbct.FemaleText_loc2, ""), IFNULL(lct.text_loc2, ""))) AS text_loc2, + IFNULL(NULLIF(lbct.MaleText_loc3, ""), IFNULL(NULLIF(lbct.FemaleText_loc3, ""), IFNULL(lct.text_loc3, ""))) AS text_loc3, + IFNULL(NULLIF(lbct.MaleText_loc6, ""), IFNULL(NULLIF(lbct.FemaleText_loc6, ""), IFNULL(lct.text_loc6, ""))) AS text_loc6, + IFNULL(NULLIF(lbct.MaleText_loc8, ""), IFNULL(NULLIF(lbct.FemaleText_loc8, ""), IFNULL(lct.text_loc8, ""))) AS text_loc8 FROM creature_text ct LEFT JOIN @@ -785,14 +822,15 @@ class NpcPage extends GenericPage foreach ($text as $t) { // fixup .. either set %s for emotes or dont >.< - $text = Util::localizedString($t, 'text'); - if (in_array($t['type'], [2, 16]) && strpos($text, '%s') === false) - $text = '%s '.$text; + $msg = Util::localizedString($t, 'text'); + if (in_array($t['type'], [2, 16]) && strpos($msg, '%s') === false) + $msg = '%s '.$msg; $line = array( + 'range' => $t['range'], 'type' => 2, // [type: 0, 12] say: yellow-ish 'lang' => !empty($t['language']) ? Lang::$game['languages'][$t['language']] : null, - 'text' => sprintf(Util::parseHtmlText(htmlentities($text)), $this->name), + 'text' => sprintf(Util::parseHtmlText(htmlentities($msg)), $this->name), ); switch ($t['type']) diff --git a/pages/npcs.php b/pages/npcs.php index fced414b..0d147416 100644 --- a/pages/npcs.php +++ b/pages/npcs.php @@ -61,6 +61,9 @@ class NpcsPage extends GenericPage if (!empty($this->filter['fi']['extraCols'])) $lv['params']['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; + if ($this->category) + $lv['params']['hiddenCols'] = "$['type']"; + // create note if search limit was exceeded if ($npcs->getMatches() > CFG_SQL_LIMIT_DEFAULT) { diff --git a/pages/skill.php b/pages/skill.php index 7cdb6bf1..67cef337 100644 --- a/pages/skill.php +++ b/pages/skill.php @@ -40,7 +40,7 @@ class SkillPage extends GenericPage protected function generateTitle() { - array_unshift($this->title, $this->name, Util::ucFirst(Lang::$game['class'])); + array_unshift($this->title, $this->name, Util::ucFirst(Lang::$game['skill'])); } protected function generateContent() diff --git a/pages/utility.php b/pages/utility.php index 4c949f4b..8eface21 100644 --- a/pages/utility.php +++ b/pages/utility.php @@ -101,8 +101,8 @@ class UtilityPage extends GenericPage ); break; case 'missing-screenshots': - $cnd = [[['cuFlags', CUSTOM_HAS_SCREENSHOT, '&'], 0]]; - + // limit to 200 entries each (it generates faster, consumes less memory and should be enough options) + $cnd = [[['cuFlags', CUSTOM_HAS_SCREENSHOT, '&'], 0], 200]; if (!User::isInGroup(U_GROUP_EMPLOYEE)) $cnd[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]; diff --git a/static/js/locale_eses.js b/static/js/locale_eses.js index ca09246c..23c600c5 100644 --- a/static/js/locale_eses.js +++ b/static/js/locale_eses.js @@ -3257,7 +3257,7 @@ var LANG = { fidropdowns:{ yn: [ [1, "Sí"], [2, "No"] ], - num: [ [1, ">"], [2, ">="], [3, "="], [4, "<="], [5, "<"], [6, "!="]], ], + num: [ [1, ">"], [2, ">="], [3, "="], [4, "<="], [5, "<"], [6, "!="]], side: [ [1, "Sí"], [2, "Alianza"], [3, "Horda"], [4, "Ambos"], [5, "No"] ], faction: [ [1015, "Ala Abisal"], [469, "Alianza"], [21, "Bahía del Botín"], [1011, "Bajo Arrabal"], [946, "Bastión del Honor"], diff --git a/template/pages/npc.tpl.php b/template/pages/npc.tpl.php index a527205b..2c83abab 100644 --- a/template/pages/npc.tpl.php +++ b/template/pages/npc.tpl.php @@ -97,7 +97,9 @@ if ($this->quotes[0]): $last = end($group); foreach ($group as $itr): - echo '
'.($itr['type'] != 4 ? $this->name.' '.Lang::$npc['textTypes'][$itr['type']].Lang::$main['colon'].($itr['lang'] ? '['.$itr['lang'].']' : null) : null).$itr['text'].'
'; + $_ = ($itr['type'] != 4 ? $this->name.' '.Lang::$npc['textTypes'][$itr['type']].Lang::$main['colon'].($itr['lang'] ? '['.$itr['lang'].']' : null) : null).$itr['text']; + + echo '
'.($itr['range'] ? sprintf(Util::$dfnString, Lang::$npc['textRanges'][$itr['range']], $_) : $_).'
'; echo ($itr == $last) ? null : "\n
  • "; endforeach;