diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index f19fceafef..3e9976024d 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -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 diff --git a/core/assets/bundles/bundle_de.properties b/core/assets/bundles/bundle_de.properties index 23c3f886eb..78b1bf4794 100644 --- a/core/assets/bundles/bundle_de.properties +++ b/core/assets/bundles/bundle_de.properties @@ -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. diff --git a/core/assets/bundles/bundle_es.properties b/core/assets/bundles/bundle_es.properties index 9ee631d3ab..a8136b7ead 100644 --- a/core/assets/bundles/bundle_es.properties +++ b/core/assets/bundles/bundle_es.properties @@ -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. diff --git a/core/assets/bundles/bundle_fr.properties b/core/assets/bundles/bundle_fr.properties index e1ee0c31a7..4d29faf7f7 100644 --- a/core/assets/bundles/bundle_fr.properties +++ b/core/assets/bundles/bundle_fr.properties @@ -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. diff --git a/core/assets/bundles/bundle_in_ID.properties b/core/assets/bundles/bundle_in_ID.properties index 9f1ec1436f..b4c7f1e2a4 100644 --- a/core/assets/bundles/bundle_in_ID.properties +++ b/core/assets/bundles/bundle_in_ID.properties @@ -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. diff --git a/core/assets/bundles/bundle_ita.properties b/core/assets/bundles/bundle_ita.properties index 93cb8a4f36..4b02d88130 100644 --- a/core/assets/bundles/bundle_ita.properties +++ b/core/assets/bundles/bundle_ita.properties @@ -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. diff --git a/core/assets/bundles/bundle_ko.properties b/core/assets/bundles/bundle_ko.properties index 3b3f145bd3..6169edd949 100644 --- a/core/assets/bundles/bundle_ko.properties +++ b/core/assets/bundles/bundle_ko.properties @@ -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. diff --git a/core/assets/bundles/bundle_pl.properties b/core/assets/bundles/bundle_pl.properties index 1336e0650b..ef022067b0 100644 --- a/core/assets/bundles/bundle_pl.properties +++ b/core/assets/bundles/bundle_pl.properties @@ -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. diff --git a/core/assets/bundles/bundle_pt_BR.properties b/core/assets/bundles/bundle_pt_BR.properties index 04f28bf94a..3b54e1282d 100644 --- a/core/assets/bundles/bundle_pt_BR.properties +++ b/core/assets/bundles/bundle_pt_BR.properties @@ -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. diff --git a/core/assets/bundles/bundle_ru.properties b/core/assets/bundles/bundle_ru.properties index 1d14c9c417..81593c7e58 100644 --- a/core/assets/bundles/bundle_ru.properties +++ b/core/assets/bundles/bundle_ru.properties @@ -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. diff --git a/core/assets/bundles/bundle_tk.properties b/core/assets/bundles/bundle_tk.properties index 6120e00fd3..b8006f0edb 100644 --- a/core/assets/bundles/bundle_tk.properties +++ b/core/assets/bundles/bundle_tk.properties @@ -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. diff --git a/core/assets/bundles/bundle_uk_UA.properties b/core/assets/bundles/bundle_uk_UA.properties index ecc5320001..7a85ec0af1 100644 --- a/core/assets/bundles/bundle_uk_UA.properties +++ b/core/assets/bundles/bundle_uk_UA.properties @@ -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. diff --git a/core/src/io/anuke/mindustry/entities/units/FlyingUnit.java b/core/src/io/anuke/mindustry/entities/units/FlyingUnit.java index cdcdbf4717..1b2df0d94c 100644 --- a/core/src/io/anuke/mindustry/entities/units/FlyingUnit.java +++ b/core/src/io/anuke/mindustry/entities/units/FlyingUnit.java @@ -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(){ diff --git a/core/src/io/anuke/mindustry/io/SaveFileVersion.java b/core/src/io/anuke/mindustry/io/SaveFileVersion.java index 48ec0b58e8..4a66242dfd 100644 --- a/core/src/io/anuke/mindustry/io/SaveFileVersion.java +++ b/core/src/io/anuke/mindustry/io/SaveFileVersion.java @@ -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; diff --git a/core/src/io/anuke/mindustry/io/SaveIO.java b/core/src/io/anuke/mindustry/io/SaveIO.java index bfe652c384..98ed4b251c 100644 --- a/core/src/io/anuke/mindustry/io/SaveIO.java +++ b/core/src/io/anuke/mindustry/io/SaveIO.java @@ -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 versions = new IntMap<>(); public static final Array versionArray = Array.with( - new Save16() + new Save16() ); static{ diff --git a/core/src/io/anuke/mindustry/io/SaveMeta.java b/core/src/io/anuke/mindustry/io/SaveMeta.java index 5fd655f6b2..f782e74db1 100644 --- a/core/src/io/anuke/mindustry/io/SaveMeta.java +++ b/core/src/io/anuke/mindustry/io/SaveMeta.java @@ -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); diff --git a/core/src/io/anuke/mindustry/io/Saves.java b/core/src/io/anuke/mindustry/io/Saves.java index 4096974e97..0fd1792034 100644 --- a/core/src/io/anuke/mindustry/io/Saves.java +++ b/core/src/io/anuke/mindustry/io/Saves.java @@ -144,6 +144,10 @@ public class Saves{ Settings.save(); } + public int getBuild(){ + return meta.build; + } + public int getWave(){ return meta.wave; } diff --git a/core/src/io/anuke/mindustry/io/versions/Save16.java b/core/src/io/anuke/mindustry/io/versions/Save16.java index ece1178776..afe056970c 100644 --- a/core/src/io/anuke/mindustry/io/versions/Save16.java +++ b/core/src/io/anuke/mindustry/io/versions/Save16.java @@ -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; diff --git a/core/src/io/anuke/mindustry/ui/dialogs/LoadDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/LoadDialog.java index 03fb0ffdee..529c48ff73 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/LoadDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/LoadDialog.java @@ -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); + } } }); }