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:
Sarjuuk
2017-04-08 03:05:30 +02:00
parent bb00355ca3
commit 33b1e4a978
6 changed files with 45 additions and 12 deletions

View File

@@ -229,7 +229,8 @@ class GenericPage
case 0: // no params works always
return true;
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
if (!isset($this->validCats[$this->category[0]]))
return false;

View File

@@ -54,16 +54,16 @@ class ItemPage extends genericPage
// allow lookup by name for xml
if (!is_numeric($param))
$conditions = [['name_loc'.User::$localeId, utf8_encode(urldecode($param))]];
if (!is_numeric($param))
$this->typeId = $this->subject->id;
$conditions = [['name_loc'.User::$localeId, urldecode($param)]];
}
$this->subject = new ItemList($conditions);
if ($this->subject->error)
$this->notFound();
if (!is_numeric($param))
$this->typeId = $this->subject->id;
$this->name = $this->subject->getField('name', true);
if ($this->mode == CACHE_TYPE_PAGE)

View File

@@ -881,7 +881,10 @@ class NpcPage extends GenericPage
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');
}

View File

@@ -258,8 +258,14 @@ class QuestPage extends GenericPage
$_ = $chain[0][0];
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');
array_unshift($chain, array(
array(
@@ -275,8 +281,11 @@ class QuestPage extends GenericPage
$_ = end($chain)[0];
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');
array_push($chain, array(
array(
@@ -471,6 +480,7 @@ class QuestPage extends GenericPage
'id' => $i,
'name' => $pair[1] ?: Util::localizedString($olGOData->getEntry($i), 'name'),
'qty' => $pair[0] > 1 ? $pair[0] : 0,
'extraText' => ''
);
}
}