From bd5200de85ba918bbe5f37cfb9225effaeb29498 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Fri, 5 Jul 2024 22:03:25 +0200 Subject: [PATCH] Mapper/Quests * sort zones by number of pins, most to least * always preselect zone with most pins --- pages/quest.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pages/quest.php b/pages/quest.php index 0cd0335f..1376c0b2 100644 --- a/pages/quest.php +++ b/pages/quest.php @@ -884,16 +884,26 @@ class QuestPage extends GenericPage // ..process zone data if ($mObjectives) { + // sort zones by amount of mapper points most -> least + $zoneOrder = []; + foreach ($mObjectives as $zoneId => $data) + $zoneOrder[$zoneId] = array_reduce($data['levels'], function($carry, $spawns) { foreach ($spawns as $s) { $carry += count($s['coords']); } return $carry; }); + + arsort($zoneOrder); + $zoneOrder = array_flip(array_keys($zoneOrder)); + $areas = new ZoneList(array(['id', array_keys($mObjectives)])); if (!$areas->error) { - $someIDX = 0; // todo (low): UNK value ... map priority, floor, mapId..? values seen: 0 - 3; doesn't seem to affect anything foreach ($areas->iterate() as $id => $__) { + // [zoneId, selectionPriority] - determines which map link is preselected. (highest index) + $mZones[$zoneOrder[$id]] = [$id, count($zoneOrder) - $zoneOrder[$id]]; $mObjectives[$id]['zone'] = $areas->getField('name', true); - $mZones[] = [$id, ++$someIDX]; } } + + ksort($mZones); } // has start & end?