Sort zones in ?npc=... by spawn count

This commit is contained in:
jackpoz
2020-02-09 19:13:34 +01:00
committed by Sarjuuk
parent 5bb15d47d7
commit 1f84cae1dd

View File

@@ -666,9 +666,22 @@ trait spawnHelper
foreach ($areas as $f => &$floor)
$floor['count'] = count($floor['coords']) - (!empty($wpSum[$a][$f]) ? $wpSum[$a][$f] : 0);
uasort($data, array($this, 'sortBySpawnCount'));
$this->spawnResult[SPAWNINFO_FULL] = $data;
}
private function sortBySpawnCount($a, $b)
{
$aCount = current($a)['count'];
$bCount = current($b)['count'];
if ($aCount == $bCount) {
return 0;
}
return ($aCount < $bCount) ? 1 : -1;
}
private function createZoneSpawns() // [zoneId1, zoneId2, ..] for locations-column in listview
{
$res = DB::Aowow()->selectCol("SELECT typeId AS ARRAY_KEY, GROUP_CONCAT(DISTINCT areaId) FROM ?_spawns WHERE type = ?d AND typeId IN (?a) GROUP BY typeId", self::$type, $this->getfoundIDs());