From f72fd0105047d83f031f4f9e07f2b6d89e585e27 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 27 Feb 2018 19:13:08 -0500 Subject: [PATCH] More bugfixes --- core/assets/version.properties | 4 ++-- core/src/io/anuke/mindustry/ai/Pathfind.java | 4 ++-- core/src/io/anuke/mindustry/entities/Player.java | 2 ++ .../mindustry/entities/enemies/EnemyType.java | 3 ++- .../anuke/mindustry/graphics/BlockRenderer.java | 2 +- .../io/anuke/mindustry/input/InputHandler.java | 2 +- core/src/io/anuke/mindustry/io/Maps.java | 15 +++++++++------ .../io/anuke/mindustry/io/versions/Save15.java | 6 +++--- .../world/blocks/types/defense/RepairTurret.java | 6 ++++-- 9 files changed, 26 insertions(+), 18 deletions(-) diff --git a/core/assets/version.properties b/core/assets/version.properties index 330b7767c3..fbae5cf26f 100644 --- a/core/assets/version.properties +++ b/core/assets/version.properties @@ -1,7 +1,7 @@ #Autogenerated file. Do not modify. -#Mon Feb 26 23:26:06 EST 2018 +#Tue Feb 27 19:00:42 EST 2018 version=release -androidBuildCode=308 +androidBuildCode=311 name=Mindustry code=3.4 build=29 diff --git a/core/src/io/anuke/mindustry/ai/Pathfind.java b/core/src/io/anuke/mindustry/ai/Pathfind.java index 5099bd2df1..1d65921692 100644 --- a/core/src/io/anuke/mindustry/ai/Pathfind.java +++ b/core/src/io/anuke/mindustry/ai/Pathfind.java @@ -169,8 +169,8 @@ public class Pathfind{ /**Reset and clear the paths.*/ public void resetPaths(){ - for(SpawnPoint point : world.getSpawns()){ - resetPathFor(point); + for(int i = 0; i < world.getSpawns().size; i ++){ + resetPathFor(world.getSpawns().get(i)); } } diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index 6400e6e2a2..5ef9259598 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -156,6 +156,8 @@ public class Player extends SyncEntity{ return; } + if(isDead()) return; + Tile tile = world.tileWorld(x, y); //if player is in solid block diff --git a/core/src/io/anuke/mindustry/entities/enemies/EnemyType.java b/core/src/io/anuke/mindustry/entities/enemies/EnemyType.java index bc0ada5608..9ce29dadea 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/EnemyType.java +++ b/core/src/io/anuke/mindustry/entities/enemies/EnemyType.java @@ -228,7 +228,8 @@ public class EnemyType { //no tile found if(enemy.target == null){ - enemy.target = Entities.getClosest(playerGroup, enemy.x, enemy.y, range, e -> !((Player)e).isAndroid); + enemy.target = Entities.getClosest(playerGroup, enemy.x, enemy.y, range, e -> !((Player)e).isAndroid && + !((Player)e).isDead()); } }else if(nearCore){ enemy.target = world.getCore().entity; diff --git a/core/src/io/anuke/mindustry/graphics/BlockRenderer.java b/core/src/io/anuke/mindustry/graphics/BlockRenderer.java index 7a610a5518..e53ffacd1b 100644 --- a/core/src/io/anuke/mindustry/graphics/BlockRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/BlockRenderer.java @@ -177,7 +177,7 @@ public class BlockRenderer{ OrthographicCamera camera = Core.camera; - Graphics.end(); + if(Graphics.drawing()) Graphics.end(); int crangex = (int)(camera.viewportWidth * camera.zoom / (chunksize * tilesize))+1; int crangey = (int)(camera.viewportHeight * camera.zoom / (chunksize * tilesize))+1; diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index d068eaee8e..88ef529f4e 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -127,7 +127,7 @@ public abstract class InputHandler extends InputAdapter{ } public void breakBlock(int x, int y, boolean sound){ - if(!Net.client()) Placement.breakBlock(x, y, sound, sound); + if(!Net.client()) Placement.breakBlock(x, y, true, sound); if(Net.active()){ NetEvents.handleBreak(x, y); diff --git a/core/src/io/anuke/mindustry/io/Maps.java b/core/src/io/anuke/mindustry/io/Maps.java index 038bc99d25..ad41c3f431 100644 --- a/core/src/io/anuke/mindustry/io/Maps.java +++ b/core/src/io/anuke/mindustry/io/Maps.java @@ -82,7 +82,7 @@ public class Maps implements Disposable{ if(!gwt) { if (!loadMapFile(customMapDirectory.child("maps.json"), false)) { try { - Log.info("Failed to find custom map directory. Creating one instead."); + Log.info("Failed to find custom map directory."); customMapDirectory.child("maps.json").writeString("{}", false); } catch (Exception e) { throw new RuntimeException("Failed to create custom map directory!"); @@ -161,21 +161,24 @@ public class Maps implements Disposable{ } private boolean loadMapFile(FileHandle file, boolean logException){ - try{ + try { Array arr = json.fromJson(ArrayContainer.class, file).maps; - if(arr != null){ //can be an empty map file - for(Map map : arr){ + if (arr != null) { //can be an empty map file + for (Map map : arr) { map.pixmap = new Pixmap(file.sibling(map.name + ".png")); - if(!headless) map.texture = new Texture(map.pixmap); + if (!headless) map.texture = new Texture(map.pixmap); maps.put(map.id, map); mapNames.put(map.name, map); lastID = Math.max(lastID, map.id); - if(!map.custom){ + if (!map.custom) { defaultMaps.add(map); } } } return true; + }catch (GdxRuntimeException e){ + Log.err(e); + return true; }catch(Exception e){ if(logException) { Log.err(e); diff --git a/core/src/io/anuke/mindustry/io/versions/Save15.java b/core/src/io/anuke/mindustry/io/versions/Save15.java index df955efa49..cd654ba7de 100644 --- a/core/src/io/anuke/mindustry/io/versions/Save15.java +++ b/core/src/io/anuke/mindustry/io/versions/Save15.java @@ -307,7 +307,7 @@ public class Save15 extends SaveFileVersion { for(int y = 0; y < world.height(); y ++){ Tile tile = world.tile(x, y); - if(tile.breakable()){ + if(tile != null && tile.breakable()){ if(tile.block() instanceof Rock){ totalrocks ++; }else{ @@ -325,7 +325,7 @@ public class Save15 extends SaveFileVersion { for (int y = 0; y < world.height(); y++) { Tile tile = world.tile(x, y); - if (tile.block() instanceof Rock) { + if (tile != null && tile.block() instanceof Rock) { stream.writeInt(tile.packedPosition()); } } @@ -338,7 +338,7 @@ public class Save15 extends SaveFileVersion { for(int y = 0; y < world.height(); y ++){ Tile tile = world.tile(x, y); - if(tile.breakable() && !(tile.block() instanceof Rock)){ + if(tile != null && tile.breakable() && !(tile.block() instanceof Rock)){ stream.writeInt(x + y*world.width()); //tile pos stream.writeInt(tile.block().id); //block ID diff --git a/core/src/io/anuke/mindustry/world/blocks/types/defense/RepairTurret.java b/core/src/io/anuke/mindustry/world/blocks/types/defense/RepairTurret.java index 4e65b5dc6e..1d650e08fc 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/defense/RepairTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/defense/RepairTurret.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.world.blocks.types.defense; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.utils.Array; +import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.world.Layer; import io.anuke.mindustry.world.Tile; import io.anuke.ucore.core.Timers; @@ -80,9 +81,10 @@ public class RepairTurret extends PowerTurret{ @Override public void drawLayer2(Tile tile){ PowerTurretEntity entity = tile.entity(); + TileEntity target = entity.blockTarget; - if(entity.power >= powerUsed && entity.blockTarget != null && Angles.angleDist(entity.angleTo(entity.blockTarget), entity.rotation) < 10){ - Tile targetTile = entity.blockTarget.tile; + if(entity.power >= powerUsed && target != null && Angles.angleDist(entity.angleTo(target), entity.rotation) < 10){ + Tile targetTile = target.tile; float len = 4f; float x = tile.drawx() + Angles.trnsx(entity.rotation, len), y = tile.drawy() + Angles.trnsy(entity.rotation, len);