diff --git a/includes/shared.php b/includes/shared.php index 8278509f..fb67b6c6 100644 --- a/includes/shared.php +++ b/includes/shared.php @@ -1,6 +1,6 @@ subject->getField('reputationIndex') != -1) // only if you can actually gain reputation by kills { // inherit siblings/children from $spillover - $cIds = DB::World()->selectCol('SELECT DISTINCT creature_id FROM creature_onkill_reputation WHERE - (RewOnKillRepValue1 > 0 AND (RewOnKillRepFaction1 = ?d{ OR (RewOnKillRepFaction1 IN (?a) AND IsTeamAward1 <> 0)})) OR - (RewOnKillRepValue2 > 0 AND (RewOnKillRepFaction2 = ?d{ OR (RewOnKillRepFaction2 IN (?a) AND IsTeamAward2 <> 0)}))', + $cRep = DB::World()->selectCol('SELECT DISTINCT creature_id AS ARRAY_KEY, qty FROM ( + SELECT creature_id, RewOnKillRepValue1 as qty FROM creature_onkill_reputation WHERE RewOnKillRepValue1 > 0 AND (RewOnKillRepFaction1 = ?d{ OR (RewOnKillRepFaction1 IN (?a) AND IsTeamAward1 <> 0)}) UNION + SELECT creature_id, RewOnKillRepValue2 as qty FROM creature_onkill_reputation WHERE RewOnKillRepValue2 > 0 AND (RewOnKillRepFaction2 = ?d{ OR (RewOnKillRepFaction2 IN (?a) AND IsTeamAward2 <> 0)}) + ) x', $this->typeId, $spillover->getFoundIDs() ?: DBSIMPLE_SKIP, $this->typeId, $spillover->getFoundIDs() ?: DBSIMPLE_SKIP ); - if ($cIds) + if ($cRep) { - $killCreatures = new CreatureList(array(['id', $cIds])); + $killCreatures = new CreatureList(array(['id', array_keys($cRep)])); if (!$killCreatures->error) { + $data = $killCreatures->getListviewData(); + foreach ($data as $id => &$d) + $d['reputation'] = $cRep[$id]; + $tab = array( 'file' => 'creature', - 'data' => $killCreatures->getListviewData(), + 'data' => $data, 'showRep' => true, - 'params' => [] + 'params' => array( + 'extraCols' => '$_', + 'sort' => "$['-reputation', 'name']" + ) ); if ($killCreatures->getMatches() > CFG_SQL_LIMIT_DEFAULT) diff --git a/template/listviews/creature.tpl.php b/template/listviews/creature.tpl.php index 635e3b32..089033b1 100644 --- a/template/listviews/creature.tpl.php +++ b/template/listviews/creature.tpl.php @@ -1,3 +1,20 @@ + +var _ = [ + { + id: 'reputation', + after: 'location', + name: LANG.rep, + tooltip: LANG.tooltip_repgain, + width: '8%', + value: 'reputation' + } +]; + + new Listview({ template:'npc', var _ = [ { diff --git a/template/listviews/quest.tpl.php b/template/listviews/quest.tpl.php index 6b42b56f..69c1e502 100644 --- a/template/listviews/quest.tpl.php +++ b/template/listviews/quest.tpl.php @@ -1,5 +1,5 @@ var _ = [ {