From 6d6fac00d78789a02a7cfd8dbd1cc2b0bca34b28 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 22 Nov 2019 15:33:01 -0500 Subject: [PATCH] Less hacky support for atrocious json --- core/assets/bundles/bundle.properties | 2 +- .../io/anuke/mindustry/mod/ContentParser.java | 19 +++++-------------- core/src/io/anuke/mindustry/mod/Mods.java | 11 +---------- .../mindustry/ui/fragments/HudFragment.java | 2 +- .../android/en-US/changelogs/100.1.txt | 5 +++++ gradle.properties | 2 +- 6 files changed, 14 insertions(+), 27 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/100.1.txt diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index f765cdbae9..b317b385eb 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -1084,7 +1084,7 @@ mech.alpha-mech.description = The standard control mech. Based on a Dagger unit, mech.delta-mech.description = A fast, lightly-armored mech made for hit-and-run attacks. Does little damage against structures, but can kill large groups of enemy units very quickly with its arc lightning weapons. mech.tau-mech.description = The support mech. Heals allied blocks by shooting at them. Can heal allies in a radius with its repair ability. mech.omega-mech.description = A bulky and well-armored mech, made for front-line assaults. Its armor can block up to 90% of incoming damage. -mech.dart-ship.description = The standard control ship. Reasonably fast and light, but has little offensive capability and low mining speed. +mech.dart-ship.description = The standard control ship. Fast mining speed. Reasonably fast and light, but has little offensive capability. mech.javelin-ship.description = A hit-and-run strike ship. While initially slow, it can accelerate to great speeds and fly by enemy outposts, dealing large amounts of damage with its lightning and missiles. mech.trident-ship.description = A heavy bomber, built for construction and destroying enemy fortifications. Reasonably well armored. mech.glaive-ship.description = A large, well-armored gunship. Equipped with an incendiary repeater. Highly maneuverable. diff --git a/core/src/io/anuke/mindustry/mod/ContentParser.java b/core/src/io/anuke/mindustry/mod/ContentParser.java index e76ba11029..1d3fd47a45 100644 --- a/core/src/io/anuke/mindustry/mod/ContentParser.java +++ b/core/src/io/anuke/mindustry/mod/ContentParser.java @@ -365,22 +365,13 @@ public class ContentParser{ init(); } - JsonValue value; - try{ - //try to read hjson, bail out if it doesn't work - value = parser.fromJson(null, Jval.read(json).toString(Jformat.plain)); - }catch(Throwable t){ - try{ - value = parser.fromJson(null, json); - }catch(Throwable extra){ - if(t instanceof RuntimeException){ - throw t; - }else{ - throw new RuntimeException(t); - } - } + //remove extra # characters to make it valid json... apparently some people have *unquoted* # characters in their json + if(file.extension().equals("json")){ + json = json.replace("#", "\\#"); } + JsonValue value = parser.fromJson(null, Jval.read(json).toString(Jformat.plain)); + if(!parsers.containsKey(type)){ throw new SerializationException("No parsers for content type '" + type + "'"); } diff --git a/core/src/io/anuke/mindustry/mod/Mods.java b/core/src/io/anuke/mindustry/mod/Mods.java index 77b81827ff..0a2764e27c 100644 --- a/core/src/io/anuke/mindustry/mod/Mods.java +++ b/core/src/io/anuke/mindustry/mod/Mods.java @@ -493,16 +493,7 @@ public class Mods implements Loadable{ throw new IllegalArgumentException("No mod.json found."); } - //try to read as hjson if possible - String readString = metaf.readString(); - try{ - readString = Jval.read(readString).toString(Jformat.plain); - }catch(Throwable e){ - e.printStackTrace(); - readString = metaf.readString(); - } - - ModMeta meta = json.fromJson(ModMeta.class, readString); + ModMeta meta = json.fromJson(ModMeta.class, Jval.read(metaf.readString()).toString(Jformat.plain)); String camelized = meta.name.replace(" ", ""); String mainClass = meta.main == null ? camelized.toLowerCase() + "." + camelized + "Mod" : meta.main; String baseName = meta.name.toLowerCase().replace(" ", "-"); diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index caca0a81a9..3bbce3b1ec 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -345,7 +345,7 @@ public class HudFragment extends Fragment{ @Remote(targets = Loc.both, forward = true, called = Loc.both) public static void setPlayerTeamEditor(Player player, Team team){ - if(state.isEditor()){ + if(state.isEditor() && player != null){ player.setTeam(team); } } diff --git a/fastlane/metadata/android/en-US/changelogs/100.1.txt b/fastlane/metadata/android/en-US/changelogs/100.1.txt new file mode 100644 index 0000000000..53c981258b --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/100.1.txt @@ -0,0 +1,5 @@ +- Added fallback mod loading for poorly formatted old mods +- Fixed infinite building range +- Fixed impact reactors being able to blow up core on servers +- Fixed liquid bridges passing backwards +- Updated various translations diff --git a/gradle.properties b/gradle.properties index 2eff81cfef..ea6984d9ee 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=92f150377ea71e7d132f88fc6e331dc49b21d5c5 +archash=e678c42cdc539e794ad0a0079a45970181aa2fe3