From 8616fc6b05035b8322b371da1041f87116d459de Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 16 May 2019 17:15:22 -0400 Subject: [PATCH] Made invalid legacy maps be properly discarded --- core/src/io/anuke/mindustry/core/ContentLoader.java | 4 ++++ core/src/io/anuke/mindustry/maps/Maps.java | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/io/anuke/mindustry/core/ContentLoader.java b/core/src/io/anuke/mindustry/core/ContentLoader.java index c7af6e9154..f84e770ca3 100644 --- a/core/src/io/anuke/mindustry/core/ContentLoader.java +++ b/core/src/io/anuke/mindustry/core/ContentLoader.java @@ -167,6 +167,10 @@ public class ContentLoader{ public T getByID(ContentType type, int id){ if(temporaryMapper != null && temporaryMapper[type.ordinal()] != null && temporaryMapper[type.ordinal()].length != 0){ + //-1 = invalid content + if(id < 0){ + return null; + } if(temporaryMapper[type.ordinal()].length <= id || temporaryMapper[type.ordinal()][id] == null){ return getByID(type, 0); //default value is always ID 0 } diff --git a/core/src/io/anuke/mindustry/maps/Maps.java b/core/src/io/anuke/mindustry/maps/Maps.java index 8b7017a935..ba37fe1ad5 100644 --- a/core/src/io/anuke/mindustry/maps/Maps.java +++ b/core/src/io/anuke/mindustry/maps/Maps.java @@ -162,12 +162,12 @@ public class Maps implements Disposable{ for(FileHandle file : customMapDirectory.list()){ if(file.extension().equalsIgnoreCase(oldMapExtension)){ try{ + convertedAny = true; LegacyMapIO.convertMap(file, file.sibling(file.nameWithoutExtension() + "." + mapExtension)); //delete old, converted file; it is no longer useful file.delete(); - convertedAny = true; Log.info("Converted file {0}", file); - }catch(IOException e){ + }catch(Exception e){ //rename the file to a 'mmap_conversion_failed' extension to keep it there just in case //but don't delete it file.copyTo(file.sibling(file.name() + "_conversion_failed"));