From 5c6b659ce33b519a6b94882b65f161581b4ae0d7 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 16 Jul 2021 12:59:50 -0400 Subject: [PATCH] Possible rare crash fix --- core/src/mindustry/ai/BlockIndexer.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/core/src/mindustry/ai/BlockIndexer.java b/core/src/mindustry/ai/BlockIndexer.java index 430630f5d3..272fb6d543 100644 --- a/core/src/mindustry/ai/BlockIndexer.java +++ b/core/src/mindustry/ai/BlockIndexer.java @@ -48,6 +48,7 @@ public class BlockIndexer{ private Seq breturnArray = new Seq<>(Building.class); public BlockIndexer(){ + clearFlags(); Events.on(TilePreChangeEvent.class, event -> { removeIndex(event.tile); @@ -62,11 +63,7 @@ public class BlockIndexer{ flagMap = new TileArray[Team.all.length][BlockFlag.all.length]; activeTeams = new Seq<>(Team.class); - for(int i = 0; i < flagMap.length; i++){ - for(int j = 0; j < BlockFlag.all.length; j++){ - flagMap[i][j] = new TileArray(); - } - } + clearFlags(); allOres.clear(); ores = new IntSeq[content.items().size][][]; @@ -160,6 +157,14 @@ public class BlockIndexer{ return blocksPresent != null && blocksPresent[block.id]; } + private void clearFlags(){ + for(int i = 0; i < flagMap.length; i++){ + for(int j = 0; j < BlockFlag.all.length; j++){ + flagMap[i][j] = new TileArray(); + } + } + } + private TileArray[] getFlagged(Team team){ return flagMap[team.id]; }