mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-22 04:28:27 +07:00
Fixed crash caused by lack of multithreading
This commit is contained in:
parent
9555b10b97
commit
a116a2a553
@ -176,7 +176,7 @@ public class Control extends Module{
|
||||
Timers.runTask(30f, () -> state.set(State.menu));
|
||||
});
|
||||
|
||||
Events.on(WorldLoadEvent.class, () -> Gdx.app.postRunnable(() -> Events.fire(WorldLoadGraphicsEvent.class)));
|
||||
Events.on(WorldLoadEvent.class, () -> threads.runGraphics(() -> Events.fire(WorldLoadGraphicsEvent.class)));
|
||||
}
|
||||
|
||||
public void addPlayer(int index){
|
||||
@ -261,12 +261,14 @@ public class Control extends Module{
|
||||
ui.loadfrag.show();
|
||||
saves.resetSave();
|
||||
|
||||
threads.run(() -> {
|
||||
logic.reset();
|
||||
world.loadMap(map);
|
||||
logic.play();
|
||||
Timers.run(5f, () -> {
|
||||
threads.run(() -> {
|
||||
logic.reset();
|
||||
world.loadMap(map);
|
||||
logic.play();
|
||||
|
||||
Gdx.app.postRunnable(ui.loadfrag::hide);
|
||||
Gdx.app.postRunnable(ui.loadfrag::hide);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,14 @@ public class ThreadHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public void runGraphics(Runnable r){
|
||||
if(enabled) {
|
||||
Gdx.app.postRunnable(r);
|
||||
}else{
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
public void runDelay(Runnable r){
|
||||
if(enabled) {
|
||||
synchronized (toRun) {
|
||||
|
@ -14,8 +14,6 @@ public class ItemImage extends Stack {
|
||||
public ItemImage(TextureRegion region, Supplier<String> text, Color color) {
|
||||
Table t = new Table().left().bottom();
|
||||
|
||||
t.label(text).get().setFontScale(0.5f);
|
||||
|
||||
image = new Image(region);
|
||||
image.setColor(color);
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class Build {
|
||||
rect.setSize(type.size * tilesize, type.size * tilesize);
|
||||
rect.setCenter(type.offset() + x * tilesize, type.offset() + y * tilesize);
|
||||
|
||||
if (type.solid || type.solidifes)
|
||||
if (type.solid || type.solidifes) {
|
||||
synchronized (Entities.entityLock) {
|
||||
try {
|
||||
|
||||
@ -112,6 +112,7 @@ public class Build {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Tile tile = world.tile(x, y);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user