Organized map files by planet
This commit is contained in:
@@ -40,6 +40,8 @@ public class Maps{
|
||||
private static String[] defaultMapNames = {"maze", "fortress", "labyrinth", "islands", "tendrils", "caldera", "wasteland", "shattered", "fork", "triad", "mudFlats", "moltenLake", "archipelago", "debrisField", "domain", "veins", "glacier", "passage"};
|
||||
/** Maps tagged as PvP */
|
||||
private static String[] pvpMaps = {"veins", "glacier", "passage"};
|
||||
/** If true, the defaultMapNames are prefixed with default/ */
|
||||
private static boolean useDefaultFolder = true;
|
||||
|
||||
/** All maps stored in an ordered array. */
|
||||
private Seq<Map> maps = new Seq<>();
|
||||
@@ -126,7 +128,7 @@ public class Maps{
|
||||
//defaults; must work
|
||||
try{
|
||||
for(String name : defaultMapNames){
|
||||
Fi file = Core.files.internal("maps/" + name + "." + mapExtension);
|
||||
Fi file = Core.files.internal((useDefaultFolder ? "maps/default/" : "maps/") + name + "." + mapExtension);
|
||||
loadMap(file, false);
|
||||
}
|
||||
}catch(IOException e){
|
||||
|
||||
@@ -91,7 +91,7 @@ public class SectorSubmissions{
|
||||
sub.author = author;
|
||||
sub.mapFileLink = mapFileLink;
|
||||
|
||||
var preset = new SectorPreset("sector-" + planet.name + "-" + id, "hidden-serpulo/" + id, planet, id);
|
||||
var preset = new SectorPreset("sector-" + planet.name + "-" + id, "hidden/" + id, planet, id);
|
||||
|
||||
preset.requireUnlock = false;
|
||||
if(difficulty > 0f) preset.difficulty = difficulty;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mindustry.maps.generators;
|
||||
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.game.*;
|
||||
@@ -18,12 +19,33 @@ public class FileMapGenerator implements WorldGenerator{
|
||||
public final SectorPreset preset;
|
||||
|
||||
public FileMapGenerator(String mapName, SectorPreset preset){
|
||||
//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;
|
||||
if(maps == null){
|
||||
this.map = null;
|
||||
}else{
|
||||
Seq<String> candidates = new Seq<>(4);
|
||||
|
||||
//<planetname>/<mapname>.msav
|
||||
candidates.add(preset.planet.name + "/" + mapName);
|
||||
|
||||
//<mapname>.msav (directly in maps folder)
|
||||
candidates.add(mapName);
|
||||
|
||||
//for modded maps, try loading without the mod prefix
|
||||
if(preset.minfo.mod != null){
|
||||
String baseName = mapName.substring(1 + preset.minfo.mod.name.length());
|
||||
|
||||
//<planetname>/<mapname>.msav
|
||||
candidates.add(preset.planet.name + "/" + baseName);
|
||||
|
||||
//<mapname>.msav (directly in maps folder)
|
||||
candidates.add(baseName);
|
||||
}
|
||||
|
||||
//find the first matching candidate to load
|
||||
String fileName = candidates.find(name -> Vars.tree.get("maps/" + name + "." + mapExtension).exists());
|
||||
|
||||
this.map = maps.loadInternalMap(fileName == null ? candidates.first() : fileName);
|
||||
}
|
||||
|
||||
this.preset = preset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user