From 081b6b0a04b69137e6b52682642272696883833e Mon Sep 17 00:00:00 2001 From: Bjorn Neergaard Date: Sat, 23 Jan 2016 18:55:25 -0600 Subject: [PATCH 1/4] Rework minimaps --- _maps/DiscStation.dm | 1 + _maps/asteroidstation.dm | 1 + _maps/birdstation.dm | 1 + _maps/dreamstation.dm | 1 + _maps/metastation.dm | 1 + _maps/ministation.dm | 1 + _maps/tgstation2.dm | 1 + code/controllers/master.dm | 2 +- code/controllers/subsystem/minimap.dm | 224 +++++++------------------- code/game/machinery/computer/crew.dm | 2 +- icons/minimap.dmi | Bin 0 -> 196 bytes 11 files changed, 71 insertions(+), 164 deletions(-) create mode 100644 icons/minimap.dmi diff --git a/_maps/DiscStation.dm b/_maps/DiscStation.dm index 1b163f1c880..059d4c6166e 100644 --- a/_maps/DiscStation.dm +++ b/_maps/DiscStation.dm @@ -15,6 +15,7 @@ Names of z-level do not matter, but order does greatly, for instances such as ch #include "map_files\generic\z7.dmm" + #define MAP_PATH "map_files/DiscStation" #define MAP_FILE "DiscStation.dmm" #define MAP_NAME "DiscStation" diff --git a/_maps/asteroidstation.dm b/_maps/asteroidstation.dm index c337bda0cbb..88c7ee1ebe3 100644 --- a/_maps/asteroidstation.dm +++ b/_maps/asteroidstation.dm @@ -14,6 +14,7 @@ Names of z-level do not matter, but order does greatly, for instances such as ch #include "map_files\generic\z6.dmm" #include "map_files\generic\z7.dmm" + #define MAP_PATH "map_files/AsteroidStation" #define MAP_FILE "AsteroidStation.dmm" #define MAP_NAME "AsteroidStation" diff --git a/_maps/birdstation.dm b/_maps/birdstation.dm index 70e6875db2f..0605a82a166 100644 --- a/_maps/birdstation.dm +++ b/_maps/birdstation.dm @@ -16,6 +16,7 @@ A small map intended for lowpop(40 players and less). #include "map_files\generic\z6.dmm" #include "map_files\generic\z7.dmm" + #define MAP_PATH "map_files/BirdStation" #define MAP_FILE "BirdStation.dmm" #define MAP_NAME "BirdboatStation" diff --git a/_maps/dreamstation.dm b/_maps/dreamstation.dm index f03e2446329..e46fd09f200 100644 --- a/_maps/dreamstation.dm +++ b/_maps/dreamstation.dm @@ -23,6 +23,7 @@ z7 = empty space #include "map_files\generic\z6.dmm" #include "map_files\generic\z7.dmm" + #define MAP_PATH "map_files/DreamStation" #define MAP_FILE "dreamstation04.dmm" #define MAP_NAME "DreamStation" diff --git a/_maps/metastation.dm b/_maps/metastation.dm index 0a0403d7ab8..cff27a6cdbc 100644 --- a/_maps/metastation.dm +++ b/_maps/metastation.dm @@ -23,6 +23,7 @@ z7 = empty space #include "map_files\generic\z6.dmm" #include "map_files\generic\z7.dmm" + #define MAP_PATH "map_files/MetaStation" #define MAP_FILE "MetaStation.v41I.dmm" #define MAP_NAME "MetaStation" diff --git a/_maps/ministation.dm b/_maps/ministation.dm index 1545ae1c691..ca79390cd21 100644 --- a/_maps/ministation.dm +++ b/_maps/ministation.dm @@ -56,6 +56,7 @@ Changes to the uplinks were made to discourage murderboning, the rest is the sam #include "map_files\generic\z6.dmm" #include "map_files\generic\z7.dmm" + #define MAP_PATH "map_files/MiniStation" #define MAP_FILE "MiniStation.dmm" #define MAP_NAME "MiniStation" diff --git a/_maps/tgstation2.dm b/_maps/tgstation2.dm index 75caa2f02f4..0e0bbf33318 100644 --- a/_maps/tgstation2.dm +++ b/_maps/tgstation2.dm @@ -23,6 +23,7 @@ z7 = empty space #include "map_files\generic\z6.dmm" #include "map_files\generic\z7.dmm" + #define MAP_PATH "map_files/TgStation" #define MAP_FILE "tgstation.2.1.3.dmm" #define MAP_NAME "Box Station" diff --git a/code/controllers/master.dm b/code/controllers/master.dm index 063552d3769..67fdc91a090 100644 --- a/code/controllers/master.dm +++ b/code/controllers/master.dm @@ -65,7 +65,7 @@ var/global/datum/controller/master/Master = new() /datum/controller/master/proc/Setup(zlevel) // Per-Z-level subsystems. - if (zlevel && zlevel > 0 && zlevel <= world.maxz) + if(zlevel && zlevel > 0 && zlevel <= world.maxz) for(var/datum/subsystem/SS in subsystems) SS.Initialize(world.timeofday, zlevel) sleep(-1) diff --git a/code/controllers/subsystem/minimap.dm b/code/controllers/subsystem/minimap.dm index 51497429a43..29a2a77cd38 100644 --- a/code/controllers/subsystem/minimap.dm +++ b/code/controllers/subsystem/minimap.dm @@ -1,19 +1,13 @@ -// Activate this to debug tile mismatches in the minimap. -// This will store the full information on each tile and compare it the next time you run the minimap. -// It can be used to find out what's changed since the last iteration. -// Only activate this when you need it - this should never be active on a live server! -// #define MINIMAP_DEBUG - var/datum/subsystem/minimap/SSminimap /datum/subsystem/minimap name = "Minimap" priority = -2 - var/const/MAX_ICON_DIMENSION = 1024 - var/const/ICON_SIZE = 4 + var/const/MINIMAP_SIZE = 4080 + var/const/TILE_SIZE = 16 - var/max_initalized_zlevel = 0 + var/list/z_levels = list(1) /datum/subsystem/minimap/New() NEW_SS_GLOBAL(SSminimap) @@ -21,163 +15,69 @@ var/datum/subsystem/minimap/SSminimap /datum/subsystem/minimap/Initialize(timeofday, zlevel) if(zlevel) return ..() - for(var/z = 1 to ZLEVEL_SPACEMAX) + + 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", file("[getMinimapFile(z)].png")) - max_initalized_zlevel = ZLEVEL_SPACEMAX + register_asset("minimap_[z].png", fcopy_rsc(map_path(z))) + text2file(hash, hash_path()) ..() -/datum/subsystem/minimap/proc/generate(z, x1 = 1, y1 = 1, x2 = world.maxx, y2 = world.maxy) - var/result_path = "[src.getMinimapFile(z)].png" - var/hash_path = "[src.getMinimapFile(z)].md5" - var/list/tiles = block(locate(x1, y1, z), locate(x2, y2, z)) - var/hash = "" - var/temp - var/obj/obj +/datum/subsystem/minimap/proc/hash_path() + return "data/minimaps/[MAP_NAME].md5" - #ifdef MINIMAP_DEBUG - var/tiledata_path = "data/minimaps/debug_tiledata_[z].sav" - var/savefile/F = new/savefile(tiledata_path) - #endif +/datum/subsystem/minimap/proc/map_path(z) + return "data/minimaps/[MAP_NAME]_[z].png" - // Note for future developer: If you have tiles on the map with random or dynamic icons this hash check will fail - // every time. You'll have to modify this code to generate a unique hash for your object. - // Don't forget to modify the minimap generation code to use a default icon (or skip generation altogether). - for (var/turf/tile in tiles) - if (istype(tile.loc, /area/asteroid) || istype(tile.loc, /area/mine/unexplored) || istype(tile, /turf/simulated/mineral) || (istype(tile.loc, /area/space) && istype(tile, /turf/simulated/floor/plating/asteroid))) - temp = "/area/asteroid" - else if (istype(tile.loc, /area/mine) && istype(tile, /turf/simulated/floor/plating/asteroid)) - temp = "/area/mine/explored" - else if (tile.loc.type == /area/start || (tile.type == /turf/space && !(locate(/obj/structure/lattice) in tile)) || istype(tile, /turf/space/transit)) - temp = "/turf/space" - if (locate(/obj/structure/lattice/catwalk) in tile) - - else - else if (tile.type == /turf/space) - if (locate(/obj/structure/lattice/catwalk) in tile) - temp = "/obj/structure/lattice/catwalk" - else - temp = "/obj/structure/lattice" - else if (tile.type == /turf/simulated/floor/plating/abductor) - temp = "/turf/simulated/floor/plating/abductor" - else if (tile.type == /turf/simulated/floor/plating && (locate(/obj/structure/window/shuttle) in tile)) - temp = "/obj/structure/window/shuttle" - else - temp = "[tile.icon][tile.icon_state][tile.dir]" - - obj = locate(/obj/structure/transit_tube) in tile - - if (obj) temp = "[temp]/obj/structure/transit_tube[obj.icon_state][obj.dir]" - - #ifdef MINIMAP_DEBUG - if (F["/[tile.y]/[tile.x]"] && F["/[tile.y]/[tile.x]"] != temp) - CRASH("Mismatch: [tile.type] at [tile.x],[tile.y],[tile.z] ([tile.icon], [tile.icon_state], [tile.dir])") - else - F["/[tile.y]/[tile.x]"] << temp - #endif - - hash = md5("[hash][temp]") - - if (fexists(result_path)) - if (!fexists(hash_path) || trim(file2text(hash_path)) != hash) - fdel(result_path) - fdel(hash_path) - - if (!fexists(result_path)) - ASSERT(x1 > 0) - ASSERT(y1 > 0) - ASSERT(x2 <= world.maxx) - ASSERT(y2 <= world.maxy) - - var/icon/map_icon = new/icon('html/mapbase1024.png') - - // map_icon is fine and contains only 1 direction at this point. - - ASSERT(map_icon.Width() == MAX_ICON_DIMENSION && map_icon.Height() == MAX_ICON_DIMENSION) - - - var/i = 0 - var/icon/turf_icon - var/icon/obj_icon - var/old_icon - var/old_icon_state - var/old_dir - var/new_icon - var/new_icon_state - var/new_dir - - for (var/turf/tile in tiles) - if (tile.loc.type != /area/start && (tile.type != /turf/space || (locate(/obj/structure/lattice) in tile) || (locate(/obj/structure/transit_tube) in tile)) && !istype(tile, /turf/space/transit)) - if (istype(tile.loc, /area/asteroid) || istype(tile.loc, /area/mine/unexplored) || istype(tile, /turf/simulated/mineral) || (istype(tile.loc, /area/space) && istype(tile, /turf/simulated/floor/plating/asteroid))) - new_icon = 'icons/turf/mining.dmi' - new_icon_state = "rock" - new_dir = 2 - else if (istype(tile.loc, /area/mine) && istype(tile, /turf/simulated/floor/plating/asteroid)) - new_icon = 'icons/turf/floors.dmi' - new_icon_state = "asteroid" - new_dir = 2 - else if (tile.type == /turf/simulated/floor/plating/abductor) - new_icon = 'icons/turf/floors.dmi' - new_icon_state = "alienpod1" - new_dir = 2 - else if (tile.type == /turf/space) - obj = locate(/obj/structure/lattice) in tile - - if (!obj) obj = locate(/obj/structure/transit_tube) in tile - - ASSERT(obj != null) - - if (obj) - new_icon = obj.icon - new_dir = obj.dir - new_icon_state = obj.icon_state - else if (tile.type == /turf/simulated/floor/plating && (locate(/obj/structure/window/shuttle) in tile)) - new_icon = 'icons/obj/structures.dmi' - new_dir = 2 - new_icon_state = "swindow" - else - new_icon = tile.icon - new_icon_state = tile.icon_state - new_dir = tile.dir - - if (new_icon != old_icon || new_icon_state != old_icon_state || new_dir != old_dir) - old_icon = new_icon - old_icon_state = new_icon_state - old_dir = new_dir - - turf_icon = new/icon(new_icon, new_icon_state, new_dir, 1, 0) - turf_icon.Scale(ICON_SIZE, ICON_SIZE) - - if (tile.type != /turf/space || (locate(/obj/structure/lattice) in tile)) - obj = locate(/obj/structure/transit_tube) in tile - - if (obj) - obj_icon = new/icon(obj.icon, obj.icon_state, obj.dir, 1, 0) - obj_icon.Scale(ICON_SIZE, ICON_SIZE) - turf_icon.Blend(obj_icon, ICON_OVERLAY) - - map_icon.Blend(turf_icon, ICON_OVERLAY, ((tile.x - 1) * ICON_SIZE), ((tile.y - 1) * ICON_SIZE)) - - if ((++i) % 512 == 0) sleep(1) // deliberate delay to avoid lag spikes - - else - sleep(-1) // avoid sleeping if possible: prioritize pending procs - - // BYOND BUG: map_icon now contains 4 directions? Create a new icon with only a single state. - var/icon/result_icon = new/icon() - - result_icon.Insert(map_icon, "", SOUTH, 1, 0) - - fcopy(result_icon, result_path) - text2file(hash, hash_path) - -/datum/subsystem/minimap/proc/getMinimapFile(zlevel) - return "data/minimaps/[MAP_NAME]_[zlevel]" - -/datum/subsystem/minimap/proc/sendMinimaps(client/client) - for(var/z = 1 to max_initalized_zlevel) +/datum/subsystem/minimap/proc/send(client/client) + for(var/z in z_levels) send_asset(client, "minimap_[z].png") -#ifdef MINIMAP_DEBUG -#undef MINIMAP_DEBUG -#endif +/datum/subsystem/minimap/proc/generate(z = 1, x1 = 1, y1 = 1, x2 = world.maxx, y2 = world.maxy) + // Load the background. + var/icon/minimap = new /icon('icons/minimap.dmi') + // Scale it up to our target size. + minimap.Scale(MINIMAP_SIZE, MINIMAP_SIZE) + + // Loop over turfs and generate icons. + for(var/turf/tile in block(locate(x1, y1, z), locate(x2, y2, z))) + var/obj/obj + var/icon/ikon = new /icon('icons/minimap.dmi') + + // Don't use icons for space, just add objects in space if they exist. + if(istype(tile, /turf/space)) + obj = locate(/obj/structure/lattice) in tile + if(obj) + ikon = new /icon('icons/obj/smooth_structures/lattice.dmi', "lattice", 2) + obj = locate(/obj/structure/grille) in tile + if(obj) + ikon = new /icon('icons/obj/structures.dmi', "grille", 2) + obj = locate(/obj/structure/transit_tube) in tile + if(obj) + ikon = new /icon('icons/obj/atmospherics/pipes/transit_tube.dmi', obj.icon_state, obj.dir) + else + ikon = new(tile.icon, tile.icon_state, tile.dir) + + var/icon/object + obj = locate(/obj/structure/window/reinforced) in tile + if(obj) + object = new /icon('icons/obj/smooth_structures/reinforced_window.dmi', "r_window", 2) + obj = locate(/obj/machinery/door/airlock) in tile + if(obj) + object = new /icon(obj.icon, obj.icon_state, obj.dir, 1, 0) + + if(object) + ikon.Blend(object, ICON_OVERLAY) + + // Scale the icon. + ikon.Scale(TILE_SIZE, TILE_SIZE) + // Add the tile to the minimap. + minimap.Blend(ikon, ICON_OVERLAY, ((tile.x - 1) * TILE_SIZE), ((tile.y - 1) * TILE_SIZE)) + + // 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) + fcopy(minimap, map_path(z)) \ No newline at end of file diff --git a/code/game/machinery/computer/crew.dm b/code/game/machinery/computer/crew.dm index 9ecc9cd17ec..a1f58a67ef5 100644 --- a/code/game/machinery/computer/crew.dm +++ b/code/game/machinery/computer/crew.dm @@ -256,4 +256,4 @@ var/global/datum/crewmonitor/crewmonitor = new /datum/crewmonitor/proc/sendResources(var/client/client) send_asset(client, "crewmonitor.js") send_asset(client, "crewmonitor.css") - SSminimap.sendMinimaps(client) + SSminimap.send(client) diff --git a/icons/minimap.dmi b/icons/minimap.dmi new file mode 100644 index 0000000000000000000000000000000000000000..98d85f2738160648257154e0d9c05c94f702bba8 GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnL3?x0byx0z;m;-!5T!HlRD%)E?Dy1qUqQoV& zIJqdZpd>RtkAb0LPH Date: Sat, 23 Jan 2016 20:19:03 -0600 Subject: [PATCH 2/4] Fix minimap generation for most objects --- code/controllers/subsystem/minimap.dm | 50 ++++++++++++++++----------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/code/controllers/subsystem/minimap.dm b/code/controllers/subsystem/minimap.dm index 29a2a77cd38..63ec4e91dd8 100644 --- a/code/controllers/subsystem/minimap.dm +++ b/code/controllers/subsystem/minimap.dm @@ -4,8 +4,8 @@ var/datum/subsystem/minimap/SSminimap name = "Minimap" priority = -2 - var/const/MINIMAP_SIZE = 4080 - var/const/TILE_SIZE = 16 + var/const/MINIMAP_SIZE = 2048 + var/const/TILE_SIZE = 8 var/list/z_levels = list(1) @@ -44,40 +44,48 @@ var/datum/subsystem/minimap/SSminimap // Loop over turfs and generate icons. for(var/turf/tile in block(locate(x1, y1, z), locate(x2, y2, z))) + var/icon/tile_icon var/obj/obj - var/icon/ikon = new /icon('icons/minimap.dmi') + // Don't use icons for space, just add objects in space if they exist. if(istype(tile, /turf/space)) + obj = locate(/obj/structure/lattice/catwalk) in tile + if(obj) + tile_icon = new /icon('icons/obj/smooth_structures/catwalk.dmi', "catwalk", SOUTH) obj = locate(/obj/structure/lattice) in tile if(obj) - ikon = new /icon('icons/obj/smooth_structures/lattice.dmi', "lattice", 2) + tile_icon = new /icon('icons/obj/smooth_structures/lattice.dmi', "lattice", SOUTH) obj = locate(/obj/structure/grille) in tile if(obj) - ikon = new /icon('icons/obj/structures.dmi', "grille", 2) + tile_icon = new /icon('icons/obj/structures.dmi', "grille", SOUTH) obj = locate(/obj/structure/transit_tube) in tile if(obj) - ikon = new /icon('icons/obj/atmospherics/pipes/transit_tube.dmi', obj.icon_state, obj.dir) + tile_icon = new /icon('icons/obj/atmospherics/pipes/transit_tube.dmi', obj.icon_state, obj.dir) else - ikon = new(tile.icon, tile.icon_state, tile.dir) + tile_icon = new /icon(tile.icon, tile.icon_state, tile.dir) + var/list/obj_icons = list() - var/icon/object - obj = locate(/obj/structure/window/reinforced) in tile + obj = locate(/obj/structure) in tile if(obj) - object = new /icon('icons/obj/smooth_structures/reinforced_window.dmi', "r_window", 2) - obj = locate(/obj/machinery/door/airlock) in tile + obj_icons += getFlatIcon(obj) + obj = locate(/obj/machinery) in tile if(obj) - object = new /icon(obj.icon, obj.icon_state, obj.dir, 1, 0) + 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) - if(object) - ikon.Blend(object, ICON_OVERLAY) + for(var/icon/obj_icon in obj_icons) + tile_icon.Blend(obj_icon, ICON_OVERLAY) - // Scale the icon. - ikon.Scale(TILE_SIZE, TILE_SIZE) - // Add the tile to the minimap. - minimap.Blend(ikon, ICON_OVERLAY, ((tile.x - 1) * TILE_SIZE), ((tile.y - 1) * TILE_SIZE)) + if(tile_icon) + // Scale the icon. + 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)) // 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) - fcopy(minimap, map_path(z)) \ No newline at end of file + var/icon/final = new /icon() + final.Insert(minimap, "", SOUTH, 1, 0) + fcopy(final, map_path(z)) \ No newline at end of file From 2fe70f6d7e5e30c5c96f0abed740c373ca5acb32 Mon Sep 17 00:00:00 2001 From: Bjorn Neergaard Date: Sat, 23 Jan 2016 20:47:24 -0600 Subject: [PATCH 3/4] Remie is loopy --- code/controllers/subsystem/minimap.dm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/controllers/subsystem/minimap.dm b/code/controllers/subsystem/minimap.dm index 63ec4e91dd8..56e31f1ae24 100644 --- a/code/controllers/subsystem/minimap.dm +++ b/code/controllers/subsystem/minimap.dm @@ -43,11 +43,11 @@ var/datum/subsystem/minimap/SSminimap minimap.Scale(MINIMAP_SIZE, MINIMAP_SIZE) // Loop over turfs and generate icons. - for(var/turf/tile in block(locate(x1, y1, z), locate(x2, y2, z))) + for(var/T in block(locate(x1, y1, z), locate(x2, y2, z))) + var/turf/tile = T var/icon/tile_icon var/obj/obj - // Don't use icons for space, just add objects in space if they exist. if(istype(tile, /turf/space)) obj = locate(/obj/structure/lattice/catwalk) in tile @@ -76,7 +76,8 @@ var/datum/subsystem/minimap/SSminimap if(obj) obj_icons += new /icon('icons/obj/smooth_structures/window.dmi', "window", SOUTH) - for(var/icon/obj_icon in obj_icons) + for(var/I in obj_icons) + var/icon/obj_icon = I tile_icon.Blend(obj_icon, ICON_OVERLAY) if(tile_icon) From 47f08f3714d9e8ef36485a11e6175ba619d1362d Mon Sep 17 00:00:00 2001 From: Bjorn Neergaard Date: Sun, 24 Jan 2016 20:07:14 -0600 Subject: [PATCH 4/4] Use defines for Z-levels --- code/controllers/subsystem/minimap.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/controllers/subsystem/minimap.dm b/code/controllers/subsystem/minimap.dm index 56e31f1ae24..de40efbe5c0 100644 --- a/code/controllers/subsystem/minimap.dm +++ b/code/controllers/subsystem/minimap.dm @@ -7,7 +7,7 @@ var/datum/subsystem/minimap/SSminimap var/const/MINIMAP_SIZE = 2048 var/const/TILE_SIZE = 8 - var/list/z_levels = list(1) + var/list/z_levels = list(ZLEVEL_STATION) /datum/subsystem/minimap/New() NEW_SS_GLOBAL(SSminimap)