mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-13 07:24:53 +00:00
making .max calls safer by checking .nonEmpty first (#1185)
This commit is contained in:
parent
34e2ad5ea3
commit
b7dc2b6623
1 changed files with 2 additions and 2 deletions
|
|
@ -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)
|
* @return a conglomerate sector which lists all of the entities in the discovered sector(s)
|
||||||
*/
|
*/
|
||||||
def sector(indices: Iterable[Int], range: Float): SectorPopulation = {
|
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) )
|
BlockMap.quickToSectorGroup(range, BlockMap.sectorsOnlyWithinBlockStructure(indices, blocks) )
|
||||||
} else {
|
} else {
|
||||||
SectorGroup(Nil)
|
SectorGroup(Nil)
|
||||||
|
|
@ -527,7 +527,7 @@ object BlockMap {
|
||||||
list: Iterable[Int],
|
list: Iterable[Int],
|
||||||
structure: Iterable[Sector]
|
structure: Iterable[Sector]
|
||||||
): Iterable[Sector] = {
|
): Iterable[Sector] = {
|
||||||
if (list.max < structure.size) {
|
if (list.nonEmpty && list.max < structure.size) {
|
||||||
val structureSeq = structure.toSeq
|
val structureSeq = structure.toSeq
|
||||||
list.toSet.map { structureSeq }
|
list.toSet.map { structureSeq }
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue