gamemode tweaks
minimap fix
This commit is contained in:
@@ -13,25 +13,55 @@ 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())))
|
||||
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 << "<span class='boldannounce'>Minimap generation disabled. Loading from cache...</span>"
|
||||
var/fileloc = 0
|
||||
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 << "<span class='boldannounce'>Loaded cached minimap is outdated. There may be minor discrepancies in layout.</span>" //Disclaimer against players saying map is wrong.
|
||||
fileloc = 0
|
||||
else
|
||||
if(!check_files(1))
|
||||
world << "<span class='boldannounce'>Failed to load backup minimap file. Aborting.</span>" //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 << "<span class='boldannounce'>No cached minimaps detected. Backup files loaded.</span>"
|
||||
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/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/map_path(z)
|
||||
return "data/minimaps/[MAP_NAME]_[z].png"
|
||||
|
||||
/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,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)
|
||||
@@ -43,24 +73,10 @@ var/datum/subsystem/minimap/SSminimap
|
||||
// Scale it up to our target size.
|
||||
minimap.Scale(MINIMAP_SIZE, MINIMAP_SIZE)
|
||||
|
||||
var/counter = 512
|
||||
// Loop over turfs and generate icons.
|
||||
for(var/T in block(locate(x1, y1, z), locate(x2, y2, z)))
|
||||
generate_tile(T, minimap)
|
||||
|
||||
//byond bug, this fixes OOM crashes by flattening and reseting the minimap icon holder every so and so tiles
|
||||
counter--
|
||||
if(counter <= 0)
|
||||
counter = 512
|
||||
var/icon/flatten = new /icon()
|
||||
flatten.Insert(minimap, "", SOUTH, 1, 0)
|
||||
del(minimap)
|
||||
minimap = flatten
|
||||
stoplag() //we have to sleep in order to get byond to clear out the proc's garbage bin
|
||||
|
||||
CHECK_TICK
|
||||
|
||||
|
||||
// Create a new icon and insert the generated minimap, so that BYOND doesn't generate different directions.
|
||||
var/icon/final = new /icon()
|
||||
final.Insert(minimap, "", SOUTH, 1, 0)
|
||||
@@ -69,7 +85,7 @@ var/datum/subsystem/minimap/SSminimap
|
||||
/datum/subsystem/minimap/proc/generate_tile(turf/tile, icon/minimap)
|
||||
var/icon/tile_icon
|
||||
var/obj/obj
|
||||
var/list/obj_icons = list()
|
||||
var/list/obj_icons
|
||||
// Don't use icons for space, just add objects in space if they exist.
|
||||
if(istype(tile, /turf/open/space))
|
||||
obj = locate(/obj/structure/lattice/catwalk) in tile
|
||||
@@ -86,18 +102,20 @@ var/datum/subsystem/minimap/SSminimap
|
||||
tile_icon = new /icon('icons/obj/atmospherics/pipes/transit_tube.dmi', obj.icon_state, obj.dir)
|
||||
else
|
||||
tile_icon = new /icon(tile.icon, tile.icon_state, tile.dir)
|
||||
obj_icons.Cut()
|
||||
obj_icons = list()
|
||||
|
||||
obj = locate(/obj/structure) in tile
|
||||
if(obj)
|
||||
obj_icons += getFlatIcon(obj)
|
||||
obj_icons += new /icon(obj.icon, obj.icon_state, obj.dir, 1, 0)
|
||||
obj = locate(/obj/machinery) in tile
|
||||
if(obj)
|
||||
obj_icons += new /icon(obj.icon, obj.icon_state, obj.dir, 1, 0)
|
||||
obj = locate(/obj/structure/window) in tile
|
||||
if(obj)
|
||||
obj_icons += new /icon('icons/obj/smooth_structures/window.dmi', "window", SOUTH)
|
||||
|
||||
obj = locate(/obj/structure/table) in tile
|
||||
if(obj)
|
||||
obj_icons += new /icon('icons/obj/smooth_structures/table.dmi', "table", SOUTH)
|
||||
for(var/I in obj_icons)
|
||||
var/icon/obj_icon = I
|
||||
tile_icon.Blend(obj_icon, ICON_OVERLAY)
|
||||
@@ -107,4 +125,3 @@ var/datum/subsystem/minimap/SSminimap
|
||||
tile_icon.Scale(TILE_SIZE, TILE_SIZE)
|
||||
// Add the tile to the minimap.
|
||||
minimap.Blend(tile_icon, ICON_OVERLAY, ((tile.x - 1) * TILE_SIZE), ((tile.y - 1) * TILE_SIZE))
|
||||
del(tile_icon)
|
||||
|
||||
Reference in New Issue
Block a user