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.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

View File

@@ -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");
} }

View File

@@ -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));

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();

View File

@@ -103,19 +103,21 @@ 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, () -> {
hide(); control.saves.getZoneSlot().cautiousLoad(() -> {
ui.loadAnd(() -> { hide();
logic.reset(); ui.loadAnd(() -> {
net.reset(); logic.reset();
try{ net.reset();
control.saves.getZoneSlot().load(); try{
state.set(State.playing); slot.load();
}catch(SaveException e){ //make sure to handle any save load errors! state.set(State.playing);
e.printStackTrace(); }catch(SaveException e){ //make sure to handle any save load errors!
if(control.saves.getZoneSlot() != null) control.saves.getZoneSlot().delete(); e.printStackTrace();
Core.app.post(() -> ui.showInfo("$save.corrupted")); if(control.saves.getZoneSlot() != null) control.saves.getZoneSlot().delete();
show(); Core.app.post(() -> ui.showInfo("$save.corrupted"));
} show();
}
});
}); });
}); });

View File

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

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