From 76a6a0cf751043e651b639061471eeb9cfb4e5e0 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 3 Nov 2018 09:39:59 -0400 Subject: [PATCH] Fixed crash when trying to open non-existent map --- core/assets/bundles/bundle.properties | 1 + .../src/io/anuke/mindustry/ui/dialogs/JoinDialog.java | 3 --- .../src/io/anuke/mindustry/ui/dialogs/MapsDialog.java | 11 ++++++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index b910981ceb..b9459fe6a8 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -268,6 +268,7 @@ text.error.invalidaddress = Invalid address. text.error.timedout = Timed out!\nMake sure the host has port forwarding set up, and that the address is correct! text.error.mismatch = Packet error:\npossible client/server version mismatch.\nMake sure you and the host have the latest version of Mindustry! text.error.alreadyconnected = Already connected. +text.error.mapnotfound = Map file not found! text.error.any = Unkown network error. text.settings.language = Language diff --git a/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java index 0cbd003d69..1e178435f6 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java @@ -177,8 +177,6 @@ public class JoinDialog extends FloatingDialog{ t.add("[lightgray]" + Bundles.format("text.save.map", host.mapname) + " / " + Bundles.format("text.save.wave", host.wave)).left(); }).expand().left().bottom().padLeft(12f).padBottom(8); - //server.content.add(versionString).top().expandY().top().expandX(); - }, e -> { server.content.clear(); server.content.add("$text.host.invalid"); @@ -323,7 +321,6 @@ public class JoinDialog extends FloatingDialog{ public String ip; public int port; - transient Host host; transient Table content; void setIP(String ip){ diff --git a/core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java index dfc9ebb832..8308424f10 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java @@ -147,9 +147,14 @@ public class MapsDialog extends FloatingDialog{ table.row(); table.addImageTextButton("$text.editor.openin", "icon-load-map", "clear", 16 * 2, () -> { - Vars.ui.editor.beginEditMap(map.stream.get()); - dialog.hide(); - hide(); + try{ + Vars.ui.editor.beginEditMap(map.stream.get()); + dialog.hide(); + hide(); + }catch(Exception e){ + e.printStackTrace(); + ui.showError("$text.error.mapnotfound"); + } }).fillX().height(50f).marginLeft(6); table.addImageTextButton("$text.delete", "icon-trash-16", "clear", 16 * 2, () -> {