split field 'flags' in announcements into distinct properties, mark jsVars with a '$' like in every other case

This commit is contained in:
Sarjuuk
2013-06-19 20:43:16 +02:00
parent 21f50ae2cd
commit 513c9d9114
3 changed files with 49 additions and 29 deletions

View File

@@ -183,7 +183,7 @@ abstract class BaseType
$this->curTpl = current($this->templates); $this->curTpl = current($this->templates);
$field = $this->curTpl ? Util::getIdFieldName($this->curTpl) : null; $field = $this->curTpl ? Util::getIdFieldName($this->curTpl) : null;
$this->id = $this->curTpl ? $this->curTpl[$field] : 0; $this->id = $this->curTpl ? (int)$this->curTpl[$field] : 0;
while ($qty--) while ($qty--)
next($this->templates); next($this->templates);
@@ -194,7 +194,7 @@ abstract class BaseType
public function reset() public function reset()
{ {
$this->curTpl = reset($this->templates); $this->curTpl = reset($this->templates);
$this->id = $this->curTpl[Util::getIdFieldName($this->curTpl)]; $this->id = (int)$this->curTpl[Util::getIdFieldName($this->curTpl)];
} }
// read-access to templates // read-access to templates
@@ -476,19 +476,19 @@ class Lang
$i = 1; $i = 1;
if (!$raceMask) if (!$raceMask)
return array('side' => 3, 'name' => self::$game['ra'][0]); return array('side' => SIDE_BOTH, 'name' => self::$game['ra'][0]);
if ($raceMask == RACE_MASK_HORDE) if ($raceMask == RACE_MASK_HORDE)
return array('side' => 2, 'name' => self::$game['ra'][-2]); return array('side' => SIDE_HORDE, 'name' => self::$game['ra'][-2]);
if ($raceMask == RACE_MASK_ALLIANCE) if ($raceMask == RACE_MASK_ALLIANCE)
return array('side' => 1, 'name' => self::$game['ra'][-1]); return array('side' => SIDE_ALLIANCE, 'name' => self::$game['ra'][-1]);
if ($raceMask & RACE_MASK_HORDE) if ($raceMask & RACE_MASK_HORDE)
$side |= 2; $side |= SIDE_HORDE;
if ($raceMask & RACE_MASK_ALLIANCE) if ($raceMask & RACE_MASK_ALLIANCE)
$side |= 1; $side |= SIDE_ALLIANCE;
while ($raceMask) while ($raceMask)
{ {
@@ -550,9 +550,14 @@ class SmartyAoWoW extends Smarty
// since it's the same for every page, except index.. // since it's the same for every page, except index..
if ($this->_tpl_vars['query'][0] && !preg_match('/[^a-z]/i', $this->_tpl_vars['query'][0])) if ($this->_tpl_vars['query'][0] && !preg_match('/[^a-z]/i', $this->_tpl_vars['query'][0]))
{ {
$ann = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE flags & 0x10 AND (page = ?s OR page = "*")', $this->_tpl_vars['query'][0]); $ann = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE status = 1 AND (page = ?s OR page = "*")', $this->_tpl_vars['query'][0]);
foreach ($ann as $k => $v) foreach ($ann as $k => $v)
$ann[$k]['text'] = Util::localizedString($v, 'text'); {
if ($t = Util::localizedString($v, 'text'))
$ann[$k]['text'] = Util::jsEscape($t);
else
unset($ann[$k]);
}
$this->_tpl_vars['announcements'] = $ann; $this->_tpl_vars['announcements'] = $ann;
} }
@@ -1499,9 +1504,7 @@ class Util
{ {
$_ = decBin($val); $_ = decBin($val);
while (fMod(strLen($_), 4)) // in 4-blocks while (fMod(strLen($_), 4)) // in 4-blocks
{
$_ = '0'.$_; $_ = '0'.$_;
}
return 'b'.strToUpper($_); return 'b'.strToUpper($_);
} }
@@ -1638,17 +1641,20 @@ class Util
$jsonStats = []; $jsonStats = [];
for ($h = 1; $h <= 3; $h++) for ($h = 1; $h <= 3; $h++)
{ {
$obj = $enchant['object'.$h];
$val = $enchant['amount'.$h];
if (isset($amountOverride)) // itemSuffixes have dynamic amount if (isset($amountOverride)) // itemSuffixes have dynamic amount
$enchant['amount'.$h] = $amountOverride; $val = $amountOverride;
switch ($enchant['type'.$h]) switch ($enchant['type'.$h])
{ {
case 2: case 2:
@$jsonStats[ITEM_MOD_WEAPON_DMG] += $enchant['amount'.$h]; @$jsonStats[ITEM_MOD_WEAPON_DMG] += $val;
break; break;
case 3: case 3:
case 7: case 7:
$spl = new SpellList(array(['s.id', (int)$enchant['object'.$h]])); $spl = new SpellList(array(['s.id', (int)$obj]));
$gains = $spl->getStatGain(); $gains = $spl->getStatGain();
foreach ($gains as $gain) foreach ($gains as $gain)
@@ -1656,33 +1662,36 @@ class Util
@$jsonStats[$k] += $v; @$jsonStats[$k] += $v;
break; break;
case 4: case 4:
switch ($enchant['object'.$h]) switch ($obj)
{ {
case 0: // Physical case 0: // Physical
@$jsonStats[ITEM_MOD_ARMOR] += $enchant['amount'.$h]; @$jsonStats[ITEM_MOD_ARMOR] += $val;
break; break;
case 1: // Holy case 1: // Holy
@$jsonStats[ITEM_MOD_HOLY_RESISTANCE] += $enchant['amount'.$h]; @$jsonStats[ITEM_MOD_HOLY_RESISTANCE] += $val;
break; break;
case 2: // Fire case 2: // Fire
@$jsonStats[ITEM_MOD_FIRE_RESISTANCE] += $enchant['amount'.$h]; @$jsonStats[ITEM_MOD_FIRE_RESISTANCE] += $val;
break; break;
case 3: // Nature case 3: // Nature
@$jsonStats[ITEM_MOD_NATURE_RESISTANCE] += $enchant['amount'.$h]; @$jsonStats[ITEM_MOD_NATURE_RESISTANCE] += $val;
break; break;
case 4: // Frost case 4: // Frost
@$jsonStats[ITEM_MOD_FROST_RESISTANCE] += $enchant['amount'.$h]; @$jsonStats[ITEM_MOD_FROST_RESISTANCE] += $val;
break; break;
case 5: // Shadow case 5: // Shadow
@$jsonStats[ITEM_MOD_SHADOW_RESISTANCE] += $enchant['amount'.$h]; @$jsonStats[ITEM_MOD_SHADOW_RESISTANCE] += $val;
break; break;
case 6: // Arcane case 6: // Arcane
@$jsonStats[ITEM_MOD_ARCANE_RESISTANCE] += $enchant['amount'.$h]; @$jsonStats[ITEM_MOD_ARCANE_RESISTANCE] += $val;
break; break;
} }
break; break;
case 5: case 5:
@$jsonStats[$enchant['object'.$h]] += $enchant['amount'.$h]; if ($obj == ITEM_MOD_ATTACK_POWER)
@$jsonStats[ITEM_MOD_RANGED_ATTACK_POWER] += $val;
@$jsonStats[$obj] += $val;
break; break;
} }
} }

View File

@@ -0,0 +1,14 @@
ALTER TABLE `aowow_announcements` ADD COLUMN `status` tinyint(4) NOT NULL COMMENT '0:disabled; 1:enabled; 2:deleted' AFTER `status`;
ALTER TABLE `aowow_announcements` ADD COLUMN `mode` tinyint(4) NOT NULL COMMENT '0:pageTop; 1:contentTop' AFTER `status`;
UPDATE `aowow_announcements` SET
`status` = ((`flags` & 0xF0) >> 4),
`mode` = (`flags` & 0xF)
WHERE 1;
UPDATE `aowow_announcements` SET
`text_loc0` = IF(`text_loc0` <> '', CONCAT('$', `text_loc0`), ''),
`text_loc2` = IF(`text_loc2` <> '', CONCAT('$', `text_loc2`), ''),
`text_loc3` = IF(`text_loc3` <> '', CONCAT('$', `text_loc3`), ''),
`text_loc6` = IF(`text_loc6` <> '', CONCAT('$', `text_loc6`), ''),
`text_loc8` = IF(`text_loc8` <> '', CONCAT('$', `text_loc8`), '')
WHERE `flags` & 0xF00;
ALTER TABLE `aowow_announcements` DROP COLUMN `flags`;

View File

@@ -1,18 +1,15 @@
{strip} {strip}
{math equation="abs(x)" x=$an.id assign="pId"} {math equation="abs(x)" x=$an.id assign="pId"}
{math equation="(x & 0xF)" x=$an.flags assign="mode"}
{math equation="(x & 0xF0) >> 4" x=$an.flags assign="status"}
{math equation="(x & 0xF00) >> 8" x=$an.flags assign="jsVar"}
{/strip} {/strip}
<div id="announcement-{$pId}"></div> <div id="announcement-{$pId}"></div>
<script type="text/javascript"> <script type="text/javascript">
new Announcement({ldelim} new Announcement({ldelim}
parent: 'announcement-{$pId}', parent: 'announcement-{$pId}',
id: {$an.id}, id: {$an.id},
text: {if $jsVar}{$an.text}{else}'{$an.text}'{/if}, text: {if $an.text[0] == '$'}{$an.text|substr:1}{else}'{$an.text}'{/if},
name: '{$an.name}', name: '{$an.name}',
style: '{$an.style}', style: '{$an.style}',
status: {$status}, status: {$an.status},
mode: {$mode} mode: {$an.mode}
{rdelim}); {rdelim});
</script> </script>