Fixed save crash
This commit is contained in:
@@ -126,6 +126,12 @@ public class Renderer extends RendererModule{
|
|||||||
//render the entire map
|
//render the entire map
|
||||||
if(floorCache == null || floorCache.length != chunksx || floorCache[0].length != chunksy){
|
if(floorCache == null || floorCache.length != chunksx || floorCache[0].length != chunksy){
|
||||||
floorCache = new Cache[chunksx][chunksy];
|
floorCache = new Cache[chunksx][chunksy];
|
||||||
|
|
||||||
|
for(int x = 0; x < chunksx; x ++){
|
||||||
|
for(int y = 0; y < chunksy; y ++){
|
||||||
|
renderCache(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OrthographicCamera camera = Core.camera;
|
OrthographicCamera camera = Core.camera;
|
||||||
|
|||||||
@@ -435,7 +435,7 @@ public class UI extends SceneModule{
|
|||||||
new table(){{
|
new table(){{
|
||||||
new table("pane"){{
|
new table("pane"){{
|
||||||
|
|
||||||
new label(()->"Respawning in " + (int)(control.getRespawnTime()/60)).scale(0.75f).pad(10);
|
new label(()->"[orange]Respawning in " + (int)(control.getRespawnTime()/60)).scale(0.75f).pad(10);
|
||||||
|
|
||||||
visible(()->control.getRespawnTime() > 0 && !GameState.is(State.menu));
|
visible(()->control.getRespawnTime() > 0 && !GameState.is(State.menu));
|
||||||
|
|
||||||
|
|||||||
@@ -161,7 +161,6 @@ public class Enemy extends DestructibleEntity{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
Draw.color();
|
|
||||||
|
|
||||||
String region = ClassReflection.getSimpleName(getClass()).toLowerCase() + "-t" + Mathf.clamp(tier, 1, 3);
|
String region = ClassReflection.getSimpleName(getClass()).toLowerCase() + "-t" + Mathf.clamp(tier, 1, 3);
|
||||||
|
|
||||||
@@ -170,6 +169,7 @@ public class Enemy extends DestructibleEntity{
|
|||||||
Draw.getShader(Outline.class).region = Draw.region(region);
|
Draw.getShader(Outline.class).region = Draw.region(region);
|
||||||
|
|
||||||
Draw.shader(Outline.class);
|
Draw.shader(Outline.class);
|
||||||
|
Draw.color();
|
||||||
Draw.rect(region, x, y, direction.angle()-90);
|
Draw.rect(region, x, y, direction.angle()-90);
|
||||||
Draw.shader();
|
Draw.shader();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,13 @@ public class TankEnemy extends Enemy{
|
|||||||
speed = 0.2f;
|
speed = 0.2f;
|
||||||
reload = 90f;
|
reload = 90f;
|
||||||
bullet = BulletType.small;
|
bullet = BulletType.small;
|
||||||
|
length = 3f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void shoot(){
|
void shoot(){
|
||||||
vector.set(length, 0).rotate(direction.angle());
|
vector.set(length, 0).rotate(direction.angle());
|
||||||
|
|
||||||
Angles.shotgun(3, 4f, direction.angle(), f->{
|
Angles.shotgun(3, 8f, direction.angle(), f->{
|
||||||
Bullet out = new Bullet(bullet, this, x+vector.x, y+vector.y, f).add();
|
Bullet out = new Bullet(bullet, this, x+vector.x, y+vector.y, f).add();
|
||||||
out.damage = (int)(damage*Vars.multiplier);
|
out.damage = (int)(damage*Vars.multiplier);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import io.anuke.mindustry.world.World;
|
|||||||
import io.anuke.mindustry.world.blocks.Blocks;
|
import io.anuke.mindustry.world.blocks.Blocks;
|
||||||
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||||
import io.anuke.ucore.core.*;
|
import io.anuke.ucore.core.*;
|
||||||
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
public class AndroidInput extends InputAdapter{
|
public class AndroidInput extends InputAdapter{
|
||||||
@@ -101,7 +102,7 @@ public class AndroidInput extends InputAdapter{
|
|||||||
|
|
||||||
public static void doInput(){
|
public static void doInput(){
|
||||||
if(Gdx.input.isTouched(0)
|
if(Gdx.input.isTouched(0)
|
||||||
&& Mathf.near2d(lmousex, lmousey, Gdx.input.getX(0), Gdx.input.getY(0), 50)
|
&& Mathf.near2d(lmousex, lmousey, Gdx.input.getX(0), Gdx.input.getY(0), Unit.dp.inPixels(50))
|
||||||
&& !ui.hasMouse() /*&& (player.recipe == null || mode == PlaceMode.touch)*/){
|
&& !ui.hasMouse() /*&& (player.recipe == null || mode == PlaceMode.touch)*/){
|
||||||
warmup += Timers.delta();
|
warmup += Timers.delta();
|
||||||
|
|
||||||
@@ -127,8 +128,8 @@ public class AndroidInput extends InputAdapter{
|
|||||||
mousey = ly;
|
mousey = ly;
|
||||||
}else{
|
}else{
|
||||||
warmup = 0;
|
warmup = 0;
|
||||||
lmousex = Gdx.input.getX(0);
|
//lmousex = Gdx.input.getX(0);
|
||||||
lmousey = Gdx.input.getY(0);
|
//lmousey = Gdx.input.getY(0);
|
||||||
player.breaktime = 0;
|
player.breaktime = 0;
|
||||||
|
|
||||||
mousex = Mathf.clamp(mousex, 0, Gdx.graphics.getWidth());
|
mousex = Mathf.clamp(mousex, 0, Gdx.graphics.getWidth());
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ import io.anuke.ucore.entities.Entity;
|
|||||||
* spawn lane (byte)
|
* spawn lane (byte)
|
||||||
* x (float)
|
* x (float)
|
||||||
* y (float)
|
* y (float)
|
||||||
|
* tier (byte)
|
||||||
* health (int)
|
* health (int)
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@@ -82,7 +83,7 @@ import io.anuke.ucore.entities.Entity;
|
|||||||
*/
|
*/
|
||||||
public class SaveIO{
|
public class SaveIO{
|
||||||
/**Save file version ID. Should be incremented every breaking release.*/
|
/**Save file version ID. Should be incremented every breaking release.*/
|
||||||
private static final int fileVersionID = 6;
|
private static final int fileVersionID = 7;
|
||||||
|
|
||||||
private static FormatProvider provider = null;
|
private static FormatProvider provider = null;
|
||||||
|
|
||||||
@@ -91,7 +92,11 @@ public class SaveIO{
|
|||||||
Enemy.class,
|
Enemy.class,
|
||||||
FastEnemy.class,
|
FastEnemy.class,
|
||||||
RapidEnemy.class,
|
RapidEnemy.class,
|
||||||
FlamerEnemy.class
|
FlamerEnemy.class,
|
||||||
|
TankEnemy.class,
|
||||||
|
BlastEnemy.class,
|
||||||
|
MortarEnemy.class,
|
||||||
|
TestEnemy.class
|
||||||
);
|
);
|
||||||
|
|
||||||
private static final ObjectMap<Class<? extends Enemy>, Byte> idEnemies = new ObjectMap<Class<? extends Enemy>, Byte>(){{
|
private static final ObjectMap<Class<? extends Enemy>, Byte> idEnemies = new ObjectMap<Class<? extends Enemy>, Byte>(){{
|
||||||
@@ -186,6 +191,7 @@ public class SaveIO{
|
|||||||
stream.writeByte(enemy.spawn); //lane
|
stream.writeByte(enemy.spawn); //lane
|
||||||
stream.writeFloat(enemy.x); //x
|
stream.writeFloat(enemy.x); //x
|
||||||
stream.writeFloat(enemy.y); //y
|
stream.writeFloat(enemy.y); //y
|
||||||
|
stream.writeByte(enemy.tier); //tier
|
||||||
stream.writeInt(enemy.health); //health
|
stream.writeInt(enemy.health); //health
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -308,6 +314,7 @@ public class SaveIO{
|
|||||||
int lane = stream.readByte();
|
int lane = stream.readByte();
|
||||||
float x = stream.readFloat();
|
float x = stream.readFloat();
|
||||||
float y = stream.readFloat();
|
float y = stream.readFloat();
|
||||||
|
byte tier = stream.readByte();
|
||||||
int health = stream.readInt();
|
int health = stream.readInt();
|
||||||
|
|
||||||
try{
|
try{
|
||||||
@@ -315,6 +322,7 @@ public class SaveIO{
|
|||||||
enemy.health = health;
|
enemy.health = health;
|
||||||
enemy.x = x;
|
enemy.x = x;
|
||||||
enemy.y = y;
|
enemy.y = y;
|
||||||
|
enemy.tier = tier;
|
||||||
enemy.add();
|
enemy.add();
|
||||||
enemiesToUpdate.add(enemy);
|
enemiesToUpdate.add(enemy);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.ui;
|
|||||||
|
|
||||||
import com.badlogic.gdx.utils.Timer;
|
import com.badlogic.gdx.utils.Timer;
|
||||||
import com.badlogic.gdx.utils.Timer.Task;
|
import com.badlogic.gdx.utils.Timer.Task;
|
||||||
|
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.io.SaveIO;
|
import io.anuke.mindustry.io.SaveIO;
|
||||||
@@ -68,13 +69,17 @@ public class SaveDialog extends Dialog{
|
|||||||
@Override
|
@Override
|
||||||
public void run(){
|
public void run(){
|
||||||
hide();
|
hide();
|
||||||
|
Vars.ui.hideLoading();
|
||||||
try{
|
try{
|
||||||
SaveIO.saveToSlot(slot);
|
SaveIO.saveToSlot(slot);
|
||||||
}catch (Exception e){
|
}catch (Throwable e){
|
||||||
Vars.ui.showError("[orange]Failed to save game!");
|
e = (e.getCause() == null ? e : e.getCause());
|
||||||
return;
|
|
||||||
|
Vars.ui.showError("[orange]Failed to save game!\n[white]" +
|
||||||
|
ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" +
|
||||||
|
"at " + e.getStackTrace()[0].getFileName() + ":"+ e.getStackTrace()[0].getLineNumber());
|
||||||
}
|
}
|
||||||
Vars.ui.hideLoading();
|
|
||||||
}
|
}
|
||||||
}, 5f/60f);
|
}, 5f/60f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ public class Drill extends Block{
|
|||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
|
|
||||||
if(tile.floor() == resource && Timers.get(tile, 60 * time)){
|
//drills can only hold up to 10 items at a time
|
||||||
|
if(tile.floor() == resource && Timers.get(tile, 60 * time) && tile.entity.totalItems() < 10){
|
||||||
offloadNear(tile, result);
|
offloadNear(tile, result);
|
||||||
Effects.effect("spark", tile.worldx(), tile.worldy());
|
Effects.effect("spark", tile.worldx(), tile.worldy());
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
BIN
desktop/mindustry-saves/2.mins
Normal file
BIN
desktop/mindustry-saves/2.mins
Normal file
Binary file not shown.
Reference in New Issue
Block a user