Fixed #2632 (among other things)

This commit is contained in:
Anuken
2020-09-20 15:23:34 -04:00
parent 415380f25e
commit 0a314e142e
9 changed files with 18 additions and 5 deletions

View File

@@ -74,6 +74,7 @@ importPackage(Packages.mindustry.gen)
importPackage(Packages.mindustry.graphics) importPackage(Packages.mindustry.graphics)
importPackage(Packages.mindustry.graphics.g3d) importPackage(Packages.mindustry.graphics.g3d)
importPackage(Packages.mindustry.input) importPackage(Packages.mindustry.input)
importPackage(Packages.mindustry.io)
importPackage(Packages.mindustry.logic) importPackage(Packages.mindustry.logic)
importPackage(Packages.mindustry.maps) importPackage(Packages.mindustry.maps)
importPackage(Packages.mindustry.maps.filters) importPackage(Packages.mindustry.maps.filters)

View File

@@ -44,7 +44,7 @@ public class MinerAI extends AIController{
} }
if(ore != null){ if(ore != null){
moveTo(ore, unit.type().range / 1.5f); moveTo(ore, unit.type().range / 2f);
if(unit.within(ore, unit.type().range)){ if(unit.within(ore, unit.type().range)){
miner.mineTile(ore); miner.mineTile(ore);

View File

@@ -31,7 +31,7 @@ public abstract class UnlockableContent extends MappableContent{
this.localizedName = Core.bundle.get(getContentType() + "." + this.name + ".name", this.name); this.localizedName = Core.bundle.get(getContentType() + "." + this.name + ".name", this.name);
this.description = Core.bundle.getOrNull(getContentType() + "." + this.name + ".description"); 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(){ public String displayDescription(){

View File

@@ -61,6 +61,9 @@ public class Saves{
//automatically assign sector save slots //automatically assign sector save slots
for(SaveSlot slot : saves){ for(SaveSlot slot : saves){
if(slot.getSector() != null){ 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; slot.getSector().save = slot;
} }
} }

View File

@@ -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{ public static void load(Fi file) throws SaveException{
load(file, world.context); load(file, world.context);
} }

View File

@@ -22,7 +22,7 @@ public class Scripts implements Disposable{
private final Seq<String> blacklist = Seq.with(".net.", "java.net", "files", "reflect", "javax", "rhino", "file", "channels", "jdk", private final Seq<String> 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", "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."); ".awt", "socket", "classloader", "oracle", "invoke", "java.util.function", "java.util.stream", "org.");
private final Seq<String> whitelist = Seq.with("mindustry.net", "netserver", "netclient", "com.sun.proxy.$proxy", "mindustry.gen.", "mindustry.logic.", "mindustry.async."); private final Seq<String> whitelist = Seq.with("mindustry.net", "netserver", "netclient", "com.sun.proxy.$proxy", "mindustry.gen.", "mindustry.logic.", "mindustry.async.", "saveio");
private final Context context; private final Context context;
private final Scriptable scope; private final Scriptable scope;
private boolean errored; private boolean errored;

View File

@@ -275,6 +275,10 @@ public class Sector{
Core.settings.put(key(key), value); 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. /** Projects this sector onto a 4-corner square for use in map gen.
* Allocates a new object. Do not call in the main loop. */ * Allocates a new object. Do not call in the main loop. */
private SectorRect makeRect(){ private SectorRect makeRect(){

View File

@@ -413,7 +413,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
} }
if(shouldHide) hide(); 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(); stable.pack();

View File

@@ -11,6 +11,7 @@ import arc.struct.*;
import arc.util.*; import arc.util.*;
import mindustry.game.*; import mindustry.game.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.io.*;
import mindustry.net.*; import mindustry.net.*;
import java.io.*; import java.io.*;
@@ -42,7 +43,7 @@ public class ScriptMainGenerator{
classes.removeAll(type -> type.isSynthetic() || type.isAnonymousClass() || type.getCanonicalName() == null || Modifier.isPrivate(type.getModifiers()) 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())); || 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.distinct();
classes.sortComparing(Class::getName); classes.sortComparing(Class::getName);