diff --git a/core/src/mindustry/mod/ContentPatcher.java b/core/src/mindustry/mod/ContentPatcher.java index ed03f6ca89..620fb07145 100644 --- a/core/src/mindustry/mod/ContentPatcher.java +++ b/core/src/mindustry/mod/ContentPatcher.java @@ -70,12 +70,14 @@ public class ContentPatcher{ patches.clear(); for(String patch : patchArray){ + PatchSet set = new PatchSet(patch, new JsonValue("error")); + patches.add(set); + try{ JsonValue value = parser.getJson().fromJson(null, Jval.read(patch).toString(Jformat.plain)); - PatchSet set = new PatchSet(patch, value); - patches.add(set); currentlyApplying = set; + set.name = value.getString("name", ""); value.remove("name"); //patchsets can have a name, ignore it if present for(var child : value){ assign(root, child.name, child, null, null, null); @@ -83,8 +85,9 @@ public class ContentPatcher{ currentlyApplying = null; }catch(Exception e){ - patches.peek().error = true; - patches.peek().warnings.add(Strings.getSimpleMessage(e)); + set.error = true; + set.warnings.add(Strings.getSimpleMessage(e)); + currentlyApplying = null; Log.err("Failed to apply patch: " + patch, e); } @@ -516,14 +519,13 @@ public class ContentPatcher{ public static class PatchSet{ public String patch; public JsonValue json; - public String name; + public String name = ""; public boolean error; public Seq warnings = new Seq<>(); public PatchSet(String patch, JsonValue json){ this.patch = patch; this.json = json; - name = json.getString("name", ""); } } diff --git a/tests/src/test/java/PatcherTests.java b/tests/src/test/java/PatcherTests.java index d272510e7a..a88fa262c0 100644 --- a/tests/src/test/java/PatcherTests.java +++ b/tests/src/test/java/PatcherTests.java @@ -244,7 +244,7 @@ public class PatcherTests{ unit.dagger.frogs: 10 """)); - assertEquals(1, Vars.state.patcher.patches.first().warnings.size); + assertEquals(2, Vars.state.patcher.patches.first().warnings.size); } @Test