From 320ad252d1f3db2b28e6a8c3dd21410273fc19a7 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Tue, 4 Aug 2015 19:02:23 +0200 Subject: [PATCH] Tooltips/Items * skipping an error, when handling heirloom-armor with scaled level on external tooltips the tooltip will now be displayed but without the armor-class changing at level 40 * prevent assigning arbitrary randomEnchantments to items (e.g. Warglaive of Azzinoth of the Whale) --- includes/shared.php | 2 +- includes/types/item.class.php | 34 ++++++++++++++++++++++++++++------ pages/item.php | 2 +- static/js/basic.js | 3 ++- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/includes/shared.php b/includes/shared.php index 04bd9d2e..8278509f 100644 --- a/includes/shared.php +++ b/includes/shared.php @@ -1,6 +1,6 @@ getRandEnchantForItem($enhance['r'])) + $res .= ' '.Util::localizedString($this->enhanceR, 'name'); + + return $res; + } + public function renderTooltip($interactive = false, $subOf = 0, $enhance = []) { if ($this->error) @@ -455,20 +466,20 @@ class ItemList extends BaseType if (!empty($enhance['r'])) { - if ($rndEnch = DB::Aowow()->selectRow('SELECT * FROM ?_itemrandomenchant WHERE Id = ?d', $enhance['r'])) + if ($this->getRandEnchantForItem($enhance['r'])) { - $_name .= ' '.Util::localizedString($rndEnch, 'name'); + $_name .= ' '.Util::localizedString($this->enhanceR, 'name'); $randEnchant = ''; for ($i = 1; $i < 6; $i++) { - if ($rndEnch['enchantId'.$i] <= 0) + if ($this->enhanceR['enchantId'.$i] <= 0) continue; - $enchant = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE Id = ?d', $rndEnch['enchantId'.$i]); - if ($rndEnch['allocationPct'.$i] > 0) + $enchant = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE Id = ?d', $this->enhanceR['enchantId'.$i]); + if ($this->enhanceR['allocationPct'.$i] > 0) { - $amount = intVal($rndEnch['allocationPct'.$i] * $this->generateEnchSuffixFactor()); + $amount = intVal($this->enhanceR['allocationPct'.$i] * $this->generateEnchSuffixFactor()); $randEnchant .= ''.str_replace('$i', $amount, Util::localizedString($enchant, 'name')).'
'; } else @@ -1080,6 +1091,17 @@ class ItemList extends BaseType return $x; } + private function getRandEnchantForItem($randId) + { + // is it available for this item? .. does it even exist?! + if (empty($this->enhanceR)) + if (DB::World()->selectCell('SELECT 1 FROM item_enchantment_template WHERE entry = ?d AND ench = ?d', abs($this->getField('randomEnchant')), abs($randId))) + if ($_ = DB::Aowow()->selectRow('SELECT * FROM ?_itemrandomenchant WHERE Id = ?d', $randId)) + $this->enhanceR = $_; + + return !empty($this->enhanceR); + } + // from Trinity public function generateEnchSuffixFactor() { diff --git a/pages/item.php b/pages/item.php index fd71076f..4c1f142a 100644 --- a/pages/item.php +++ b/pages/item.php @@ -983,7 +983,7 @@ class ItemPage extends genericPage return '$WowheadPower.registerItem(\''.$itemString.'\', '.User::$localeId.', {})'; $x = '$WowheadPower.registerItem(\''.$itemString.'\', '.User::$localeId.", {\n"; - $x .= "\tname_".User::$localeString.": '".Util::jsEscape($this->subject->getField('name', true))."',\n"; + $x .= "\tname_".User::$localeString.": '".Util::jsEscape($this->subject->getField('name', true, $this->enhancedTT))."',\n"; $x .= "\tquality: ".$this->subject->getField('quality').",\n"; $x .= "\ticon: '".urlencode($this->subject->getField('iconString'))."',\n"; $x .= "\ttooltip_".User::$localeString.": '".Util::jsEscape($this->subject->renderTooltip(false, 0, $this->enhancedTT))."'\n"; diff --git a/static/js/basic.js b/static/js/basic.js index 32c864d6..aff4535c 100644 --- a/static/js/basic.js +++ b/static/js/basic.js @@ -1378,7 +1378,8 @@ $WH.g_setTooltipLevel = function(tooltip, level) { } // Always keep the base armor type - return prefix + g_itemset_types[_]; + return $WH.isset('g_itemset_types') ? prefix + g_itemset_types[_] : _all; // sarjuuk: LANG is not available if the tooltip is included externaly + // return prefix + g_itemset_types[_]; }); // Update min-max damage