Fixed JSON sector preset files failing to load
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package mindustry.maps.generators;
|
||||
|
||||
import arc.math.geom.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.io.*;
|
||||
@@ -16,7 +17,13 @@ public class FileMapGenerator implements WorldGenerator{
|
||||
public final SectorPreset preset;
|
||||
|
||||
public FileMapGenerator(String mapName, SectorPreset preset){
|
||||
this.map = maps != null ? maps.loadInternalMap(mapName) : null;
|
||||
//try to look for the prefixed map first, then the mod-specific one
|
||||
this.map = maps != null ? maps.loadInternalMap(
|
||||
preset.minfo.mod == null || Vars.tree.get("maps/" + mapName + "." + mapExtension).exists() ?
|
||||
mapName :
|
||||
mapName.substring(1 + preset.minfo.mod.name.length())
|
||||
) : null;
|
||||
|
||||
this.preset = preset;
|
||||
}
|
||||
|
||||
|
||||
@@ -575,7 +575,7 @@ public class ContentParser{
|
||||
|
||||
if(!value.has("sector") || !value.get("sector").isNumber()) throw new RuntimeException("SectorPresets must have a sector number.");
|
||||
|
||||
SectorPreset out = new SectorPreset(mod + "-" + name);
|
||||
SectorPreset out = new SectorPreset(mod + "-" + name, currentMod);
|
||||
|
||||
currentContent = out;
|
||||
read(() -> {
|
||||
|
||||
@@ -5,6 +5,7 @@ import mindustry.ctype.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.maps.generators.*;
|
||||
import mindustry.mod.Mods.*;
|
||||
|
||||
public class SectorPreset extends UnlockableContent{
|
||||
public FileMapGenerator generator;
|
||||
@@ -36,11 +37,17 @@ public class SectorPreset extends UnlockableContent{
|
||||
}
|
||||
|
||||
/** Internal use only! */
|
||||
public SectorPreset(String name){
|
||||
public SectorPreset(String name, LoadedMod mod){
|
||||
super(name);
|
||||
this.minfo.mod = mod;
|
||||
this.generator = new FileMapGenerator(name, this);
|
||||
}
|
||||
|
||||
/** Internal use only! */
|
||||
public SectorPreset(String name){
|
||||
this(name, null);
|
||||
}
|
||||
|
||||
public void initialize(Planet planet, int sector){
|
||||
this.planet = planet;
|
||||
sector %= planet.sectors.size;
|
||||
|
||||
Reference in New Issue
Block a user