More bugfixes

This commit is contained in:
Anuken
2018-02-27 19:13:08 -05:00
parent 828dd78611
commit f72fd01050
9 changed files with 26 additions and 18 deletions

View File

@ -1,7 +1,7 @@
#Autogenerated file. Do not modify. #Autogenerated file. Do not modify.
#Mon Feb 26 23:26:06 EST 2018 #Tue Feb 27 19:00:42 EST 2018
version=release version=release
androidBuildCode=308 androidBuildCode=311
name=Mindustry name=Mindustry
code=3.4 code=3.4
build=29 build=29

View File

@ -169,8 +169,8 @@ public class Pathfind{
/**Reset and clear the paths.*/ /**Reset and clear the paths.*/
public void resetPaths(){ public void resetPaths(){
for(SpawnPoint point : world.getSpawns()){ for(int i = 0; i < world.getSpawns().size; i ++){
resetPathFor(point); resetPathFor(world.getSpawns().get(i));
} }
} }

View File

@ -156,6 +156,8 @@ public class Player extends SyncEntity{
return; return;
} }
if(isDead()) return;
Tile tile = world.tileWorld(x, y); Tile tile = world.tileWorld(x, y);
//if player is in solid block //if player is in solid block

View File

@ -228,7 +228,8 @@ public class EnemyType {
//no tile found //no tile found
if(enemy.target == null){ 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){ }else if(nearCore){
enemy.target = world.getCore().entity; enemy.target = world.getCore().entity;

View File

@ -177,7 +177,7 @@ public class BlockRenderer{
OrthographicCamera camera = Core.camera; OrthographicCamera camera = Core.camera;
Graphics.end(); if(Graphics.drawing()) Graphics.end();
int crangex = (int)(camera.viewportWidth * camera.zoom / (chunksize * tilesize))+1; int crangex = (int)(camera.viewportWidth * camera.zoom / (chunksize * tilesize))+1;
int crangey = (int)(camera.viewportHeight * camera.zoom / (chunksize * tilesize))+1; int crangey = (int)(camera.viewportHeight * camera.zoom / (chunksize * tilesize))+1;

View File

@ -127,7 +127,7 @@ public abstract class InputHandler extends InputAdapter{
} }
public void breakBlock(int x, int y, boolean sound){ 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()){ if(Net.active()){
NetEvents.handleBreak(x, y); NetEvents.handleBreak(x, y);

View File

@ -82,7 +82,7 @@ public class Maps implements Disposable{
if(!gwt) { if(!gwt) {
if (!loadMapFile(customMapDirectory.child("maps.json"), false)) { if (!loadMapFile(customMapDirectory.child("maps.json"), false)) {
try { 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); customMapDirectory.child("maps.json").writeString("{}", false);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Failed to create custom map directory!"); 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){ private boolean loadMapFile(FileHandle file, boolean logException){
try{ try {
Array<Map> arr = json.fromJson(ArrayContainer.class, file).maps; Array<Map> arr = json.fromJson(ArrayContainer.class, file).maps;
if(arr != null){ //can be an empty map file if (arr != null) { //can be an empty map file
for(Map map : arr){ for (Map map : arr) {
map.pixmap = new Pixmap(file.sibling(map.name + ".png")); 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); maps.put(map.id, map);
mapNames.put(map.name, map); mapNames.put(map.name, map);
lastID = Math.max(lastID, map.id); lastID = Math.max(lastID, map.id);
if(!map.custom){ if (!map.custom) {
defaultMaps.add(map); defaultMaps.add(map);
} }
} }
} }
return true; return true;
}catch (GdxRuntimeException e){
Log.err(e);
return true;
}catch(Exception e){ }catch(Exception e){
if(logException) { if(logException) {
Log.err(e); Log.err(e);

View File

@ -307,7 +307,7 @@ public class Save15 extends SaveFileVersion {
for(int y = 0; y < world.height(); y ++){ for(int y = 0; y < world.height(); y ++){
Tile tile = world.tile(x, y); Tile tile = world.tile(x, y);
if(tile.breakable()){ if(tile != null && tile.breakable()){
if(tile.block() instanceof Rock){ if(tile.block() instanceof Rock){
totalrocks ++; totalrocks ++;
}else{ }else{
@ -325,7 +325,7 @@ public class Save15 extends SaveFileVersion {
for (int y = 0; y < world.height(); y++) { for (int y = 0; y < world.height(); y++) {
Tile tile = world.tile(x, y); Tile tile = world.tile(x, y);
if (tile.block() instanceof Rock) { if (tile != null && tile.block() instanceof Rock) {
stream.writeInt(tile.packedPosition()); stream.writeInt(tile.packedPosition());
} }
} }
@ -338,7 +338,7 @@ public class Save15 extends SaveFileVersion {
for(int y = 0; y < world.height(); y ++){ for(int y = 0; y < world.height(); y ++){
Tile tile = world.tile(x, 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(x + y*world.width()); //tile pos
stream.writeInt(tile.block().id); //block ID stream.writeInt(tile.block().id); //block ID

View File

@ -3,6 +3,7 @@ package io.anuke.mindustry.world.blocks.types.defense;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.world.Layer; import io.anuke.mindustry.world.Layer;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
@ -80,9 +81,10 @@ public class RepairTurret extends PowerTurret{
@Override @Override
public void drawLayer2(Tile tile){ public void drawLayer2(Tile tile){
PowerTurretEntity entity = tile.entity(); PowerTurretEntity entity = tile.entity();
TileEntity target = entity.blockTarget;
if(entity.power >= powerUsed && entity.blockTarget != null && Angles.angleDist(entity.angleTo(entity.blockTarget), entity.rotation) < 10){ if(entity.power >= powerUsed && target != null && Angles.angleDist(entity.angleTo(target), entity.rotation) < 10){
Tile targetTile = entity.blockTarget.tile; Tile targetTile = target.tile;
float len = 4f; float len = 4f;
float x = tile.drawx() + Angles.trnsx(entity.rotation, len), y = tile.drawy() + Angles.trnsy(entity.rotation, len); float x = tile.drawx() + Angles.trnsx(entity.rotation, len), y = tile.drawy() + Angles.trnsy(entity.rotation, len);