From 3d08de51e11d6e57100abb6056181aea255c1173 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Tue, 21 Jul 2015 21:08:15 +0200 Subject: [PATCH] Items/Heirlooms * damage range of melee weapons is noe 20% and ranged weapons 30% * removed localized number format from item-tooltips. this broke damage recalculation User/Weightscales * fixed managing weightscales by moving ! around --- includes/ajaxHandler.class.php | 12 ++++++------ includes/types/item.class.php | 23 +++++++++++++---------- includes/utilities.php | 3 ++- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/includes/ajaxHandler.class.php b/includes/ajaxHandler.class.php index b68d6712..ba73ef5c 100644 --- a/includes/ajaxHandler.class.php +++ b/includes/ajaxHandler.class.php @@ -204,8 +204,8 @@ class AjaxHandler */ private function handleCookie() { - if (User::$id && $this->params && !empty($this->get[$this->params[0]])) - if (DB::Aowow()->query('REPLACE INTO ?_account_cookies VALUES (?d, ?, ?)', User::$id, $this->params[0], $this->get[$this->params[0]])) + if (User::$id && $this->params && $this->get($this->params[0])) + if (DB::Aowow()->query('REPLACE INTO ?_account_cookies VALUES (?d, ?, ?)', User::$id, $this->params[0], $this->get($this->params[0]))) return 0; return null; @@ -552,7 +552,7 @@ class AjaxHandler break; case 'flag-reply': - if (!User::$id || $this->post('id')) + if (!User::$id || !$this->post('id')) break; DB::Aowow()->query( @@ -633,11 +633,11 @@ class AjaxHandler // should probably occur in g_user.excludegroups (dont forget to also set g_users.settings = {}) return ''; case 'weightscales': - if (!$this->post('save')) + if ($this->post('save')) { - if (!isset($this->post['id'])) + if (!$this->post('id')) { - $res = DB::Aowow()->selectRow('SELECT max(id) as max, count(id) as num FROM ?_account_weightscales WHERE userId = ?d', User::$id); + $res = DB::Aowow()->selectRow('SELECT MAX(id) AS max, count(id) AS num FROM ?_account_weightscales WHERE userId = ?d', User::$id); if ($res['num'] < 5) // more or less hard-defined in LANG.message_weightscalesaveerror $this->post['id'] = ++$res['max']; else diff --git a/includes/types/item.class.php b/includes/types/item.class.php index e8a9f2ba..93d3845b 100644 --- a/includes/types/item.class.php +++ b/includes/types/item.class.php @@ -593,14 +593,14 @@ class ItemList extends BaseType $dps = $speed ? ($dmgmin1 + $dmgmax1) / (2 * $speed) : 0; if ($_class == ITEM_CLASS_AMMUNITION && $dmgmin1 && $dmgmax1) - $x .= Lang::item('addsDps').' '.Lang::nf(($dmgmin1 + $dmgmax1) / 2, 1).' '.Lang::item('dps2').'
'; + $x .= Lang::item('addsDps').' '.number_format(($dmgmin1 + $dmgmax1) / 2, 1).' '.Lang::item('dps2').'
'; else if ($dps) { if ($_class == ITEM_CLASS_WEAPON) { $x .= ''; $x .= ''; - $x .= ''; + $x .= ''; // do not use localized format here! $x .= '
'.sprintf($this->curTpl['dmgType1'] ? Lang::item('damageMagic') : Lang::item('damagePhys'), $this->curTpl['dmgMin1'].' - '.$this->curTpl['dmgMax1'], Lang::game('sc', $this->curTpl['dmgType1'])).''.Lang::item('speed').' '.Lang::nf($speed, 2).''.Lang::item('speed').' '.number_format($speed, 2).'
'; } else @@ -611,7 +611,7 @@ class ItemList extends BaseType $x .= '+'.sprintf($this->curTpl['dmgType2'] ? Lang::item('damageMagic') : Lang::item('damagePhys'), $this->curTpl['dmgMin2'].' - '.$this->curTpl['dmgMax2'], Lang::game('sc', $this->curTpl['dmgType2'])).'
'; if ($_class == ITEM_CLASS_WEAPON) - $x .= '('.Lang::nf($dps, 1).' '.Lang::item('dps').')
'; + $x .= '('.number_format($dps, 1).' '.Lang::item('dps').')
'; // do not use localized format here! // display FeralAttackPower if set if ($fap = $this->getFeralAP()) @@ -1329,12 +1329,12 @@ class ItemList extends BaseType if ($mask & (1 << $i)) $field = Util::$ssdMaskFields[$i]; - return $field ? DB::Aowow()->selectCell("SELECT ?# FROM ?_scalingstatvalues WHERE id = ?", $field, $this->ssd[$this->id]['maxLevel']) : 0; + return $field ? DB::Aowow()->selectCell('SELECT ?# FROM ?_scalingstatvalues WHERE id = ?d', $field, $this->ssd[$this->id]['maxLevel']) : 0; } private function initScalingStats() { - $this->ssd[$this->id] = DB::Aowow()->selectRow("SELECT * FROM ?_scalingstatdistribution WHERE id = ?", $this->curTpl['scalingStatDistribution']); + $this->ssd[$this->id] = DB::Aowow()->selectRow('SELECT * FROM ?_scalingstatdistribution WHERE id = ?d', $this->curTpl['scalingStatDistribution']); if (!$this->ssd[$this->id]) return; @@ -1358,12 +1358,15 @@ class ItemList extends BaseType if ($ssvArmor = $this->getSSDMod('armor')) $this->templates[$this->id]['armor'] = $ssvArmor; - // if set dpsMod in ScalingStatValue use it for min (70% from average), max (130% from average) damage + // if set dpsMod in ScalingStatValue use it for min/max damage + // mle: 20% range / rgd: 30% range if ($extraDPS = $this->getSSDMod('dps')) // dmg_x2 not used for heirlooms { + $range = isset($this->json[$this->id]['rgddps']) ? 0.3 : 0.2; $average = $extraDPS * $this->curTpl['delay'] / 1000; - $this->templates[$this->id]['dmgMin1'] = Lang::nf(0.7 * $average); - $this->templates[$this->id]['dmgMax1'] = Lang::nf(1.3 * $average); + + $this->templates[$this->id]['dmgMin1'] = floor((1 - $range) * $average); + $this->templates[$this->id]['dmgMax1'] = floor((1 + $range) * $average); } // apply Spell Power from ScalingStatValue if set @@ -1519,8 +1522,8 @@ class ItemList extends BaseType $json['dmgtype1'] = $this->curTpl['dmgType1']; $json['dmgmin1'] = $this->curTpl['dmgMin1'] + $this->curTpl['dmgMin2']; $json['dmgmax1'] = $this->curTpl['dmgMax1'] + $this->curTpl['dmgMax2']; - $json['speed'] = Lang::nf($this->curTpl['delay'] / 1000, 2); - $json['dps'] = !floatVal($json['speed']) ? 0 : Lang::nf(($json['dmgmin1'] + $json['dmgmax1']) / (2 * $json['speed']), 1); + $json['speed'] = number_format($this->curTpl['delay'] / 1000, 2); + $json['dps'] = !floatVal($json['speed']) ? 0 : number_format(($json['dmgmin1'] + $json['dmgmax1']) / (2 * $json['speed']), 1); if (in_array($json['subclass'], [2, 3, 18, 19])) { diff --git a/includes/utilities.php b/includes/utilities.php index 4183a0e4..cca4908d 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -1067,7 +1067,8 @@ class Util else $c = 2 / 52; - $result = Lang::nf($val / Util::$gtCombatRatings[$type] / $c, 2); + // do not use localized number format here! + $result = number_format($val / Util::$gtCombatRatings[$type] / $c, 2); } if (!in_array($type, array(ITEM_MOD_DEFENSE_SKILL_RATING, ITEM_MOD_EXPERTISE_RATING)))