Made invalid legacy maps be properly discarded

This commit is contained in:
Anuken
2019-05-16 17:15:22 -04:00
parent aeb3662414
commit 8616fc6b05
2 changed files with 6 additions and 2 deletions

View File

@@ -167,6 +167,10 @@ public class ContentLoader{
public <T extends Content> 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
}

View File

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