From 0a314e142e64b7b625b669d6378059e420ec0b8a Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 20 Sep 2020 15:23:34 -0400 Subject: [PATCH] Fixed #2632 (among other things) --- core/assets/scripts/global.js | 1 + core/src/mindustry/ai/types/MinerAI.java | 2 +- core/src/mindustry/ctype/UnlockableContent.java | 2 +- core/src/mindustry/game/Saves.java | 3 +++ core/src/mindustry/io/SaveIO.java | 4 ++++ core/src/mindustry/mod/Scripts.java | 2 +- core/src/mindustry/type/Sector.java | 4 ++++ core/src/mindustry/ui/dialogs/PlanetDialog.java | 2 +- tools/src/mindustry/tools/ScriptMainGenerator.java | 3 ++- 9 files changed, 18 insertions(+), 5 deletions(-) diff --git a/core/assets/scripts/global.js b/core/assets/scripts/global.js index 5377350e3d..7d395c8378 100755 --- a/core/assets/scripts/global.js +++ b/core/assets/scripts/global.js @@ -74,6 +74,7 @@ importPackage(Packages.mindustry.gen) importPackage(Packages.mindustry.graphics) importPackage(Packages.mindustry.graphics.g3d) importPackage(Packages.mindustry.input) +importPackage(Packages.mindustry.io) importPackage(Packages.mindustry.logic) importPackage(Packages.mindustry.maps) importPackage(Packages.mindustry.maps.filters) diff --git a/core/src/mindustry/ai/types/MinerAI.java b/core/src/mindustry/ai/types/MinerAI.java index f635c9e543..c4e654ce29 100644 --- a/core/src/mindustry/ai/types/MinerAI.java +++ b/core/src/mindustry/ai/types/MinerAI.java @@ -44,7 +44,7 @@ public class MinerAI extends AIController{ } if(ore != null){ - moveTo(ore, unit.type().range / 1.5f); + moveTo(ore, unit.type().range / 2f); if(unit.within(ore, unit.type().range)){ miner.mineTile(ore); diff --git a/core/src/mindustry/ctype/UnlockableContent.java b/core/src/mindustry/ctype/UnlockableContent.java index ee1739eb9d..9c4b147214 100644 --- a/core/src/mindustry/ctype/UnlockableContent.java +++ b/core/src/mindustry/ctype/UnlockableContent.java @@ -31,7 +31,7 @@ public abstract class UnlockableContent extends MappableContent{ this.localizedName = Core.bundle.get(getContentType() + "." + this.name + ".name", this.name); this.description = Core.bundle.getOrNull(getContentType() + "." + this.name + ".description"); - this.unlocked = Core.settings != null && Core.settings.getBool(name + "-unlocked", false); + this.unlocked = Core.settings != null && Core.settings.getBool(this.name + "-unlocked", false); } public String displayDescription(){ diff --git a/core/src/mindustry/game/Saves.java b/core/src/mindustry/game/Saves.java index 9ec689a1aa..0d2b75bf9c 100644 --- a/core/src/mindustry/game/Saves.java +++ b/core/src/mindustry/game/Saves.java @@ -61,6 +61,9 @@ public class Saves{ //automatically assign sector save slots for(SaveSlot slot : saves){ if(slot.getSector() != null){ + if(slot.getSector().save != null){ + Log.warn("Sector @ has two corresponding saves: @ and @", slot.getSector(), slot.getSector().save.file, slot.file); + } slot.getSector().save = slot; } } diff --git a/core/src/mindustry/io/SaveIO.java b/core/src/mindustry/io/SaveIO.java index 518cfa13d1..8b56ef2a61 100644 --- a/core/src/mindustry/io/SaveIO.java +++ b/core/src/mindustry/io/SaveIO.java @@ -126,6 +126,10 @@ public class SaveIO{ } } + public static void load(String saveName) throws SaveException{ + load(saveDirectory.child(saveName + ".msav")); + } + public static void load(Fi file) throws SaveException{ load(file, world.context); } diff --git a/core/src/mindustry/mod/Scripts.java b/core/src/mindustry/mod/Scripts.java index 14a9e4326f..1aa260e8fa 100644 --- a/core/src/mindustry/mod/Scripts.java +++ b/core/src/mindustry/mod/Scripts.java @@ -22,7 +22,7 @@ public class Scripts implements Disposable{ private final Seq blacklist = Seq.with(".net.", "java.net", "files", "reflect", "javax", "rhino", "file", "channels", "jdk", "runtime", "util.os", "rmi", "security", "org.", "sun.", "beans", "sql", "http", "exec", "compiler", "process", "system", ".awt", "socket", "classloader", "oracle", "invoke", "java.util.function", "java.util.stream", "org."); - private final Seq whitelist = Seq.with("mindustry.net", "netserver", "netclient", "com.sun.proxy.$proxy", "mindustry.gen.", "mindustry.logic.", "mindustry.async."); + private final Seq whitelist = Seq.with("mindustry.net", "netserver", "netclient", "com.sun.proxy.$proxy", "mindustry.gen.", "mindustry.logic.", "mindustry.async.", "saveio"); private final Context context; private final Scriptable scope; private boolean errored; diff --git a/core/src/mindustry/type/Sector.java b/core/src/mindustry/type/Sector.java index 137c1b0142..19bc03f874 100644 --- a/core/src/mindustry/type/Sector.java +++ b/core/src/mindustry/type/Sector.java @@ -275,6 +275,10 @@ public class Sector{ Core.settings.put(key(key), value); } + public String toString(){ + return planet.name + "#" + id; + } + /** Projects this sector onto a 4-corner square for use in map gen. * Allocates a new object. Do not call in the main loop. */ private SectorRect makeRect(){ diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index 022a92b770..0ee8fa3509 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -413,7 +413,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ } if(shouldHide) hide(); - }).growX().padTop(2f).height(50f).minWidth(170f); + }).growX().padTop(2f).height(50f).minWidth(170f).disabled(b -> state.rules.sector == sector && !state.isMenu()); } stable.pack(); diff --git a/tools/src/mindustry/tools/ScriptMainGenerator.java b/tools/src/mindustry/tools/ScriptMainGenerator.java index 66a5233e29..e15335e91a 100644 --- a/tools/src/mindustry/tools/ScriptMainGenerator.java +++ b/tools/src/mindustry/tools/ScriptMainGenerator.java @@ -11,6 +11,7 @@ import arc.struct.*; import arc.util.*; import mindustry.game.*; import mindustry.gen.*; +import mindustry.io.*; import mindustry.net.*; import java.io.*; @@ -42,7 +43,7 @@ public class ScriptMainGenerator{ classes.removeAll(type -> type.isSynthetic() || type.isAnonymousClass() || type.getCanonicalName() == null || Modifier.isPrivate(type.getModifiers()) || blacklist.contains(s -> type.getName().startsWith(base + "." + s + ".")) || nameBlacklist.contains(type.getSimpleName())); - classes.add(NetConnection.class); + classes.add(NetConnection.class, SaveIO.class); classes.distinct(); classes.sortComparing(Class::getName);