A variety of crash and bugfixes
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.core;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||
import io.anuke.mindustry.game.EnemySpawn;
|
||||
@@ -130,9 +129,9 @@ public class Logic extends Module {
|
||||
if(!state.mode.disableWaveTimer){
|
||||
|
||||
if(state.enemies <= 0){
|
||||
state.wavetime -= delta();
|
||||
if(!world.getMap().name.equals("tutorial")) state.wavetime -= delta();
|
||||
|
||||
if(state.lastUpdated < state.wave + 1 && state.wavetime < Vars.aheadPathfinding){ //start updating beforehand
|
||||
if(state.lastUpdated < state.wave + 1 && state.wavetime < aheadPathfinding){ //start updating beforehand
|
||||
world.pathfinder().resetPaths();
|
||||
state.lastUpdated = state.wave + 1;
|
||||
}
|
||||
|
||||
@@ -253,7 +253,6 @@ public class NetClient extends Module {
|
||||
//do nothing else...
|
||||
//TODO fix
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Net.handleClient(DisconnectPacket.class, packet -> {
|
||||
@@ -294,11 +293,7 @@ public class NetClient extends Module {
|
||||
next.block().handleItem(Item.getByID(packet.itemid), next, tile);
|
||||
};
|
||||
|
||||
if(threads.isEnabled()){
|
||||
threads.run(r);
|
||||
}else{
|
||||
r.run();
|
||||
}
|
||||
threads.run(r);
|
||||
});
|
||||
|
||||
Net.handleClient(ItemSetPacket.class, packet -> {
|
||||
@@ -308,11 +303,7 @@ public class NetClient extends Module {
|
||||
tile.entity.items[packet.itemid] = packet.amount;
|
||||
};
|
||||
|
||||
if(threads.isEnabled()){
|
||||
threads.run(r);
|
||||
}else{
|
||||
r.run();
|
||||
}
|
||||
threads.run(r);
|
||||
});
|
||||
|
||||
Net.handleClient(ItemOffloadPacket.class, packet -> {
|
||||
@@ -323,11 +314,7 @@ public class NetClient extends Module {
|
||||
next.block().handleItem(Item.getByID(packet.itemid), next, tile);
|
||||
};
|
||||
|
||||
if(threads.isEnabled()){
|
||||
threads.run(r);
|
||||
}else{
|
||||
r.run();
|
||||
}
|
||||
threads.run(r);
|
||||
});
|
||||
|
||||
Net.handleClient(NetErrorPacket.class, packet -> {
|
||||
|
||||
@@ -34,8 +34,12 @@ public class ThreadHandler {
|
||||
}
|
||||
|
||||
public void run(Runnable r){
|
||||
synchronized (toRun) {
|
||||
toRun.add(r);
|
||||
if(enabled) {
|
||||
synchronized (toRun) {
|
||||
toRun.add(r);
|
||||
}
|
||||
}else{
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.anuke.mindustry.core;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Colors;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
@@ -121,7 +122,7 @@ public class UI extends SceneModule{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
public synchronized void update(){
|
||||
if(Vars.debug && !Vars.showUI) return;
|
||||
|
||||
scene.act();
|
||||
@@ -173,6 +174,11 @@ public class UI extends SceneModule{
|
||||
build.end();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean hasMouse() {
|
||||
return super.hasMouse();
|
||||
}
|
||||
|
||||
public Locale getLocale(){
|
||||
String loc = Settings.getString("locale");
|
||||
if(loc.equals("default")){
|
||||
@@ -233,6 +239,8 @@ public class UI extends SceneModule{
|
||||
dialog.hide();
|
||||
confirmed.listen();
|
||||
});
|
||||
dialog.keyDown(Keys.ESCAPE, dialog::hide);
|
||||
dialog.keyDown(Keys.BACK, dialog::hide);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Placement {
|
||||
state.inventory.addItem(tile.block().drops.item, tile.block().drops.amount);
|
||||
}
|
||||
|
||||
if(sound) Sounds.play("break");
|
||||
if(sound) threads.run(() -> Sounds.play("break"));
|
||||
|
||||
if(!tile.block().isMultiblock() && !tile.isLinked()){
|
||||
tile.setBlock(Blocks.air);
|
||||
@@ -85,7 +85,7 @@ public class Placement {
|
||||
}
|
||||
}else if(effects) Effects.effect(Fx.place, x * tilesize, y * tilesize);
|
||||
|
||||
if(effects && sound) Sounds.play("place");
|
||||
if(effects && sound) threads.run(() -> Sounds.play("place"));
|
||||
}
|
||||
|
||||
public static boolean validPlace(int x, int y, Block type){
|
||||
|
||||
Reference in New Issue
Block a user