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:
Shadowlight213
2016-09-11 01:11:16 -07:00
parent c3c2a90e41
commit 43e3975b10
10 changed files with 41 additions and 16 deletions

View File

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

View File

@@ -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()

View File

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

View File

@@ -355,3 +355,6 @@ BOMBCAP 20
# spawn, while the converse is true. Alter this number to affect the amount
# of ruins.
LAVALAND_BUDGET 60
## Space Ruin Budged
Space_Budget 16

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 917 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 KiB