error-announces

rough draft for gameobjects (searchable, tooltips)
more tabs for item.php
This commit is contained in:
Sarjuuk
2013-11-28 20:42:26 +01:00
parent 5e785d6c78
commit 2830fe97fc
19 changed files with 866 additions and 172 deletions

View File

@@ -54,6 +54,9 @@ foreach ($AoWoWconf['characters'] as $realm => $charDBInfo)
// create Template-Object
$smarty = new SmartyAoWoW($AoWoWconf);
// attach template to util (yes bandaid, shut up and code me a fix)
Util::$pageTemplate = &$smarty;
// Setup Session
if (isset($_COOKIE[COOKIE_AUTH]))
{

View File

@@ -13,8 +13,11 @@ class AchievementList extends BaseType
public $criteria = [];
public $tooltip = [];
protected $queryBase = 'SELECT *, id AS ARRAY_KEY FROM ?_achievement a';
protected $queryOpts = ['a' => ['o' => 'orderInGroup ASC']];
protected $queryBase = 'SELECT `a`.*, `a`.`id` AS ARRAY_KEY FROM ?_achievement a';
protected $queryOpts = array(
'a' => ['o' => 'orderInGroup ASC'],
'ac' => ['j' => ['?_achievementcriteria AS `ac` ON `ac`.`refAchievement` = `a`.`id`', true], 'g' => '`a`.`id`']
);
public function __construct($conditions = [], $applyFilter = false)
{
@@ -267,7 +270,7 @@ class AchievementListFilter extends Filter
}
unset($cr);
$this->error = 1;
$this->error = true;
return [1];
}

View File

@@ -6,14 +6,74 @@ if (!defined('AOWOW_REVISION'))
class GameObjectList extends BaseType
{
use listviewHelper, spawnHelper;
public static $type = TYPE_OBJECT;
protected $queryBase = 'SELECT *, go.entry AS ARRAY_KEY FROM gameobject_template go';
protected $queryOpts = array(
'go' => [['lg']],
'lg' => ['j' => ['locales_gameobject lq ON go.entry = lq.entry', true]]
'lg' => ['j' => ['locales_gameobject lq ON go.entry = lq.entry', true]],
'l' => ['j' => ['?_lock l ON l.id = IF(go.type = 3, data0, null)', true], 's' => ', l.type1, l.properties1, l.reqSkill1, l.type2, l.properties2, l.reqSkill2']
);
public function __construct($conditions = [], $applyFilter = false)
{
parent::__construct($conditions, $applyFilter);
if ($this->error)
return;
// post processing
// most of this will be obsolete, when gameobjects get their own table
foreach ($this->iterate() as $_id => &$curTpl)
{
switch ($curTpl['type'])
{
case OBJECT_CHEST:
$curTpl['lootId'] = $curTpl['data1'];
$curTpl['lootStack'] = [$curTpl['data4'], $curTpl['data5']];
$curTpl['lockId'] = $curTpl['data0'];
if (!isset($curTpl['properties1']))
break;
if ($curTpl['properties1'] == LOCK_PROPERTY_HERBALISM)
{
$curTpl['reqSkill'] = $curTpl['reqSkill1'];
$curTpl['type'] = -3;
}
else if ($curTpl['properties1'] == LOCK_PROPERTY_MINING)
{
$curTpl['reqSkill'] = $curTpl['reqSkill1'];
$curTpl['type'] = -4;
}
else if ($curTpl['properties1'] == LOCK_PROPERTY_FOOTLOCKER)
{
$curTpl['reqSkill'] = $curTpl['reqSkill1'];
$curTpl['type'] = -5;
}
else if( $curTpl['properties2'] == LOCK_PROPERTY_FOOTLOCKER)
{
$curTpl['reqSkill'] = $curTpl['reqSkill2'];
$curTpl['type'] = -5;
}
break;
case OBJECT_FISHINGHOLE:
$curTpl['lootId'] = $curTpl['data1'];
$curTpl['lootStack'] = [$curTpl['data2'], $curTpl['data3']];
break;
default: // adding more, when i need them
$curTpl['lockId'] = 0;
break;
}
for ($i = 0; $i < 24; $i++) // kill indescriptive/unused fields
unset($curTpl['data'.$i]);
}
}
public static function getName($id)
{
$n = DB::Aowow()->SelectRow('
@@ -36,10 +96,47 @@ class GameObjectList extends BaseType
return Util::localizedString($n, 'name');
}
public function getListviewData() { }
public function addGlobalsToJScript(&$template, $addMask = 0) { }
public function renderTooltip() { }
public function getListviewData()
{
$data = [];
foreach ($this->iterate() as $__)
{
$data[$this->id] = array(
'id' => $this->id,
'name' => $this->getField('name', true),
'type' => $this->curTpl['type']
);
if (!empty($this->curTpl['reqSkill']))
$data[$this->id]['skill'] = $this->curTpl['reqSkill'];
}
return $data;
}
public function renderTooltip($interactive = false)
{
if (!$this->curTpl)
return array();
if (isset($this->tooltips[$this->id]))
return $this->tooltips[$this->id];
$x = '<table>';
$x .= '<tr><td><b class="q">'.$this->getField('name', true).'</b></td></tr>';
$x .= '<tr><td>[TYPE '.$this->curTpl['type'].']</td></tr>';
if ($locks = Lang::getLocks($this->curTpl['lockId']))
foreach ($locks as $l)
$x .= '<tr><td>'.$l.'</td></tr>';
$x .= '</table>';
$this->tooltips[$this->id] = $x;
return $this->tooltips[$this->id];
}
public function addGlobalsToJScript(&$template, $addMask = 0) { }
}
?>

View File

@@ -122,7 +122,7 @@ class ItemsetListFilter extends Filter
}
unset($cr);
$this->error = 1;
$this->error = true;
return [1];
}

View File

@@ -1840,7 +1840,7 @@ class SpellListFilter extends Filter
}
unset($cr);
$this->error = 1;
$this->error = true;
return [1];
}

View File

@@ -66,7 +66,7 @@ class Lang
public static function getLocks($lockId, $interactive = false)
{
$locks = [];
$lock = DB::Aowow()->selectRow('SELECT * FROM ?_lock WHERE id = ?d', $lockId);
$lock = DB::Aowow()->selectRow('SELECT * FROM ?_lock WHERE id = ?d', $lockId);
if (!$lock)
return '';
@@ -279,6 +279,7 @@ class SmartyAoWoW extends Smarty
{
private $config = [];
private $jsGlobals = [];
private $errors = [];
public function __construct($config)
{
@@ -319,6 +320,12 @@ class SmartyAoWoW extends Smarty
$this->_tpl_vars['page'][$var] = $val;
}
// use, if you want to alert the staff to a problem with Trinity
public function internalError($str)
{
$this->errors[] = $str;
}
public function display($tpl)
{
$tv = &$this->_tpl_vars;
@@ -355,19 +362,37 @@ class SmartyAoWoW extends Smarty
}
}
// display occured errors
if (User::isInGroup(U_GROUP_STAFF) && $this->errors)
{
if (!isset($tv['announcements']))
$tv['announcements'] = [];
$tv['announcements'][] = array(
'id' => 0,
'mode' => 1,
'status' => 1,
'name' => 'internal error',
'style' => 'padding-left: 45px; background-image: url(template/images/report.gif); background-size: 15px 15px; background-position: 10px center; border: dashed 2px #C03030;',
'text' => '<span id="inputbox-error">- '.implode("<br>- ", $this->errors).'</span>',
);
}
// fetch announcements
if ($tv['query'][0] && !preg_match('/[^a-z]/i', $tv['query'][0]))
{
if (!isset($tv['announcements']))
$tv['announcements'] = [];
$ann = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE status = 1 AND (page = ? OR page = "*")', $tv['query'][0]);
foreach ($ann as $k => $v)
{
if ($t = Util::localizedString($v, 'text'))
{
$ann[$k]['text'] = Util::jsEscape($t);
else
unset($ann[$k]);
$tv['announcements'][] = $ann[$k];
}
}
$tv['announcements'] = $ann;
}
$this->applyGlobals();
@@ -1233,6 +1258,8 @@ class Util
public static $tcEncoding = '0zMcmVokRsaqbdrfwihuGINALpTjnyxtgevElBCDFHJKOPQSUWXYZ123456789';
public static $pageTemplate = null;
private static $execTime = 0.0;
public static function execTime($set = false)
@@ -1676,7 +1703,7 @@ class Util
case 0:
return true;
case 1:
return !$keys[0] || isset($struct[$keys[0]]);
return (is_int($keys) && in_array($keys, $struct)) || (is_array($keys) && isset($struct[$keys[0]]));
case 2:
if (!isset($struct[$keys[0]]))
return false;
@@ -1840,11 +1867,17 @@ class Util
$set['max'] = $entry['maxcount'];
}
if (!isset($groupChances[$entry['groupid']]))
{
$groupChances[$entry['groupid']] = 0;
$nGroupEquals[$entry['groupid']] = 0;
}
if ($set['quest'] || !$set['group'])
$set['groupChance'] = abs($entry['ChanceOrQuestChance']);
else if ($entry['groupid'] && !$entry['ChanceOrQuestChance'])
{
@$nGroupEquals[$entry['groupid']]++;
$nGroupEquals[$entry['groupid']]++;
$set['groupChance'] = &$groupChances[$entry['groupid']];
}
else if ($entry['groupid'] && $entry['ChanceOrQuestChance'])
@@ -1854,10 +1887,8 @@ class Util
}
else // shouldn't happened
{
if (User::isInGroup(U_GROUP_DEV))
die(var_dump($entry));
else
continue;
Util::$pageTemplate->internalError('Loot by LootId: unhandled case in calculating chance for item '.$entry['item'].'!');
continue;
}
$loot[] = $set;
@@ -1868,8 +1899,11 @@ class Util
$sum = $groupChances[$k];
if (!$sum)
$sum = 0;
else if ($sum > 100) // group has > 100% dropchance .. hmm, display some kind of error..?
else if ($sum > 100)
{
Util::$pageTemplate->internalError('Loot by LootId: entry '.$lootId.' / group '.$k.' has a total chance of '.$sum.'%. Some items cannot drop!');
$sum = 100;
}
$cnt = empty($nGroupEquals[$k]) ? 1 : $nGroupEquals[$k];
@@ -1879,8 +1913,7 @@ class Util
return [$loot, array_unique($rawItems)];
}
// v this is bullshit, but as long as there is no integral template class..
public static function handleLoot($table, $entry, &$pageTemplate, $debug = false)
public static function handleLoot($table, $entry, $debug = false, &$debugCols = [])
{
$lv = [];
$loot = null;
@@ -1902,7 +1935,7 @@ class Util
return $lv;
$items = new ItemList(array(['i.id', $struct[1]]));
$items->addGlobalsToJscript($pageTemplate, GLOBALINFO_SELF | GLOBALINFO_RELATED);
$items->addGlobalsToJscript(Util::$pageTemplate, GLOBALINFO_SELF | GLOBALINFO_RELATED);
$foo = $items->getListviewData();
// assign listview LV rows to loot rows, not the other way round! The same item may be contained multiple times
@@ -1950,7 +1983,7 @@ class Util
);
$lv[] = array_merge($base, $data);
$pageTemplate->extendGlobalData(TYPE_ITEM, [$loot['content'] => $data]);
Util::$pageTemplate->extendGlobalData(TYPE_ITEM, [$loot['content'] => $data]);
}
}
@@ -1973,6 +2006,20 @@ class Util
$_['percent'] = 100;
}
}
else
{
$fields = ['mode', 'reference'];
$set = 0;
foreach ($lv as $foo)
foreach ($fields as $idx => $field)
if (!empty($foo[$field]))
$set |= 1 << $idx;
$debugCols[] = "Listview.funcBox.createSimpleCol('group', 'Group', '7%', 'group')";
foreach ($fields as $idx => $field)
if ($set & (1 << $idx))
$debugCols[] = "Listview.funcBox.createSimpleCol('".$field."', '".Util::ucFirst($field)."', '7%', '".$field."')";
}
return $lv;
}
@@ -2009,13 +2056,15 @@ class Util
foreach ($refs as $rId => $ref)
{
// errör: item/ref is in group 0 without a chance set
// check for possible database inconsistencies
if (!$ref['chance'] && !$ref['isGrouped'])
continue; // todo (low): create dubug output
Util::$pageTemplate->internalError('Loot by Item: ungrouped Item/Ref '.$ref['item'].' has 0% chance assigned!');
// errör: item/ref is in group with >100% chance across all items contained
if ($ref['isGrouped'] && $ref['sumChance'] > 100)
continue; // todo (low): create dubug output
Util::$pageTemplate->internalError('Loot by Item: group with Item/Ref '.$ref['item'].' has '.$ref['sumChance'].'% total chance! Some items cannot drop!');
if ($ref['isGrouped'] && $ref['sumChance'] == 100 && !$ref['chance'])
Util::$pageTemplate->internalError('Loot by Item: Item/Ref '.$ref['item'].' with adaptive chance cannot drop. Group already at 100%!');
$chance = ($ref['chance'] ? $ref['chance'] : (100 - $ref['sumChance']) / $ref['nZeroItems']) / 100;