From 56bb1c46ec066c456c36806fc1f86427061614f8 Mon Sep 17 00:00:00 2001 From: Leshana Date: Mon, 5 Feb 2018 00:02:57 -0500 Subject: [PATCH] Reorganzied Holo Minimaps into SSholomaps subsystem. Running its init as part of proper init sequence lets us time it properly. Plus its nicer than the hacky override of the old master controller. --- code/__defines/subsystems.dm | 1 + code/controllers/subsystems/holomaps_vr.dm | 24 ++++++++++++++++++++++ code/modules/holomap/generate_holomap.dm | 24 +++++++--------------- code/modules/holomap/holomap_datum.dm | 4 ++-- code/modules/holomap/station_holomap.dm | 18 ++++++++-------- vorestation.dme | 1 + 6 files changed, 44 insertions(+), 28 deletions(-) create mode 100644 code/controllers/subsystems/holomaps_vr.dm diff --git a/code/__defines/subsystems.dm b/code/__defines/subsystems.dm index 5b459f73ffe..8460f14fceb 100644 --- a/code/__defines/subsystems.dm +++ b/code/__defines/subsystems.dm @@ -30,6 +30,7 @@ var/global/list/runlevel_flags = list(RUNLEVEL_LOBBY, RUNLEVEL_SETUP, RUNLEVEL_G #define INIT_ORDER_SHUTTLES 3 #define INIT_ORDER_LIGHTING 0 #define INIT_ORDER_AIR -1 +#define INIT_ORDER_HOLOMAPS -5 #define INIT_ORDER_OVERLAY -6 #define INIT_ORDER_XENOARCH -20 diff --git a/code/controllers/subsystems/holomaps_vr.dm b/code/controllers/subsystems/holomaps_vr.dm new file mode 100644 index 00000000000..5fcca274800 --- /dev/null +++ b/code/controllers/subsystems/holomaps_vr.dm @@ -0,0 +1,24 @@ +// +// Holo-Minimaps Generation Subsystem handles initialization of the holo minimaps. +// Look in code/modules/holomap/generate_holomap.dm to find generateHoloMinimaps() +// +SUBSYSTEM_DEF(holomaps) + name = "HoloMiniMaps" + init_order = INIT_ORDER_HOLOMAPS + flags = SS_NO_FIRE + var/static/holomaps_initialized = FALSE + var/static/list/holoMiniMaps = list() + var/static/list/extraMiniMaps = list() + var/static/list/station_holomaps = list() + +/datum/controller/subsystem/holomaps/Recover() + flags |= SS_NO_INIT // Make extra sure we don't initialize twice. + +/datum/controller/subsystem/holomaps/Initialize(timeofday) + generateHoloMinimaps() + . = ..() + +/datum/controller/subsystem/holomaps/stat_entry(msg) + if (!Debug2) + return // Only show up in stat panel if debugging is enabled. + . = ..() diff --git a/code/modules/holomap/generate_holomap.dm b/code/modules/holomap/generate_holomap.dm index 3db49243ab4..e4917e0ba0b 100644 --- a/code/modules/holomap/generate_holomap.dm +++ b/code/modules/holomap/generate_holomap.dm @@ -23,23 +23,13 @@ /*|| istype(tile, /turf/simulated/shuttle/floor)*/ \ || (locate(/obj/structure/catwalk) in tile)) - -// WARNING - TOTAL HACK - HOOKING INIT -/datum/controller/game_controller/setup_objects() - ..() - generateHoloMinimaps() - /// Generates all the holo minimaps, initializing it all nicely, probably. -// TODO - This should be a subsystem ~Leshana -var/global/holomaps_initialized = FALSE -var/global/list/holoMiniMaps = list() -var/global/list/extraMiniMaps = list() -/proc/generateHoloMinimaps() +/datum/controller/subsystem/holomaps/proc/generateHoloMinimaps() var/start_time = world.timeofday // Build the base map for each z level for (var/z = 1 to world.maxz) - global.holoMiniMaps |= z // hack, todo fix - global.holoMiniMaps[z] = generateHoloMinimap(z) + holoMiniMaps |= z // hack, todo fix + holoMiniMaps[z] = generateHoloMinimap(z) // Generate the area overlays, small maps, etc for the station levels. for (var/z in using_map.station_levels) @@ -49,7 +39,7 @@ var/global/list/extraMiniMaps = list() for(var/smoosh_list in using_map.holomap_smoosh) smooshTetherHolomaps(smoosh_list) - global.holomaps_initialized = TRUE + holomaps_initialized = TRUE admin_notice("Holomaps initialized in [round(0.1*(world.timeofday-start_time),0.1)] seconds.", R_DEBUG) // TODO - Check - They had a delayed init perhaps? @@ -57,7 +47,7 @@ var/global/list/extraMiniMaps = list() S.setup_holomap() // Generates the "base" holomap for one z-level, showing only the physical structure of walls and paths. -/proc/generateHoloMinimap(var/zLevel = 1) +/datum/controller/subsystem/holomaps/proc/generateHoloMinimap(var/zLevel = 1) // Save these values now to avoid a bazillion array lookups var/offset_x = HOLOMAP_PIXEL_OFFSET_X(zLevel) var/offset_y = HOLOMAP_PIXEL_OFFSET_Y(zLevel) @@ -87,7 +77,7 @@ var/global/list/extraMiniMaps = list() // This seems to do the drawing thing, but draws only the areas, having nothing to do with the tiles. // Leshana: I'm guessing this map will get overlayed on top of the base map at runtime? We'll see. // Wait, seems we actually blend the area map on top of it right now! Huh. -/proc/generateStationMinimap(var/zLevel) +/datum/controller/subsystem/holomaps/proc/generateStationMinimap(var/zLevel) // Save these values now to avoid a bazillion array lookups var/offset_x = HOLOMAP_PIXEL_OFFSET_X(zLevel) var/offset_y = HOLOMAP_PIXEL_OFFSET_Y(zLevel) @@ -134,7 +124,7 @@ var/global/list/extraMiniMaps = list() extraMiniMaps["[HOLOMAP_EXTRA_STATIONMAPSMALL]_[zLevel]"] = actual_small_map // For tiny multi-z maps like the tether, we want to smoosh em together into a nice big one! -/proc/smooshTetherHolomaps(var/list/zlevels) +/datum/controller/subsystem/holomaps/proc/smooshTetherHolomaps(var/list/zlevels) var/icon/big_map = icon(HOLOMAP_ICON, "stationmap") var/icon/small_map = icon(HOLOMAP_ICON, "blank") // For each zlevel in turn, overlay them on top of each other diff --git a/code/modules/holomap/holomap_datum.dm b/code/modules/holomap/holomap_datum.dm index 67a1ee0bc90..b66c1020b02 100644 --- a/code/modules/holomap/holomap_datum.dm +++ b/code/modules/holomap/holomap_datum.dm @@ -6,7 +6,7 @@ /datum/station_holomap/proc/initialize_holomap(var/turf/T, var/isAI = null, var/mob/user = null, var/reinit = FALSE) if(!station_map || reinit) - station_map = image(extraMiniMaps["[HOLOMAP_EXTRA_STATIONMAP]_[T.z]"]) + station_map = image(SSholomaps.extraMiniMaps["[HOLOMAP_EXTRA_STATIONMAP]_[T.z]"]) if(!cursor || reinit) cursor = image('icons/holomap_markers_vr.dmi', "you") if(!legend || reinit) @@ -33,7 +33,7 @@ // TODO - Strategic Holomap support // /datum/station_holomap/strategic/initialize_holomap(var/turf/T, var/isAI=null, var/mob/user=null) // ..() -// station_map = image(extraMiniMaps[HOLOMAP_EXTRA_STATIONMAP_STRATEGIC]) +// station_map = image(SSholomaps.extraMiniMaps[HOLOMAP_EXTRA_STATIONMAP_STRATEGIC]) // legend = image('icons/effects/64x64.dmi', "strategic") // legend.pixel_x = 3*WORLD_ICON_SIZE // legend.pixel_y = 3*WORLD_ICON_SIZE diff --git a/code/modules/holomap/station_holomap.dm b/code/modules/holomap/station_holomap.dm index 29dd5b5c6db..eb2ea9d53ff 100644 --- a/code/modules/holomap/station_holomap.dm +++ b/code/modules/holomap/station_holomap.dm @@ -1,5 +1,6 @@ -var/global/list/station_holomaps = list() - +// +// Wall mounted holomap of the station +// /obj/machinery/station_map name = "station holomap" desc = "A virtual map of the surrounding station." @@ -10,7 +11,6 @@ var/global/list/station_holomaps = list() use_power = 1 idle_power_usage = 10 active_power_usage = 500 - //auto_init = 0 // We handle our own special initialization needs. // TODO - Make this not ~Leshana circuit = /obj/item/weapon/circuitboard/station_map // TODO - Port use_auto_lights from /vg - for now declare here @@ -34,17 +34,17 @@ var/global/list/station_holomaps = list() ..() holomap_datum = new() original_zLevel = loc.z - station_holomaps += src + SSholomaps.station_holomaps += src flags |= ON_BORDER // Why? It doesn't help if its not density /obj/machinery/station_map/initialize() . = ..() - if(ticker && holomaps_initialized) + if(SSholomaps.holomaps_initialized) spawn(1) // Tragically we need to spawn this in order to give the frame construcing us time to set pixel_x/y setup_holomap() /obj/machinery/station_map/Destroy() - station_holomaps -= src + SSholomaps.station_holomaps -= src stopWatching() holomap_datum = null . = ..() @@ -54,7 +54,7 @@ var/global/list/station_holomaps = list() bogus = FALSE var/turf/T = get_turf(src) original_zLevel = T.z - if(!("[HOLOMAP_EXTRA_STATIONMAP]_[original_zLevel]" in extraMiniMaps)) + if(!("[HOLOMAP_EXTRA_STATIONMAP]_[original_zLevel]" in SSholomaps.extraMiniMaps)) bogus = TRUE holomap_datum.initialize_holomap_bogus() update_icon() @@ -62,7 +62,7 @@ var/global/list/station_holomaps = list() holomap_datum.initialize_holomap(T, reinit = TRUE) - small_station_map = image(extraMiniMaps["[HOLOMAP_EXTRA_STATIONMAPSMALL]_[original_zLevel]"], dir = dir) + small_station_map = image(SSholomaps.extraMiniMaps["[HOLOMAP_EXTRA_STATIONMAPSMALL]_[original_zLevel]"], dir = dir) // small_station_map.plane = LIGHTING_PLANE // Not until we do planes ~Leshana // small_station_map.layer = LIGHTING_LAYER+1 // Weird things will happen! @@ -182,7 +182,7 @@ var/global/list/station_holomaps = list() if(bogus) holomap_datum.initialize_holomap_bogus() else - small_station_map.icon = extraMiniMaps["[HOLOMAP_EXTRA_STATIONMAPSMALL]_[original_zLevel]"] + small_station_map.icon = SSholomaps.extraMiniMaps["[HOLOMAP_EXTRA_STATIONMAPSMALL]_[original_zLevel]"] overlays |= small_station_map holomap_datum.initialize_holomap(get_turf(src)) diff --git a/vorestation.dme b/vorestation.dme index 66d3778a765..36ec9fb12b8 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -207,6 +207,7 @@ #include "code\controllers\subsystems\atoms.dm" #include "code\controllers\subsystems\bellies_vr.dm" #include "code\controllers\subsystems\garbage.dm" +#include "code\controllers\subsystems\holomaps_vr.dm" #include "code\controllers\subsystems\lighting.dm" #include "code\controllers\subsystems\machines.dm" #include "code\controllers\subsystems\mapping_vr.dm"