mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Misc/Errors
* Item/XML
- fixed setting typeId when lookup was item name
- fixed lookup by name with utf8-chars
* Items
- do not display page for invalid categories
* NPC
- fixed reputation display
* Quest
- broke infinite loop occuring when quest is in chain with itself
* Filters
- handle different sizes of cr, crs and crv passed
This commit is contained in:
@@ -818,13 +818,32 @@ abstract class Filter
|
|||||||
if (strpos($term, $c.'=') === 0)
|
if (strpos($term, $c.'=') === 0)
|
||||||
{
|
{
|
||||||
$$c = explode(':', explode('=', $term)[1]);
|
$$c = explode(':', explode('=', $term)[1]);
|
||||||
$this->formData['setCriteria'][$c] = $$c; // todo (high): move to checks
|
|
||||||
unset($tmp[$i]);
|
unset($tmp[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = 0; $i < max(count($cr), count($crv), count($crs)); $i++)
|
// handle erronous input
|
||||||
|
if (count($cr) != count($crv) || count($cr) != count($crs))
|
||||||
|
{
|
||||||
|
// use min provided criterion as basis
|
||||||
|
$min = min(count($cr), count($crv), count($crs));
|
||||||
|
if (count($cr) > $min)
|
||||||
|
array_splice($cr, $min);
|
||||||
|
|
||||||
|
if (count($crv) > $min)
|
||||||
|
array_splice($crv, $min);
|
||||||
|
|
||||||
|
if (count($crs) > $min)
|
||||||
|
array_splice($crs, $min);
|
||||||
|
|
||||||
|
$this->error = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (self::$criteria as $c)
|
||||||
|
$this->formData['setCriteria'][$c] = $$c;
|
||||||
|
|
||||||
|
for ($i = 0; $i < count($cr); $i++)
|
||||||
{
|
{
|
||||||
if (!isset($cr[$i]) || !isset($crs[$i]) || !isset($crv[$i]) ||
|
if (!isset($cr[$i]) || !isset($crs[$i]) || !isset($crv[$i]) ||
|
||||||
!intVal($cr[$i]) || $crs[$i] === '' || $crv[$i] === '')
|
!intVal($cr[$i]) || $crs[$i] === '' || $crv[$i] === '')
|
||||||
|
|||||||
@@ -229,7 +229,8 @@ class GenericPage
|
|||||||
case 0: // no params works always
|
case 0: // no params works always
|
||||||
return true;
|
return true;
|
||||||
case 1: // null is valid || value in a 1-dim-array || key for a n-dim-array
|
case 1: // null is valid || value in a 1-dim-array || key for a n-dim-array
|
||||||
return $this->category[0] === null || in_array($this->category[0], $this->validCats) || !empty($this->validCats[$this->category[0]]);
|
$filtered = array_filter($this->validCats, function ($x) { return is_int($x); });
|
||||||
|
return $this->category[0] === null || in_array($this->category[0], $filtered) || !empty($this->validCats[$this->category[0]]);
|
||||||
case 2: // first param has to be a key. otherwise invalid
|
case 2: // first param has to be a key. otherwise invalid
|
||||||
if (!isset($this->validCats[$this->category[0]]))
|
if (!isset($this->validCats[$this->category[0]]))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -54,16 +54,16 @@ class ItemPage extends genericPage
|
|||||||
|
|
||||||
// allow lookup by name for xml
|
// allow lookup by name for xml
|
||||||
if (!is_numeric($param))
|
if (!is_numeric($param))
|
||||||
$conditions = [['name_loc'.User::$localeId, utf8_encode(urldecode($param))]];
|
$conditions = [['name_loc'.User::$localeId, urldecode($param)]];
|
||||||
|
|
||||||
if (!is_numeric($param))
|
|
||||||
$this->typeId = $this->subject->id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->subject = new ItemList($conditions);
|
$this->subject = new ItemList($conditions);
|
||||||
if ($this->subject->error)
|
if ($this->subject->error)
|
||||||
$this->notFound();
|
$this->notFound();
|
||||||
|
|
||||||
|
if (!is_numeric($param))
|
||||||
|
$this->typeId = $this->subject->id;
|
||||||
|
|
||||||
$this->name = $this->subject->getField('name', true);
|
$this->name = $this->subject->getField('name', true);
|
||||||
|
|
||||||
if ($this->mode == CACHE_TYPE_PAGE)
|
if ($this->mode == CACHE_TYPE_PAGE)
|
||||||
|
|||||||
@@ -881,7 +881,10 @@ class NpcPage extends GenericPage
|
|||||||
|
|
||||||
if ($row['spillover'])
|
if ($row['spillover'])
|
||||||
{
|
{
|
||||||
$spillover[$factions->getField('cat')] = [intVal(array_sum($row['qty']) / 2), $row['maxRank']];
|
$spillover[$factions->getField('cat')] = array(
|
||||||
|
[ $set['qty'][0] / 2, $set['qty'][1] / 2 ],
|
||||||
|
$row['maxRank']
|
||||||
|
);
|
||||||
$set['spillover'] = $factions->getField('cat');
|
$set['spillover'] = $factions->getField('cat');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -258,8 +258,14 @@ class QuestPage extends GenericPage
|
|||||||
$_ = $chain[0][0];
|
$_ = $chain[0][0];
|
||||||
while ($_)
|
while ($_)
|
||||||
{
|
{
|
||||||
if ($_ = DB::Aowow()->selectRow('SELECT id AS typeId, name_loc0, name_loc2, name_loc3, name_loc6, name_loc8, reqRaceMask FROM ?_quests WHERE nextQuestIdChain = ?d', $_['typeId']))
|
if ($_ = DB::Aowow()->selectRow('SELECT id AS typeId, IF(id = nextQuestIdChain, 1, 0) AS error, name_loc0, name_loc2, name_loc3, name_loc6, name_loc8, reqRaceMask FROM ?_quests WHERE nextQuestIdChain = ?d', $_['typeId']))
|
||||||
{
|
{
|
||||||
|
if ($_['error'])
|
||||||
|
{
|
||||||
|
trigger_error('Quest '.$_['typeId'].' is in a chain with itself');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$n = Util::localizedString($_, 'name');
|
$n = Util::localizedString($_, 'name');
|
||||||
array_unshift($chain, array(
|
array_unshift($chain, array(
|
||||||
array(
|
array(
|
||||||
@@ -275,8 +281,11 @@ class QuestPage extends GenericPage
|
|||||||
$_ = end($chain)[0];
|
$_ = end($chain)[0];
|
||||||
while ($_)
|
while ($_)
|
||||||
{
|
{
|
||||||
if ($_ = DB::Aowow()->selectRow('SELECT id AS typeId, name_loc0, name_loc2, name_loc3, name_loc6, name_loc8, reqRaceMask, nextQuestIdChain AS _next FROM ?_quests WHERE id = ?d', $_['_next']))
|
if ($_ = DB::Aowow()->selectRow('SELECT id AS typeId, IF(id = nextQuestIdChain, 1, 0) AS error, name_loc0, name_loc2, name_loc3, name_loc6, name_loc8, reqRaceMask, nextQuestIdChain AS _next FROM ?_quests WHERE id = ?d', $_['_next']))
|
||||||
{
|
{
|
||||||
|
if ($_['error']) // error already triggered
|
||||||
|
break;
|
||||||
|
|
||||||
$n = Util::localizedString($_, 'name');
|
$n = Util::localizedString($_, 'name');
|
||||||
array_push($chain, array(
|
array_push($chain, array(
|
||||||
array(
|
array(
|
||||||
@@ -471,6 +480,7 @@ class QuestPage extends GenericPage
|
|||||||
'id' => $i,
|
'id' => $i,
|
||||||
'name' => $pair[1] ?: Util::localizedString($olGOData->getEntry($i), 'name'),
|
'name' => $pair[1] ?: Util::localizedString($olGOData->getEntry($i), 'name'),
|
||||||
'qty' => $pair[0] > 1 ? $pair[0] : 0,
|
'qty' => $pair[0] > 1 ? $pair[0] : 0,
|
||||||
|
'extraText' => ''
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,9 +92,9 @@ if ($this->reputation):
|
|||||||
|
|
||||||
foreach ($set[1] as $itr):
|
foreach ($set[1] as $itr):
|
||||||
if ($itr['qty'][1] && User::isInGroup(U_GROUP_EMPLOYEE))
|
if ($itr['qty'][1] && User::isInGroup(U_GROUP_EMPLOYEE))
|
||||||
$qty = $itr['qty'][0] . sprintf(Util::$dfnString, Lang::faction('customRewRate'), ($itr['qty'][1] > 0 ? '+' : '').$itr['qty'][1]);
|
$qty = intVal($itr['qty'][0]) . sprintf(Util::$dfnString, Lang::faction('customRewRate'), ($itr['qty'][1] > 0 ? '+' : '').intVal($itr['qty'][1]));
|
||||||
else
|
else
|
||||||
$qty = array_sum($itr['qty']);
|
$qty = intVal(array_sum($itr['qty']));
|
||||||
|
|
||||||
echo '<li><div'.($itr['qty'][0] < 0 ? ' class="reputation-negative-amount"' : null).'><span>'.$qty.'</span> '.Lang::npc('repWith') .
|
echo '<li><div'.($itr['qty'][0] < 0 ? ' class="reputation-negative-amount"' : null).'><span>'.$qty.'</span> '.Lang::npc('repWith') .
|
||||||
' <a href="?faction='.$itr['id'].'">'.$itr['name'].'</a>'.($itr['cap'] && $itr['qty'][0] > 0 ? ' ('.sprintf(Lang::npc('stopsAt'), $itr['cap']).')' : null).'</div></li>';
|
' <a href="?faction='.$itr['id'].'">'.$itr['name'].'</a>'.($itr['cap'] && $itr['qty'][0] > 0 ? ' ('.sprintf(Lang::npc('stopsAt'), $itr['cap']).')' : null).'</div></li>';
|
||||||
|
|||||||
Reference in New Issue
Block a user