mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-14 09:47:24 +07:00
Added message for loading broken saves
This commit is contained in:
@ -123,6 +123,7 @@ text.server.port=Port:
|
||||
text.server.addressinuse=Address already in use!
|
||||
text.server.invalidport=Invalid port number!
|
||||
text.server.error=[crimson]Error hosting server: [orange]{0}
|
||||
text.save.old=This save is for an older version of the game, and can no longer be used.\n\n[LIGHT_GRAY]Save backwards compatibility will be implemented in the full 4.0 release.
|
||||
text.save.new=New Save
|
||||
text.save.overwrite=Are you sure you want to overwrite\nthis save slot?
|
||||
text.overwrite=Overwrite
|
||||
@ -292,7 +293,6 @@ text.blocks.inputfuel=Fuel
|
||||
text.blocks.fuelburntime=Fuel Burn Time
|
||||
text.blocks.inputcapacity=Input capacity
|
||||
text.blocks.outputcapacity=Output capacity
|
||||
text.blocks.required=Required:
|
||||
|
||||
text.unit.blocks=blocks
|
||||
text.unit.powersecond=power units/second
|
||||
|
@ -492,3 +492,4 @@ block.liquid-junction.name=Liquid Junction
|
||||
block.bridge-conduit.name=Bridge Conduit
|
||||
block.rotary-pump.name=Rotary Pump
|
||||
block.nuclear-reactor.name=Nuclear Reactor
|
||||
text.save.old=This save is for an older version of the game, and can no longer be used.\n\n[LIGHT_GRAY]Save backwards compatibility will be implemented in the full 4.0 release.
|
||||
|
@ -492,3 +492,4 @@ block.liquid-junction.name=Liquid Junction
|
||||
block.bridge-conduit.name=Bridge Conduit
|
||||
block.rotary-pump.name=Rotary Pump
|
||||
block.nuclear-reactor.name=Nuclear Reactor
|
||||
text.save.old=This save is for an older version of the game, and can no longer be used.\n\n[LIGHT_GRAY]Save backwards compatibility will be implemented in the full 4.0 release.
|
||||
|
@ -492,3 +492,4 @@ block.liquid-junction.name=Liquid Junction
|
||||
block.bridge-conduit.name=Bridge Conduit
|
||||
block.rotary-pump.name=Rotary Pump
|
||||
block.nuclear-reactor.name=Nuclear Reactor
|
||||
text.save.old=This save is for an older version of the game, and can no longer be used.\n\n[LIGHT_GRAY]Save backwards compatibility will be implemented in the full 4.0 release.
|
||||
|
@ -492,3 +492,4 @@ block.liquid-junction.name=Liquid Junction
|
||||
block.bridge-conduit.name=Bridge Conduit
|
||||
block.rotary-pump.name=Rotary Pump
|
||||
block.nuclear-reactor.name=Nuclear Reactor
|
||||
text.save.old=This save is for an older version of the game, and can no longer be used.\n\n[LIGHT_GRAY]Save backwards compatibility will be implemented in the full 4.0 release.
|
||||
|
@ -492,3 +492,4 @@ block.liquid-junction.name=Liquid Junction
|
||||
block.bridge-conduit.name=Bridge Conduit
|
||||
block.rotary-pump.name=Rotary Pump
|
||||
block.nuclear-reactor.name=Nuclear Reactor
|
||||
text.save.old=This save is for an older version of the game, and can no longer be used.\n\n[LIGHT_GRAY]Save backwards compatibility will be implemented in the full 4.0 release.
|
||||
|
@ -492,3 +492,4 @@ block.distributor.name=Distributor
|
||||
block.distributor.description=A splitter that can split items into 8 directions.
|
||||
block.overflow-gate.description=A combination splitter and router that only outputs to the left and right if the front path is blocked.
|
||||
block.nuclear-reactor.name=Nuclear Reactor
|
||||
text.save.old=This save is for an older version of the game, and can no longer be used.\n\n[LIGHT_GRAY]Save backwards compatibility will be implemented in the full 4.0 release.
|
||||
|
@ -492,3 +492,4 @@ block.liquid-junction.name=Liquid Junction
|
||||
block.bridge-conduit.name=Bridge Conduit
|
||||
block.rotary-pump.name=Rotary Pump
|
||||
block.nuclear-reactor.name=Nuclear Reactor
|
||||
text.save.old=This save is for an older version of the game, and can no longer be used.\n\n[LIGHT_GRAY]Save backwards compatibility will be implemented in the full 4.0 release.
|
||||
|
@ -492,3 +492,4 @@ block.liquid-junction.name=Liquid Junction
|
||||
block.bridge-conduit.name=Bridge Conduit
|
||||
block.rotary-pump.name=Rotary Pump
|
||||
block.nuclear-reactor.name=Nuclear Reactor
|
||||
text.save.old=This save is for an older version of the game, and can no longer be used.\n\n[LIGHT_GRAY]Save backwards compatibility will be implemented in the full 4.0 release.
|
||||
|
@ -492,3 +492,4 @@ block.liquid-junction.name=Liquid Junction
|
||||
block.bridge-conduit.name=Bridge Conduit
|
||||
block.rotary-pump.name=Rotary Pump
|
||||
block.nuclear-reactor.name=Nuclear Reactor
|
||||
text.save.old=This save is for an older version of the game, and can no longer be used.\n\n[LIGHT_GRAY]Save backwards compatibility will be implemented in the full 4.0 release.
|
||||
|
@ -492,3 +492,4 @@ block.liquid-junction.name=Liquid Junction
|
||||
block.bridge-conduit.name=Bridge Conduit
|
||||
block.rotary-pump.name=Rotary Pump
|
||||
block.nuclear-reactor.name=Nuclear Reactor
|
||||
text.save.old=This save is for an older version of the game, and can no longer be used.\n\n[LIGHT_GRAY]Save backwards compatibility will be implemented in the full 4.0 release.
|
||||
|
@ -492,3 +492,4 @@ block.liquid-junction.name=Liquid Junction
|
||||
block.bridge-conduit.name=Bridge Conduit
|
||||
block.rotary-pump.name=Rotary Pump
|
||||
block.nuclear-reactor.name=Nuclear Reactor
|
||||
text.save.old=This save is for an older version of the game, and can no longer be used.\n\n[LIGHT_GRAY]Save backwards compatibility will be implemented in the full 4.0 release.
|
||||
|
@ -23,9 +23,13 @@ import static io.anuke.mindustry.Vars.world;
|
||||
public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
||||
protected static Translator vec = new Translator();
|
||||
protected static float wobblyness = 0.6f;
|
||||
public final UnitState
|
||||
|
||||
resupply = new UnitState(){
|
||||
protected Trail trail = new Trail(8);
|
||||
protected CarriableTrait carrying;
|
||||
|
||||
protected final UnitState
|
||||
|
||||
resupply = new UnitState(){
|
||||
public void entered(){
|
||||
target = null;
|
||||
}
|
||||
@ -40,81 +44,79 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
||||
}
|
||||
}
|
||||
},
|
||||
idle = new UnitState(){
|
||||
public void update(){
|
||||
retarget(() -> {
|
||||
targetClosest();
|
||||
targetClosestEnemyFlag(BlockFlag.target);
|
||||
idle = new UnitState(){
|
||||
public void update(){
|
||||
retarget(() -> {
|
||||
targetClosest();
|
||||
targetClosestEnemyFlag(BlockFlag.target);
|
||||
|
||||
if(target != null){
|
||||
setState(attack);
|
||||
}
|
||||
});
|
||||
if(target != null){
|
||||
setState(attack);
|
||||
}
|
||||
});
|
||||
|
||||
target = getClosestCore();
|
||||
if(target != null){
|
||||
circle(50f);
|
||||
target = getClosestCore();
|
||||
if(target != null){
|
||||
circle(50f);
|
||||
}
|
||||
velocity.scl(0.8f);
|
||||
}
|
||||
},
|
||||
attack = new UnitState(){
|
||||
public void entered(){
|
||||
target = null;
|
||||
}
|
||||
|
||||
public void update(){
|
||||
if(Units.invalidateTarget(target, team, x, y)){
|
||||
target = null;
|
||||
}
|
||||
|
||||
if(!inventory.hasAmmo()){
|
||||
state.set(resupply);
|
||||
}else if(target == null){
|
||||
retarget(() -> {
|
||||
targetClosest();
|
||||
targetClosestEnemyFlag(BlockFlag.target);
|
||||
targetClosestEnemyFlag(BlockFlag.producer);
|
||||
|
||||
if(target == null){
|
||||
setState(idle);
|
||||
}
|
||||
velocity.scl(0.8f);
|
||||
}
|
||||
},
|
||||
attack = new UnitState(){
|
||||
public void entered(){
|
||||
target = null;
|
||||
});
|
||||
}else{
|
||||
attack(150f);
|
||||
|
||||
if((Mathf.angNear(angleTo(target), rotation, 15f) || !inventory.getAmmo().bullet.keepVelocity) //bombers don't care about rotation
|
||||
&& distanceTo(target) < inventory.getAmmo().getRange()){
|
||||
AmmoType ammo = inventory.getAmmo();
|
||||
inventory.useAmmo();
|
||||
|
||||
Vector2 to = Predict.intercept(FlyingUnit.this, target, ammo.bullet.speed);
|
||||
|
||||
getWeapon().update(FlyingUnit.this, to.x, to.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
retreat = new UnitState(){
|
||||
public void entered(){
|
||||
target = null;
|
||||
}
|
||||
|
||||
public void update(){
|
||||
if(Units.invalidateTarget(target, team, x, y)){
|
||||
target = null;
|
||||
}
|
||||
|
||||
if(!inventory.hasAmmo()){
|
||||
state.set(resupply);
|
||||
}else if(target == null){
|
||||
retarget(() -> {
|
||||
targetClosest();
|
||||
targetClosestEnemyFlag(BlockFlag.target);
|
||||
targetClosestEnemyFlag(BlockFlag.producer);
|
||||
|
||||
if(target == null){
|
||||
setState(idle);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
attack(150f);
|
||||
|
||||
if((Mathf.angNear(angleTo(target), rotation, 15f) || !inventory.getAmmo().bullet.keepVelocity) //bombers don't care about rotation
|
||||
&& distanceTo(target) < inventory.getAmmo().getRange()){
|
||||
AmmoType ammo = inventory.getAmmo();
|
||||
inventory.useAmmo();
|
||||
|
||||
Vector2 to = Predict.intercept(FlyingUnit.this, target, ammo.bullet.speed);
|
||||
|
||||
getWeapon().update(FlyingUnit.this, to.x, to.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
retreat = new UnitState(){
|
||||
public void entered(){
|
||||
target = null;
|
||||
}
|
||||
|
||||
public void update(){
|
||||
if(health >= maxHealth()){
|
||||
state.set(attack);
|
||||
}else if(!targetHasFlag(BlockFlag.repair)){
|
||||
retarget(() -> {
|
||||
Tile target = Geometry.findClosest(x, y, world.indexer().getAllied(team, BlockFlag.repair));
|
||||
if(target != null) FlyingUnit.this.target = target.entity;
|
||||
});
|
||||
}else{
|
||||
circle(20f);
|
||||
}
|
||||
}
|
||||
};
|
||||
protected Trail trail = new Trail(8);
|
||||
protected CarriableTrait carrying;
|
||||
public void update(){
|
||||
if(health >= maxHealth()){
|
||||
state.set(attack);
|
||||
}else if(!targetHasFlag(BlockFlag.repair)){
|
||||
retarget(() -> {
|
||||
Tile target = Geometry.findClosest(x, y, world.indexer().getAllied(team, BlockFlag.repair));
|
||||
if(target != null) FlyingUnit.this.target = target.entity;
|
||||
});
|
||||
}else{
|
||||
circle(20f);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//instantiation only
|
||||
public FlyingUnit(){
|
||||
|
@ -15,11 +15,12 @@ public abstract class SaveFileVersion{
|
||||
|
||||
public SaveMeta getData(DataInputStream stream) throws IOException{
|
||||
long time = stream.readLong(); //read last saved time
|
||||
int build = stream.readInt();
|
||||
byte mode = stream.readByte(); //read the gamemode
|
||||
String map = stream.readUTF(); //read the map
|
||||
int wave = stream.readInt(); //read the wave
|
||||
byte difficulty = stream.readByte(); //read the difficulty
|
||||
return new SaveMeta(version, time, mode, map, wave, Difficulty.values()[difficulty]);
|
||||
return new SaveMeta(version, time, build, mode, map, wave, Difficulty.values()[difficulty]);
|
||||
}
|
||||
|
||||
public abstract void read(DataInputStream stream) throws IOException;
|
||||
|
@ -3,6 +3,7 @@ package io.anuke.mindustry.io;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Base64Coder;
|
||||
import com.badlogic.gdx.utils.IntArray;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.io.versions.Save16;
|
||||
@ -15,9 +16,10 @@ import java.util.zip.InflaterInputStream;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class SaveIO{
|
||||
public static final IntArray breakingVersions = IntArray.with(47);
|
||||
public static final IntMap<SaveFileVersion> versions = new IntMap<>();
|
||||
public static final Array<SaveFileVersion> versionArray = Array.with(
|
||||
new Save16()
|
||||
new Save16()
|
||||
);
|
||||
|
||||
static{
|
||||
|
@ -10,14 +10,16 @@ import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class SaveMeta{
|
||||
public int version;
|
||||
public int build;
|
||||
public String date;
|
||||
public GameMode mode;
|
||||
public Map map;
|
||||
public int wave;
|
||||
public Difficulty difficulty;
|
||||
|
||||
public SaveMeta(int version, long date, int mode, String map, int wave, Difficulty difficulty){
|
||||
public SaveMeta(int version, long date, int build, int mode, String map, int wave, Difficulty difficulty){
|
||||
this.version = version;
|
||||
this.build = build;
|
||||
this.date = Platform.instance.format(new Date(date));
|
||||
this.mode = GameMode.values()[mode];
|
||||
this.map = world.maps().getByName(map);
|
||||
|
@ -144,6 +144,10 @@ public class Saves{
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public int getBuild(){
|
||||
return meta.build;
|
||||
}
|
||||
|
||||
public int getWave(){
|
||||
return meta.wave;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.io.Map;
|
||||
import io.anuke.mindustry.io.SaveFileVersion;
|
||||
import io.anuke.mindustry.io.Version;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.BlockPart;
|
||||
@ -153,6 +154,7 @@ public class Save16 extends SaveFileVersion{
|
||||
//--META--
|
||||
stream.writeInt(version); //version id
|
||||
stream.writeLong(TimeUtils.millis()); //last saved
|
||||
stream.writeInt(Version.build);
|
||||
|
||||
//--GENERAL STATE--
|
||||
stream.writeByte(state.mode.ordinal()); //gamemode
|
||||
@ -175,7 +177,6 @@ public class Save16 extends SaveFileVersion{
|
||||
}
|
||||
|
||||
//--ENTITIES--
|
||||
//TODO synchronized block here
|
||||
|
||||
int groups = 0;
|
||||
|
||||
|
@ -185,7 +185,13 @@ public class LoadDialog extends FloatingDialog{
|
||||
public void modifyButton(TextButton button, SaveSlot slot){
|
||||
button.clicked(() -> {
|
||||
if(!button.childrenPressed()){
|
||||
runLoadSave(slot);
|
||||
int build = slot.getBuild();
|
||||
if(SaveIO.breakingVersions.contains(build)){
|
||||
ui.showInfo("$text.save.old");
|
||||
slot.delete();
|
||||
}else{
|
||||
runLoadSave(slot);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user