diff --git a/includes/defines.php b/includes/defines.php index f1edd788..84d6a481 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -183,6 +183,7 @@ define('ITEMINFO_MODEL', 0x20); define('NPCINFO_TAMEABLE', 0x1); define('NPCINFO_MODEL', 0x2); +define('NPCINFO_REP', 0x4); define('ACHIEVEMENTINFO_PROFILE', 0x1); diff --git a/includes/shared.php b/includes/shared.php index 334e4e22..b134a807 100644 --- a/includes/shared.php +++ b/includes/shared.php @@ -1,6 +1,6 @@ [], '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; diff --git a/includes/types/creature.class.php b/includes/types/creature.class.php index 0356fb6d..58256930 100644 --- a/includes/types/creature.class.php +++ b/includes/types/creature.class.php @@ -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 diff --git a/includes/types/quest.class.php b/includes/types/quest.class.php index 1f1a852e..1a3ac60a 100644 --- a/includes/types/quest.class.php +++ b/includes/types/quest.class.php @@ -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, '<']], diff --git a/pages/npcs.php b/pages/npcs.php index ccea9ddf..488c4ec5 100644 --- a/pages/npcs.php +++ b/pages/npcs.php @@ -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) diff --git a/pages/quests.php b/pages/quests.php index d982d5a1..6827df79 100644 --- a/pages/quests.php +++ b/pages/quests.php @@ -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