diff --git a/code/controllers/subsystem/minimap.dm b/code/controllers/subsystem/minimap.dm index 4cab5475475..679104bbc62 100644 --- a/code/controllers/subsystem/minimap.dm +++ b/code/controllers/subsystem/minimap.dm @@ -16,7 +16,6 @@ var/datum/subsystem/minimap/SSminimap var/hash = md5(file2text("_maps/[MAP_PATH]/[MAP_FILE]")) if(config.generate_minimaps) if(hash == trim(file2text(hash_path()))) - world.log << "Hash check [hash]" for(var/z in z_levels) //We have these files cached, let's register them register_asset("minimap_[z].png", fcopy_rsc(map_path(z))) return ..() @@ -26,20 +25,32 @@ var/datum/subsystem/minimap/SSminimap fdel(hash_path()) text2file(hash, hash_path()) else - world << "Minimap generation disabled. Loading from cache..." + world << "Minimap generation disabled. Loading from cache..." var/fileloc = 0 - if(hash == trim(file2text(hash_path())))//Let's see if we have a map cached that we can use + if(check_files(0)) //Let's first check if we have maps cached in the data folder. NOTE: This will override the backup files even if this map is older. + world.log << "cache" + if(hash != trim(file2text(hash_path()))) + world << "Loaded cached minimap is outdated. There may be minor discrepancies in layout." //Disclaimer against players saying map is wrong. fileloc = 0 else - for(var/z in z_levels) - if(!isfile(file(map_path(z,1)))) //Let's make sure we have a backup file for this map. - world << "Failed to load backup minimap file on zlevel [z]. Aborting" //We couldn't find something. Bail to prevent issues with null files - return - fileloc = 1 //No map image cached with the current map, and we have a backup. Let's fall back to it. + if(!check_files(1)) + world << "Failed to load backup minimap file. Aborting." //We couldn't find something. Bail to prevent issues with null files + return + fileloc = 1 //No map image cached with the current map, and we have a backup. Let's fall back to it. + world << "No cached minimaps detected. Backup files loaded." for(var/z in z_levels) register_asset("minimap_[z].png", fcopy_rsc(map_path(z,fileloc))) ..() +/datum/subsystem/minimap/proc/check_files(backup) // If the backup argument is true, looks in the icons folder. If false looks in the data folder. + for(var/z in z_levels) + if(!fexists(file(map_path(z,backup)))) //Let's make sure we have a file for this map + if(backup) + world.log << "Failed to find backup file for map [MAP_NAME] on zlevel [z]." + return FALSE + return TRUE + + /datum/subsystem/minimap/proc/hash_path(backup) if(backup) return "icons/minimaps/[MAP_NAME].md5"