Mod corruption load warnings

This commit is contained in:
Anuken
2019-10-02 21:23:29 -04:00
parent ec29bd3682
commit ffd4297b17
7 changed files with 49 additions and 33 deletions
+2 -1
View File
@@ -76,6 +76,7 @@ mod.requiresrestart = The game will now close to apply the mod changes.
mod.import = Import Mod mod.import = Import Mod
mod.remove.confirm = This mod will be deleted. mod.remove.confirm = This mod will be deleted.
mod.author = [LIGHT_GRAY]Author:[] {0} mod.author = [LIGHT_GRAY]Author:[] {0}
mod.missing = This save contains mods that you have recently updated or no longer have installed. Save corruption may occur. Are you sure you want to load it?\n[lightgray]Mods:\n{0}
about.button = About about.button = About
name = Name: name = Name:
@@ -177,7 +178,7 @@ save.rename.text = New name:
selectslot = Select a save. selectslot = Select a save.
slot = [accent]Slot {0} slot = [accent]Slot {0}
editmessage = Edit Message editmessage = Edit Message
save.corrupted = [accent]Save file corrupted or invalid!\nIf you have just updated your game, this is probably a change in the save format and [scarlet]not[] a bug. save.corrupted = Save file corrupted or invalid!
empty = <empty> empty = <empty>
on = On on = On
off = Off off = Off
@@ -7,6 +7,7 @@ import io.anuke.arc.files.*;
import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.*;
import io.anuke.arc.util.*; import io.anuke.arc.util.*;
import io.anuke.arc.util.async.*; import io.anuke.arc.util.async.*;
import io.anuke.mindustry.*;
import io.anuke.mindustry.core.GameState.*; import io.anuke.mindustry.core.GameState.*;
import io.anuke.mindustry.game.EventType.*; import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.io.*; import io.anuke.mindustry.io.*;
@@ -253,6 +254,17 @@ public class Saves{
return meta.map; return meta.map;
} }
public void cautiousLoad(Runnable run){
Array<String> mods = Array.with(getMods());
mods.removeAll(Vars.mods.getModStrings());
if(!mods.isEmpty()){
ui.showConfirm("$warning", Core.bundle.format("mod.missing", mods.toString("\n")), run);
}else{
run.run();
}
}
public String getName(){ public String getName(){
return Core.settings.getString("save-" + index + "-name", "untitled"); return Core.settings.getString("save-" + index + "-name", "untitled");
} }
@@ -66,7 +66,7 @@ public abstract class SaveVersion extends SaveFileReader{
"wavetime", state.wavetime, "wavetime", state.wavetime,
"stats", JsonIO.write(state.stats), "stats", JsonIO.write(state.stats),
"rules", JsonIO.write(state.rules), "rules", JsonIO.write(state.rules),
"mods", JsonIO.write(mods.getModNames().toArray(String.class)), "mods", JsonIO.write(mods.getModStrings().toArray(String.class)),
"width", world.width(), "width", world.width(),
"height", world.height() "height", world.height()
).merge(tags)); ).merge(tags));
+1 -1
View File
@@ -258,7 +258,7 @@ public class Mods implements Loadable{
} }
/** @return the mods that the client is missing. /** @return the mods that the client is missing.
* The inputted array is changed to contain the extra mods that the client has but the server does.*/ * The inputted array is changed to contain the extra mods that the client has but the server doesn't.*/
public Array<String> getIncompatibility(Array<String> out){ public Array<String> getIncompatibility(Array<String> out){
Array<String> mods = getModStrings(); Array<String> mods = getModStrings();
Array<String> result = mods.copy(); Array<String> result = mods.copy();
@@ -103,12 +103,13 @@ public class DeployDialog extends FloatingDialog{
} }
TextButton button = Elements.newButton(Core.bundle.format("resume", slot.getZone().localizedName()), Styles.squaret, () -> { TextButton button = Elements.newButton(Core.bundle.format("resume", slot.getZone().localizedName()), Styles.squaret, () -> {
control.saves.getZoneSlot().cautiousLoad(() -> {
hide(); hide();
ui.loadAnd(() -> { ui.loadAnd(() -> {
logic.reset(); logic.reset();
net.reset(); net.reset();
try{ try{
control.saves.getZoneSlot().load(); slot.load();
state.set(State.playing); state.set(State.playing);
}catch(SaveException e){ //make sure to handle any save load errors! }catch(SaveException e){ //make sure to handle any save load errors!
e.printStackTrace(); e.printStackTrace();
@@ -118,6 +119,7 @@ public class DeployDialog extends FloatingDialog{
} }
}); });
}); });
});
sub.add(button); sub.add(button);
@@ -186,10 +186,10 @@ public class LoadDialog extends FloatingDialog{
} }
public void runLoadSave(SaveSlot slot){ public void runLoadSave(SaveSlot slot){
slot.cautiousLoad(() -> {
ui.loadAnd(() -> {
hide(); hide();
ui.paused.hide(); ui.paused.hide();
ui.loadAnd(() -> {
try{ try{
net.reset(); net.reset();
slot.load(); slot.load();
@@ -203,6 +203,7 @@ public class LoadDialog extends FloatingDialog{
ui.showErrorMessage("$save.corrupted"); ui.showErrorMessage("$save.corrupted");
} }
}); });
});
} }
public void modifyButton(TextButton button, SaveSlot slot){ public void modifyButton(TextButton button, SaveSlot slot){
+1 -1
View File
@@ -1,3 +1,3 @@
org.gradle.daemon=true org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=2a94f9187de5a7fa0b795ba4725fbc3e929b890c archash=e17b152d4f597837640fe4d659ca5a820e8a2b15