A variety of crash and bugfixes

This commit is contained in:
Anuken
2018-03-01 22:19:04 -05:00
parent 41ee817d18
commit 278d80a627
6 changed files with 23 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
#Autogenerated file. Do not modify. #Autogenerated file. Do not modify.
#Thu Mar 01 09:15:00 EST 2018 #Thu Mar 01 22:16:30 EST 2018
version=release version=release
androidBuildCode=319 androidBuildCode=319
name=Mindustry name=Mindustry

View File

@@ -1,7 +1,6 @@
package io.anuke.mindustry.core; package io.anuke.mindustry.core;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.mindustry.game.EnemySpawn; import io.anuke.mindustry.game.EnemySpawn;
@@ -130,9 +129,9 @@ public class Logic extends Module {
if(!state.mode.disableWaveTimer){ if(!state.mode.disableWaveTimer){
if(state.enemies <= 0){ 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(); world.pathfinder().resetPaths();
state.lastUpdated = state.wave + 1; state.lastUpdated = state.wave + 1;
} }

View File

@@ -253,7 +253,6 @@ public class NetClient extends Module {
//do nothing else... //do nothing else...
//TODO fix //TODO fix
} }
}); });
Net.handleClient(DisconnectPacket.class, packet -> { Net.handleClient(DisconnectPacket.class, packet -> {
@@ -294,11 +293,7 @@ public class NetClient extends Module {
next.block().handleItem(Item.getByID(packet.itemid), next, tile); next.block().handleItem(Item.getByID(packet.itemid), next, tile);
}; };
if(threads.isEnabled()){ threads.run(r);
threads.run(r);
}else{
r.run();
}
}); });
Net.handleClient(ItemSetPacket.class, packet -> { Net.handleClient(ItemSetPacket.class, packet -> {
@@ -308,11 +303,7 @@ public class NetClient extends Module {
tile.entity.items[packet.itemid] = packet.amount; tile.entity.items[packet.itemid] = packet.amount;
}; };
if(threads.isEnabled()){ threads.run(r);
threads.run(r);
}else{
r.run();
}
}); });
Net.handleClient(ItemOffloadPacket.class, packet -> { Net.handleClient(ItemOffloadPacket.class, packet -> {
@@ -323,11 +314,7 @@ public class NetClient extends Module {
next.block().handleItem(Item.getByID(packet.itemid), next, tile); next.block().handleItem(Item.getByID(packet.itemid), next, tile);
}; };
if(threads.isEnabled()){ threads.run(r);
threads.run(r);
}else{
r.run();
}
}); });
Net.handleClient(NetErrorPacket.class, packet -> { Net.handleClient(NetErrorPacket.class, packet -> {

View File

@@ -34,8 +34,12 @@ public class ThreadHandler {
} }
public void run(Runnable r){ public void run(Runnable r){
synchronized (toRun) { if(enabled) {
toRun.add(r); synchronized (toRun) {
toRun.add(r);
}
}else{
r.run();
} }
} }

View File

@@ -1,6 +1,7 @@
package io.anuke.mindustry.core; package io.anuke.mindustry.core;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors; import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.math.Interpolation; import com.badlogic.gdx.math.Interpolation;
@@ -121,7 +122,7 @@ public class UI extends SceneModule{
} }
@Override @Override
public void update(){ public synchronized void update(){
if(Vars.debug && !Vars.showUI) return; if(Vars.debug && !Vars.showUI) return;
scene.act(); scene.act();
@@ -173,6 +174,11 @@ public class UI extends SceneModule{
build.end(); build.end();
} }
@Override
public synchronized boolean hasMouse() {
return super.hasMouse();
}
public Locale getLocale(){ public Locale getLocale(){
String loc = Settings.getString("locale"); String loc = Settings.getString("locale");
if(loc.equals("default")){ if(loc.equals("default")){
@@ -233,6 +239,8 @@ public class UI extends SceneModule{
dialog.hide(); dialog.hide();
confirmed.listen(); confirmed.listen();
}); });
dialog.keyDown(Keys.ESCAPE, dialog::hide);
dialog.keyDown(Keys.BACK, dialog::hide);
dialog.show(); dialog.show();
} }

View File

@@ -40,7 +40,7 @@ public class Placement {
state.inventory.addItem(tile.block().drops.item, tile.block().drops.amount); 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()){ if(!tile.block().isMultiblock() && !tile.isLinked()){
tile.setBlock(Blocks.air); tile.setBlock(Blocks.air);
@@ -85,7 +85,7 @@ public class Placement {
} }
}else if(effects) Effects.effect(Fx.place, x * tilesize, y * tilesize); }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){ public static boolean validPlace(int x, int y, Block type){