diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index 2520c18b70..cb6d914aa0 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -158,6 +158,19 @@ public class Control implements ApplicationListener, Loadable{ } }); + //delete save on campaign game over + Events.on(GameOverEvent.class, e -> { + if(state.isCampaign() && !net.client() && !headless){ + + //delete the save, it is gone. + if(saves.getCurrent() != null && !state.rules.tutorial){ + Sector sector = state.getSector(); + sector.save = null; + saves.getCurrent().delete(); + } + } + }); + Events.on(Trigger.newGame, () -> { Building core = player.closestCore(); diff --git a/core/src/mindustry/game/SpawnGroup.java b/core/src/mindustry/game/SpawnGroup.java index ad2cf44592..15f7c98fff 100644 --- a/core/src/mindustry/game/SpawnGroup.java +++ b/core/src/mindustry/game/SpawnGroup.java @@ -5,6 +5,7 @@ import arc.util.serialization.Json.*; import mindustry.content.*; import mindustry.ctype.*; import mindustry.gen.*; +import mindustry.io.legacy.*; import mindustry.type.*; import static mindustry.Vars.content; @@ -93,7 +94,9 @@ public class SpawnGroup implements Serializable{ @Override public void read(Json json, JsonValue data){ - type = content.getByName(ContentType.unit, data.getString("type", "dagger")); + String tname = data.getString("type", "dagger"); + + type = content.getByName(ContentType.unit, LegacyIO.unitMap.get(tname, tname)); if(type == null) type = UnitTypes.dagger; begin = data.getInt("begin", 0); end = data.getInt("end", never); diff --git a/core/src/mindustry/io/legacy/LegacyIO.java b/core/src/mindustry/io/legacy/LegacyIO.java index 621533b418..1d0a790159 100644 --- a/core/src/mindustry/io/legacy/LegacyIO.java +++ b/core/src/mindustry/io/legacy/LegacyIO.java @@ -7,6 +7,21 @@ import mindustry.ui.dialogs.JoinDialog.*; import java.io.*; public class LegacyIO{ + /** Maps old unit names to new ones. */ + public static final StringMap unitMap = StringMap.of( + "titan", "mace", + "chaos-array", "vestige", + "eradicator", "cataclyst", + "eruptor", "atrax", + "wraith", "flare", + "ghoul", "horizon", + "revenant", "zenith", + "lich", "antumbra", + "reaper", "eclipse", + "draug", "mono", + "phantom", "poly", + "spirit", "poly" + ); public static Seq readServers(){ Seq arr = new Seq<>();