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

View File

@ -76,6 +76,7 @@ mod.requiresrestart = The game will now close to apply the mod changes.
mod.import = Import Mod
mod.remove.confirm = This mod will be deleted.
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
name = Name:
@ -177,7 +178,7 @@ save.rename.text = New name:
selectslot = Select a save.
slot = [accent]Slot {0}
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>
on = On
off = Off

View File

@ -7,6 +7,7 @@ import io.anuke.arc.files.*;
import io.anuke.arc.graphics.*;
import io.anuke.arc.util.*;
import io.anuke.arc.util.async.*;
import io.anuke.mindustry.*;
import io.anuke.mindustry.core.GameState.*;
import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.io.*;
@ -253,6 +254,17 @@ public class Saves{
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(){
return Core.settings.getString("save-" + index + "-name", "untitled");
}

View File

@ -66,7 +66,7 @@ public abstract class SaveVersion extends SaveFileReader{
"wavetime", state.wavetime,
"stats", JsonIO.write(state.stats),
"rules", JsonIO.write(state.rules),
"mods", JsonIO.write(mods.getModNames().toArray(String.class)),
"mods", JsonIO.write(mods.getModStrings().toArray(String.class)),
"width", world.width(),
"height", world.height()
).merge(tags));

View File

@ -258,7 +258,7 @@ public class Mods implements Loadable{
}
/** @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){
Array<String> mods = getModStrings();
Array<String> result = mods.copy();

View File

@ -103,19 +103,21 @@ public class DeployDialog extends FloatingDialog{
}
TextButton button = Elements.newButton(Core.bundle.format("resume", slot.getZone().localizedName()), Styles.squaret, () -> {
hide();
ui.loadAnd(() -> {
logic.reset();
net.reset();
try{
control.saves.getZoneSlot().load();
state.set(State.playing);
}catch(SaveException e){ //make sure to handle any save load errors!
e.printStackTrace();
if(control.saves.getZoneSlot() != null) control.saves.getZoneSlot().delete();
Core.app.post(() -> ui.showInfo("$save.corrupted"));
show();
}
control.saves.getZoneSlot().cautiousLoad(() -> {
hide();
ui.loadAnd(() -> {
logic.reset();
net.reset();
try{
slot.load();
state.set(State.playing);
}catch(SaveException e){ //make sure to handle any save load errors!
e.printStackTrace();
if(control.saves.getZoneSlot() != null) control.saves.getZoneSlot().delete();
Core.app.post(() -> ui.showInfo("$save.corrupted"));
show();
}
});
});
});

View File

@ -186,22 +186,23 @@ public class LoadDialog extends FloatingDialog{
}
public void runLoadSave(SaveSlot slot){
hide();
ui.paused.hide();
ui.loadAnd(() -> {
try{
net.reset();
slot.load();
state.rules.editor = false;
state.rules.zone = null;
state.set(State.playing);
}catch(SaveException e){
Log.err(e);
state.set(State.menu);
logic.reset();
ui.showErrorMessage("$save.corrupted");
}
slot.cautiousLoad(() -> {
ui.loadAnd(() -> {
hide();
ui.paused.hide();
try{
net.reset();
slot.load();
state.rules.editor = false;
state.rules.zone = null;
state.set(State.playing);
}catch(SaveException e){
Log.err(e);
state.set(State.menu);
logic.reset();
ui.showErrorMessage("$save.corrupted");
}
});
});
}

View File

@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=2a94f9187de5a7fa0b795ba4725fbc3e929b890c
archash=e17b152d4f597837640fe4d659ca5a820e8a2b15