mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-30 16:47:13 +01:00
Reworks the minimap cache system
If minimap generation is disabled, the system will now first try to load the map from its cache, and failing that, try to load it from backup minimap files Also adds a config for space ruin budgets
This commit is contained in:
@@ -184,6 +184,7 @@
|
||||
var/grey_assistants = 0
|
||||
|
||||
var/lavaland_budget = 60
|
||||
var/space_budget = 16
|
||||
|
||||
var/aggressive_changelog = 0
|
||||
|
||||
@@ -620,6 +621,8 @@
|
||||
config.grey_assistants = 1
|
||||
if("lavaland_budget")
|
||||
config.lavaland_budget = text2num(value)
|
||||
if("space_budget")
|
||||
config.space_budget = text2num(value)
|
||||
if("no_summon_guns")
|
||||
config.no_summon_guns = 1
|
||||
if("no_summon_magic")
|
||||
|
||||
@@ -34,7 +34,7 @@ var/datum/subsystem/mapping/SSmapping
|
||||
else
|
||||
space_zlevels += i
|
||||
|
||||
seedRuins(space_zlevels, rand(8,16), /area/space, space_ruins_templates)
|
||||
seedRuins(space_zlevels, config.space_budget, /area/space, space_ruins_templates)
|
||||
|
||||
// Set up Z-level transistions.
|
||||
setup_map_transitions()
|
||||
|
||||
@@ -13,25 +13,44 @@ var/datum/subsystem/minimap/SSminimap
|
||||
NEW_SS_GLOBAL(SSminimap)
|
||||
|
||||
/datum/subsystem/minimap/Initialize(timeofday)
|
||||
if(!config.generate_minimaps)
|
||||
world << "Minimap generation disabled... Skipping"
|
||||
return
|
||||
var/hash = md5(file2text("_maps/[MAP_PATH]/[MAP_FILE]"))
|
||||
if(hash == trim(file2text(hash_path())))
|
||||
return ..()
|
||||
|
||||
for(var/z in z_levels)
|
||||
generate(z)
|
||||
register_asset("minimap_[z].png", fcopy_rsc(map_path(z)))
|
||||
fdel(hash_path())
|
||||
text2file(hash, hash_path())
|
||||
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 ..()
|
||||
for(var/z in z_levels)
|
||||
generate(z)
|
||||
register_asset("minimap_[z].png", fcopy_rsc(map_path(z)))
|
||||
fdel(hash_path())
|
||||
text2file(hash, hash_path())
|
||||
else
|
||||
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
|
||||
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.
|
||||
for(var/z in z_levels)
|
||||
register_asset("minimap_[z].png", fcopy_rsc(map_path(z,fileloc)))
|
||||
..()
|
||||
|
||||
/datum/subsystem/minimap/proc/hash_path()
|
||||
return "data/minimaps/[MAP_NAME].md5"
|
||||
/datum/subsystem/minimap/proc/hash_path(backup)
|
||||
if(backup)
|
||||
return "icons/minimaps/[MAP_NAME].md5"
|
||||
else
|
||||
return "data/minimaps/[MAP_NAME].md5"
|
||||
|
||||
/datum/subsystem/minimap/proc/map_path(z)
|
||||
return "data/minimaps/[MAP_NAME]_[z].png"
|
||||
/datum/subsystem/minimap/proc/map_path(z,backup)
|
||||
if(backup)
|
||||
return "icons/minimaps/[MAP_NAME]_[z].png"
|
||||
else
|
||||
return "data/minimaps/[MAP_NAME]_[z].png"
|
||||
|
||||
/datum/subsystem/minimap/proc/send(client/client)
|
||||
for(var/z in z_levels)
|
||||
|
||||
Reference in New Issue
Block a user