NPCs / Quests

display reputattion change in list when using corresponding filters
This commit is contained in:
Sarjuuk
2015-07-20 17:01:39 +02:00
parent 7276fed9e7
commit 5239cbd293
7 changed files with 50 additions and 9 deletions

View File

@@ -183,6 +183,7 @@ define('ITEMINFO_MODEL', 0x20);
define('NPCINFO_TAMEABLE', 0x1);
define('NPCINFO_MODEL', 0x2);
define('NPCINFO_REP', 0x4);
define('ACHIEVEMENTINFO_PROFILE', 0x1);

View File

@@ -1,6 +1,6 @@
<?php
define('AOWOW_REVISION', 7);
define('AOWOW_REVISION', 8);
define('CLI', PHP_SAPI === 'cli');

View File

@@ -667,10 +667,11 @@ abstract class Filter
protected $fiData = ['c' => [], 'v' =>[]];
protected $formData = array( // data to fill form fields
'form' => [], // base form - unsanitized
'setCriteria' => [], // dynamic criteria list - index checked
'setWeights' => [], // dynamic weights list - index checked
'extraCols' => [] // extra columns for LV - added as required
'form' => [], // base form - unsanitized
'setCriteria' => [], // dynamic criteria list - index checked
'setWeights' => [], // dynamic weights list - index checked
'extraCols' => [], // extra columns for LV - added as required
'reputationCols' => [] // simlar and exclusive to extraCols - added as required
);
// parse the provided request into a usable format; recall self with GET-params if nessecary
@@ -856,6 +857,7 @@ abstract class Filter
$form[$name] = $raw ? $data : 'fi_setWeights('.Util::toJSON($data).', 0, 1, 1);';
break;
case 'form':
case 'reputationCols':
if ($key == $name) // only if explicitely specified
$form[$name] = $data;
break;

View File

@@ -161,9 +161,21 @@ class CreatureList extends BaseType
*
* NPCINFO_TAMEABLE (0x1): include texture & react
* NPCINFO_MODEL (0x2):
* NPCINFO_REP (0x4): include repreward
*/
$data = [];
$data = [];
$rewRep = [];
if ($addInfoMask & NPCINFO_REP)
{
$rewRep = DB::World()->selectCol('
SELECT creature_id AS ARRAY_KEY, RewOnKillRepFaction1 AS ARRAY_KEY2, RewOnKillRepValue1 FROM creature_onkill_reputation WHERE creature_id IN (?a) AND RewOnKillRepFaction1 > 0 UNION
SELECT creature_id AS ARRAY_KEY, RewOnKillRepFaction2 AS ARRAY_KEY2, RewOnKillRepValue2 FROM creature_onkill_reputation WHERE creature_id IN (?a) AND RewOnKillRepFaction2 > 0',
$this->getFoundIDs(),
$this->getFoundIDs()
);
}
foreach ($this->iterate() as $__)
{
@@ -215,6 +227,14 @@ class CreatureList extends BaseType
if ($addInfoMask & NPCINFO_TAMEABLE) // only first skin of first model ... we're omitting potentially 11 skins here .. but the lv accepts only one .. w/e
$data[$this->id]['skin'] = $this->curTpl['textureString'];
if ($addInfoMask & NPCINFO_REP)
{
$data[$this->id]['reprewards'] = [];
if ($rewRep[$this->id])
foreach ($rewRep[$this->id] as $fac => $val)
$data[$this->id]['reprewards'][] = [$fac, $val];
}
}
}
@@ -427,6 +447,9 @@ class CreatureListFilter extends Filter
case 42: // increasesrepwith [enum]
if (in_array($cr[1], $this->enums[3])) // reuse
{
if ($_ = DB::Aowow()->selectRow('SELECT * FROM ?_factions WHERE id = ?d', $cr[1]))
$this->formData['reputationCols'][] = [$cr[1], Util::localizedString($_, 'name')];
if ($cIds = DB::World()->selectCol('SELECT creature_id FROM creature_onkill_reputation WHERE (RewOnKillRepFaction1 = ?d AND RewOnKillRepValue1 > 0) OR (RewOnKillRepFaction2 = ?d AND RewOnKillRepValue2 > 0)', $cr[1], $cr[1]))
return ['id', $cIds];
else
@@ -437,6 +460,9 @@ class CreatureListFilter extends Filter
case 43: // decreasesrepwith [enum]
if (in_array($cr[1], $this->enums[3])) // reuse
{
if ($_ = DB::Aowow()->selectRow('SELECT * FROM ?_factions WHERE id = ?d', $cr[1]))
$this->formData['reputationCols'][] = [$cr[1], Util::localizedString($_, 'name')];
if ($cIds = DB::World()->selectCol('SELECT creature_id FROM creature_onkill_reputation WHERE (RewOnKillRepFaction1 = ?d AND RewOnKillRepValue1 < 0) OR (RewOnKillRepFaction2 = ?d AND RewOnKillRepValue2 < 0)', $cr[1], $cr[1]))
return ['id', $cIds];
else

View File

@@ -457,6 +457,9 @@ class QuestListFilter extends Filter
case 1: // increasesrepwith
if ($this->isSaneNumeric($cr[1]) && $cr[1] > 0)
{
if ($_ = DB::Aowow()->selectRow('SELECT * FROM ?_factions WHERE id = ?d', $cr[1]))
$this->formData['reputationCols'][] = [$cr[1], Util::localizedString($_, 'name')];
return [
'OR',
['AND', ['rewardFactionId1', $cr[1]], ['rewardFactionValue1', 0, '>']],
@@ -470,6 +473,9 @@ class QuestListFilter extends Filter
case 10: // decreasesrepwith
if ($this->isSaneNumeric($cr[1]) && $cr[1] > 0)
{
if ($_ = DB::Aowow()->selectRow('SELECT * FROM ?_factions WHERE id = ?d', $cr[1]))
$this->formData['reputationCols'][] = [$cr[1], Util::localizedString($_, 'name')];
return [
'OR',
['AND', ['rewardFactionId1', $cr[1]], ['rewardFactionValue1', 0, '<']],

View File

@@ -57,13 +57,17 @@ class NpcsPage extends GenericPage
$this->filter['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL;
$this->filter['fi'] = $this->filterObj->getForm();
$repCols = $this->filterObj->getForm('reputationCols');
$lv = array(
'file' => 'creature',
'data' => $npcs->getListviewData(), // listview content
'data' => $npcs->getListviewData($repCols ? NPCINFO_REP : 0x0),
'params' => []
);
if (!empty($this->filter['fi']['extraCols']))
if ($repCols)
$lv['params']['extraCols'] = '$fi_getReputationCols('.Util::toJSON($repCols).')';
else if (!empty($this->filter['fi']['extraCols']))
$lv['params']['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)';
if ($this->category)

View File

@@ -60,7 +60,9 @@ class QuestsPage extends GenericPage
'params' => []
);
if (!empty($this->filter['fi']['extraCols']))
if ($_ = $this->filterObj->getForm('reputationCols'))
$lv['params']['extraCols'] = '$fi_getReputationCols('.Util::toJSON($_).')';
else if (!empty($this->filter['fi']['extraCols']))
$lv['params']['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)';
// create note if search limit was exceeded