Skip to content

Commit

Permalink
may be a fix for sorter crash on android
Browse files Browse the repository at this point in the history
  • Loading branch information
stabu-dev committed Nov 22, 2024
1 parent 47193f8 commit 6f9a537
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/omaloon/OmaloonMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

public class OmaloonMod extends Mod{
public static EditorListener editorListener;
public static Roomba roomba;
public static SafeClearer safeClearer;

public static ShapedEnvPlacerFragment shapedEnvPlacerFragment;
public static CliffFragment cliffFragment;
Expand Down Expand Up @@ -67,7 +67,7 @@ public OmaloonMod(){
EventHints.addHints();
CustomShapePropProcess.instance = new CustomShapePropProcess();
Vars.asyncCore.processes.add(CustomShapePropProcess.instance);
roomba = new Roomba();
safeClearer = new SafeClearer();
});

Events.on(EventType.FileTreeInitEvent.class, e ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import mindustry.world.meta.*;
import omaloon.content.*;

public class Roomba implements ApplicationListener {
public class SafeClearer implements ApplicationListener {
public static final Seq<Building> invalidBuilds = new Seq<>();

public Roomba() {
public SafeClearer() {
if (Vars.platform instanceof ApplicationCore core) core.add(this);
}

Expand Down
22 changes: 9 additions & 13 deletions src/omaloon/utils/OlUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,19 @@ public static int reverse(int rotation) {

public static int getByIndex(IntSet intSet, int index) {
if (index < 0 || index >= intSet.size) {
throw new IndexOutOfBoundsException();
throw new IndexOutOfBoundsException("Index " + index + " is out of bounds for IntSet of size " + intSet.size);
}

final int[] value = {0};
final int[] counter = {0};
intSet.each((item) -> {
if (counter[0] == index) {
value[0] = item;
int counter = 0;
for (IntSet.IntSetIterator iterator = intSet.iterator(); iterator.hasNext; ) {
int item = iterator.next();
if (counter == index) {
return item;
}
counter[0]++;
});

if (counter[0] > index) {
return value[0];
} else {
throw new IllegalArgumentException();
counter++;
}

throw new IllegalArgumentException("Index out of range for IntSet.");
}

/**bittiler stuff
Expand Down

0 comments on commit 6f9a537

Please sign in to comment.