mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-22 02:07:20 +07:00
Load order fix
This commit is contained in:
parent
695e4fefc4
commit
2b7117119c
@ -728,8 +728,10 @@ public class Mods implements Loadable{
|
||||
Seq<LoadRun> runs = new Seq<>();
|
||||
|
||||
for(LoadedMod mod : orderedMods()){
|
||||
ObjectMap<String, LoadRun> currentRun = new ObjectMap<>();
|
||||
Seq<LoadRun> unorderedContent = new Seq<>();
|
||||
ObjectMap<String, LoadRun> orderedContent = new ObjectMap<>();
|
||||
String[] contentOrder = mod.meta.contentOrder;
|
||||
ObjectSet<String> orderSet = contentOrder == null ? null : ObjectSet.with(contentOrder);
|
||||
|
||||
if(mod.root.child("content").exists()){
|
||||
Fi contentRoot = mod.root.child("content");
|
||||
@ -738,30 +740,32 @@ public class Mods implements Loadable{
|
||||
Fi folder = contentRoot.child(lower + (lower.endsWith("s") ? "" : "s"));
|
||||
if(folder.exists()){
|
||||
for(Fi file : folder.findAll(f -> f.extension().equals("json") || f.extension().equals("hjson"))){
|
||||
if(contentOrder == null){
|
||||
runs.add(new LoadRun(type, file, mod));
|
||||
|
||||
//if this is part of the ordered content, put it aside to be dealt with later
|
||||
if(orderSet != null && orderSet.contains(file.nameWithoutExtension())){
|
||||
orderedContent.put(file.nameWithoutExtension(), new LoadRun(type, file, mod));
|
||||
}else{
|
||||
currentRun.put(file.nameWithoutExtension(), new LoadRun(type, file, mod));
|
||||
unorderedContent.add(new LoadRun(type, file, mod));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Seq<String> left = currentRun.keys().toSeq();
|
||||
//ordered content will be loaded first, if it exists
|
||||
if(contentOrder != null){
|
||||
for (String contentName : contentOrder){
|
||||
LoadRun run = currentRun.get(contentName);
|
||||
for(String contentName : contentOrder){
|
||||
LoadRun run = orderedContent.get(contentName);
|
||||
if(run != null){
|
||||
runs.add(run);
|
||||
left.remove(contentName);
|
||||
}else{
|
||||
Log.warn("Cannot find content defined in contentOrder: @", contentName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
runs.addAll(left.map(name -> currentRun.get(name)).sort());
|
||||
//unordered content is sorted alphabetically per mod
|
||||
runs.addAll(unorderedContent.sort());
|
||||
}
|
||||
|
||||
for(LoadRun l : runs){
|
||||
|
Loading…
Reference in New Issue
Block a user