From b7dc2b6623be6d8cdd7002f5fb8c0f70dd56d79a Mon Sep 17 00:00:00 2001 From: Fate-JH Date: Fri, 29 Mar 2024 00:40:29 -0400 Subject: [PATCH] making .max calls safer by checking .nonEmpty first (#1185) --- .../scala/net/psforever/objects/zones/blockmap/BlockMap.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/net/psforever/objects/zones/blockmap/BlockMap.scala b/src/main/scala/net/psforever/objects/zones/blockmap/BlockMap.scala index a35d3f1c..27c7f863 100644 --- a/src/main/scala/net/psforever/objects/zones/blockmap/BlockMap.scala +++ b/src/main/scala/net/psforever/objects/zones/blockmap/BlockMap.scala @@ -93,7 +93,7 @@ class BlockMap(fullMapWidth: Int, fullMapHeight: Int, desiredSpanSize: Int) { * @return a conglomerate sector which lists all of the entities in the discovered sector(s) */ def sector(indices: Iterable[Int], range: Float): SectorPopulation = { - if (indices.max < blocks.size) { + if (indices.nonEmpty && indices.max < blocks.size) { BlockMap.quickToSectorGroup(range, BlockMap.sectorsOnlyWithinBlockStructure(indices, blocks) ) } else { SectorGroup(Nil) @@ -527,7 +527,7 @@ object BlockMap { list: Iterable[Int], structure: Iterable[Sector] ): Iterable[Sector] = { - if (list.max < structure.size) { + if (list.nonEmpty && list.max < structure.size) { val structureSeq = structure.toSeq list.toSet.map { structureSeq } } else {