Crash fixes

This commit is contained in:
Anuken
2018-09-05 09:05:15 -04:00
parent d4ccfa31b5
commit 3f07102f2a
7 changed files with 18 additions and 8 deletions

View File

@@ -80,7 +80,7 @@ public class DefenseBlocks extends BlockList implements ContentList{
shockMine = new ShockMine("shock-mine"){{ shockMine = new ShockMine("shock-mine"){{
health = 40; health = 40;
damage = 11; damage = 11;
tileDamage = 6f; tileDamage = 7f;
length = 10; length = 10;
tendrils = 5; tendrils = 5;
}}; }};

View File

@@ -158,5 +158,9 @@ public class Logic extends Module{
world.pathfinder().update(); world.pathfinder().update();
} }
} }
if(threads.isEnabled()){
netServer.update();
}
} }
} }

View File

@@ -235,7 +235,7 @@ public class NetClient extends Module{
} }
//when all chunks have been recieved, begin //when all chunks have been recieved, begin
if(netClient.recievedChunkCounter >= totalChunks){ if(netClient.recievedChunkCounter >= totalChunks && netClient.currentSnapshot != null){
snapshot = netClient.currentSnapshot; snapshot = netClient.currentSnapshot;
}else{ }else{
return; return;

View File

@@ -403,10 +403,12 @@ public class NetServer extends Module{
} }
public void update(){ public void update(){
if(threads.isEnabled() && !threads.isOnThread()) return;
if(!headless && !closing && Net.server() && state.is(State.menu)){ if(!headless && !closing && Net.server() && state.is(State.menu)){
closing = true; closing = true;
reset(); reset();
ui.loadfrag.show("$text.server.closing"); threads.runGraphics(() -> ui.loadfrag.show("$text.server.closing"));
Timers.runTask(5f, () -> { Timers.runTask(5f, () -> {
Net.closeServer(); Net.closeServer();
ui.loadfrag.hide(); ui.loadfrag.hide();

View File

@@ -15,6 +15,7 @@ import io.anuke.mindustry.content.blocks.Blocks;
import io.anuke.mindustry.content.fx.Fx; import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.Unit; import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.entities.traits.TargetTrait; import io.anuke.mindustry.entities.traits.TargetTrait;
@@ -89,13 +90,14 @@ public class MobileInput extends InputHandler implements GestureListener{
Unit unit = Units.getClosestEnemy(player.getTeam(), x, y, 20f, u -> true); Unit unit = Units.getClosestEnemy(player.getTeam(), x, y, 20f, u -> true);
if(unit != null){ if(unit != null){
player.target = unit; threads.run(() -> player.target = unit);
}else{ }else{
Tile tile = world.tileWorld(x, y); Tile tile = world.tileWorld(x, y);
if(tile != null) tile = tile.target(); if(tile != null) tile = tile.target();
if(tile != null && state.teams.areEnemies(player.getTeam(), tile.getTeam())){ if(tile != null && state.teams.areEnemies(player.getTeam(), tile.getTeam())){
player.target = tile.entity; TileEntity entity = tile.entity;
threads.run(() -> player.target = entity);
} }
} }
} }

View File

@@ -14,7 +14,7 @@ public class ShockMine extends Block{
protected int timerDamage = timers ++; protected int timerDamage = timers ++;
protected float cooldown = 80f; protected float cooldown = 80f;
protected float tileDamage = 4f; protected float tileDamage = 5f;
protected float damage = 10; protected float damage = 10;
protected int length = 10; protected int length = 10;
protected int tendrils = 6; protected int tendrils = 6;

View File

@@ -41,7 +41,7 @@ public class LiquidJunction extends LiquidBlock{
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){ public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){
int dir = source.relativeTo(tile.x, tile.y); int dir = source.relativeTo(tile.x, tile.y);
dir = (dir + 4) % 4; dir = (dir + 4) % 4;
Tile to = tile.getNearby(dir); Tile to = tile.getNearby(dir).target();
if(to.block().hasLiquids && to.block().acceptLiquid(to, tile, liquid, Math.min(to.block().liquidCapacity - to.entity.liquids.get(liquid) - 0.00001f, amount))){ if(to.block().hasLiquids && to.block().acceptLiquid(to, tile, liquid, Math.min(to.block().liquidCapacity - to.entity.liquids.get(liquid) - 0.00001f, amount))){
to.block().handleLiquid(to, tile, liquid, Math.min(to.block().liquidCapacity - to.entity.liquids.get(liquid) - 0.00001f, amount)); to.block().handleLiquid(to, tile, liquid, Math.min(to.block().liquidCapacity - to.entity.liquids.get(liquid) - 0.00001f, amount));
@@ -53,6 +53,8 @@ public class LiquidJunction extends LiquidBlock{
int dir = source.relativeTo(dest.x, dest.y); int dir = source.relativeTo(dest.x, dest.y);
dir = (dir + 4) % 4; dir = (dir + 4) % 4;
Tile to = dest.getNearby(dir); Tile to = dest.getNearby(dir);
return to != null && to.block().hasLiquids && to.block().acceptLiquid(to, dest, liquid, Math.min(to.block().liquidCapacity - to.entity.liquids.get(liquid) - 0.00001f, amount)); if(to == null) return false;
to = to.target();
return to != null && to.entity != null && to.block().hasLiquids && to.block().acceptLiquid(to, dest, liquid, Math.min(to.block().liquidCapacity - to.entity.liquids.get(liquid) - 0.00001f, amount));
} }
} }