Fixed crash caused by lack of multithreading
This commit is contained in:
@@ -176,7 +176,7 @@ public class Control extends Module{
|
|||||||
Timers.runTask(30f, () -> state.set(State.menu));
|
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){
|
public void addPlayer(int index){
|
||||||
@@ -261,12 +261,14 @@ public class Control extends Module{
|
|||||||
ui.loadfrag.show();
|
ui.loadfrag.show();
|
||||||
saves.resetSave();
|
saves.resetSave();
|
||||||
|
|
||||||
threads.run(() -> {
|
Timers.run(5f, () -> {
|
||||||
logic.reset();
|
threads.run(() -> {
|
||||||
world.loadMap(map);
|
logic.reset();
|
||||||
logic.play();
|
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){
|
public void runDelay(Runnable r){
|
||||||
if(enabled) {
|
if(enabled) {
|
||||||
synchronized (toRun) {
|
synchronized (toRun) {
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ public class ItemImage extends Stack {
|
|||||||
public ItemImage(TextureRegion region, Supplier<String> text, Color color) {
|
public ItemImage(TextureRegion region, Supplier<String> text, Color color) {
|
||||||
Table t = new Table().left().bottom();
|
Table t = new Table().left().bottom();
|
||||||
|
|
||||||
t.label(text).get().setFontScale(0.5f);
|
|
||||||
|
|
||||||
image = new Image(region);
|
image = new Image(region);
|
||||||
image.setColor(color);
|
image.setColor(color);
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class Build {
|
|||||||
rect.setSize(type.size * tilesize, type.size * tilesize);
|
rect.setSize(type.size * tilesize, type.size * tilesize);
|
||||||
rect.setCenter(type.offset() + x * tilesize, type.offset() + y * tilesize);
|
rect.setCenter(type.offset() + x * tilesize, type.offset() + y * tilesize);
|
||||||
|
|
||||||
if (type.solid || type.solidifes)
|
if (type.solid || type.solidifes) {
|
||||||
synchronized (Entities.entityLock) {
|
synchronized (Entities.entityLock) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@@ -112,6 +112,7 @@ public class Build {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Tile tile = world.tile(x, y);
|
Tile tile = world.tile(x, y);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user