diff --git a/code/__DEFINES/subsystems.dm b/code/__DEFINES/subsystems.dm index 5aa0301bf6..3979274951 100644 --- a/code/__DEFINES/subsystems.dm +++ b/code/__DEFINES/subsystems.dm @@ -62,9 +62,10 @@ #define INIT_ORDER_JOBS 65 #define INIT_ORDER_QUIRKS 60 #define INIT_ORDER_TICKER 55 -#define INIT_ORDER_INSTRUMENTS 53 +#define INIT_ORDER_INSTRUMENTS 53 #define INIT_ORDER_MAPPING 50 #define INIT_ORDER_NETWORKS 45 +#define INIT_ORDER_HOLODECK 35 #define INIT_ORDER_ATOMS 30 #define INIT_ORDER_LANGUAGE 25 #define INIT_ORDER_MACHINES 20 diff --git a/code/__HELPERS/global_lists.dm b/code/__HELPERS/global_lists.dm index 0c45a746d8..38e25b04c5 100644 --- a/code/__HELPERS/global_lists.dm +++ b/code/__HELPERS/global_lists.dm @@ -89,14 +89,6 @@ INVOKE_ASYNC(GLOBAL_PROC, /proc/init_ref_coin_values) //so the current procedure doesn't sleep because of UNTIL() - for(var/path in subtypesof(/area/holodeck)) - var/area/holodeck/A = path - var/list/compatibles = initial(A.compatible_holodeck_comps) - if(!compatibles || initial(A.abstract_type) == path) - continue - for(var/comp in compatibles) - LAZYADD(GLOB.holodeck_areas_prototypes[comp], A) - //creates every subtype of prototype (excluding prototype) and adds it to list L. //if no list/L is provided, one is created. /proc/init_subtypes(prototype, list/L) diff --git a/code/_globalvars/lists/mapping.dm b/code/_globalvars/lists/mapping.dm index bcf35859c3..fb8863ebe7 100644 --- a/code/_globalvars/lists/mapping.dm +++ b/code/_globalvars/lists/mapping.dm @@ -50,5 +50,3 @@ GLOBAL_LIST_EMPTY_TYPED(areas_by_type, /area) GLOBAL_LIST_EMPTY(all_abstract_markers) GLOBAL_LIST_EMPTY(stationroom_landmarks) //List of all spawns for stationrooms - -GLOBAL_LIST_EMPTY(holodeck_areas_prototypes) //List of holodeck area prototypes per holodeck computer type \ No newline at end of file diff --git a/code/controllers/subsystem/holodeck.dm b/code/controllers/subsystem/holodeck.dm new file mode 100644 index 0000000000..967dc9d3db --- /dev/null +++ b/code/controllers/subsystem/holodeck.dm @@ -0,0 +1,55 @@ +SUBSYSTEM_DEF(holodeck) + name = "Holodeck" + init_order = INIT_ORDER_HOLODECK + flags = SS_NO_FIRE + var/list/program_cache = list() //list of safe holodeck programs. + var/list/emag_program_cache = list() //like above, but dangerous. + var/list/offline_programs = list() //default when offline. + var/list/target_holodeck_area = list() + +/datum/controller/subsystem/holodeck/Initialize() + . = ..() + //generates the list of available holodeck programs. + for(var/path in subtypesof(/datum/holodeck_cache)) + new path + for(var/path in typesof(/obj/machinery/computer/holodeck)) //The istances will be handled by SSatoms. + var/obj/machinery/computer/holodeck/H = path + offline_programs[path] = pop(get_areas(initial(H.offline_program)), FALSE) + target_holodeck_area[path] = pop(get_areas(initial(H.holodeck_type)), FALSE) + + /* + * The sole scope of this datum is to generate lists of holodeck programs caches per holodeck computer type. + */ + +/datum/holodeck_cache + var/area/holodeck/master_type //the /area/holodeck typepath we'll be using for typesof loop. + var/skip_types //Areas that won't be added to the global list category. + var/list/compatible_holodeck_comps //list of typepaths of holodeck computers that can access this category. + +/datum/holodeck_cache/New() + if(!master_type) + return + var/list/to_add = typesof(master_type) - skip_types + var/list/programs + var/list/emag_programs + for(var/typekey in to_add) + var/area/holodeck/A = GLOB.areas_by_type[typekey] + if(!A || !A.contents.len) + continue + var/list/info_this = list() + info_this["name"] = A.name + info_this["type"] = A.type + if(A.restricted) + LAZYADD(emag_programs, list(info_this)) + else + LAZYADD(programs, list(info_this)) + for(var/comp in compatible_holodeck_comps) + if(programs) + LAZYADD(SSholodeck.program_cache[comp], programs) + if(emag_programs) + LAZYADD(SSholodeck.emag_program_cache[comp], emag_programs) + +/datum/holodeck_cache/standard + master_type = /area/holodeck/rec_center + skip_types = /area/holodeck/rec_center + compatible_holodeck_comps = list(/obj/machinery/computer/holodeck) diff --git a/code/game/area/areas/holodeck.dm b/code/game/area/areas/holodeck.dm index 75ed2b656c..d32091f98b 100644 --- a/code/game/area/areas/holodeck.dm +++ b/code/game/area/areas/holodeck.dm @@ -6,8 +6,6 @@ hidden = TRUE var/obj/machinery/computer/holodeck/linked - var/list/compatible_holodeck_comps - var/abstract_type = /area/holodeck var/restricted = 0 // if true, program goes on emag list /* @@ -55,8 +53,6 @@ */ /area/holodeck/rec_center name = "\improper Recreational Holodeck" - compatible_holodeck_comps = list(/obj/machinery/computer/holodeck) - abstract_type = /area/holodeck/rec_center /area/holodeck/rec_center/offline name = "Holodeck - Offline" diff --git a/code/modules/holodeck/area_copy.dm b/code/modules/holodeck/area_copy.dm index 316bdb8289..cb9965d34a 100644 --- a/code/modules/holodeck/area_copy.dm +++ b/code/modules/holodeck/area_copy.dm @@ -70,7 +70,7 @@ GLOBAL_LIST_INIT(duplicate_forbidden_vars_by_type, typecacheof_assoc_list(list( for (var/turf/T in turfs_src) src_min_x = min(src_min_x,T.x) src_min_y = min(src_min_y,T.y) - src_max_x = max(src_max_x,T.y) + src_max_x = max(src_max_x,T.x) src_max_y = max(src_max_y,T.y) for (var/turf/T in turfs_src) refined_src[T] = "[T.x - src_min_x].[T.y - src_min_y]" @@ -84,7 +84,7 @@ GLOBAL_LIST_INIT(duplicate_forbidden_vars_by_type, typecacheof_assoc_list(list( for (var/turf/T in turfs_trg) trg_min_x = min(trg_min_x,T.x) trg_min_y = min(trg_min_y,T.y) - trg_max_x = max(trg_max_x,T.y) + trg_max_x = max(trg_max_x,T.x) trg_max_y = max(trg_max_y,T.y) var/diff_x = round(((src_max_x - src_min_x) - (trg_max_x - trg_min_x))/2) diff --git a/code/modules/holodeck/computer.dm b/code/modules/holodeck/computer.dm index 3c87082393..65c69b995f 100644 --- a/code/modules/holodeck/computer.dm +++ b/code/modules/holodeck/computer.dm @@ -31,12 +31,12 @@ var/area/holodeck/last_program var/area/offline_program = /area/holodeck/rec_center/offline - var/list/program_cache - var/list/emag_programs - // Splitting this up allows two holodecks of the same size // to use the same source patterns. Y'know, if you want to. - var/holodeck_type = /area/holodeck/rec_center // locate(this) to get the target holodeck + var/holodeck_type = /area/holodeck/rec_center + + var/list/program_cache + var/list/emag_programs var/active = FALSE var/damaged = FALSE @@ -49,16 +49,18 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/computer/holodeck/LateInitialize() - if(ispath(holodeck_type, /area)) - linked = pop(get_areas(holodeck_type, FALSE)) - if(ispath(offline_program, /area)) - offline_program = pop(get_areas(offline_program), FALSE) - // the following is necessary for power reasons + linked = SSholodeck.target_holodeck_area[type] + offline_program = SSholodeck.offline_programs[type] if(!linked || !offline_program) log_world("No matching holodeck area found") qdel(src) return - var/area/AS = get_area(src) + + program_cache = SSholodeck.program_cache[type] + emag_programs = SSholodeck.emag_program_cache[type] + + // the following is necessary for power reasons + var/area/AS = get_base_area(src) if(istype(AS, /area/holodeck)) log_mapping("Holodeck computer cannot be in a holodeck, This would cause circular power dependency.") qdel(src) @@ -66,7 +68,6 @@ else linked.linked = src - generate_program_list() load_program(offline_program, FALSE, FALSE) /obj/machinery/computer/holodeck/Destroy() @@ -181,19 +182,6 @@ emergency_shutdown() return ..() -/obj/machinery/computer/holodeck/proc/generate_program_list() - for(var/typekey in GLOB.holodeck_areas_prototypes[type]) - var/area/holodeck/A = GLOB.areas_by_type[typekey] - if(!A || !A.contents.len) - continue - var/list/info_this = list() - info_this["name"] = A.name - info_this["type"] = A.type - if(A.restricted) - LAZYADD(emag_programs, list(info_this)) - else - LAZYADD(program_cache, list(info_this)) - /obj/machinery/computer/holodeck/proc/toggle_power(toggleOn = FALSE) if(active == toggleOn) return diff --git a/tgstation.dme b/tgstation.dme index 26bb4e2e5a..818177a465 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -264,6 +264,7 @@ #include "code\controllers\subsystem\fail2topic.dm" #include "code\controllers\subsystem\fire_burning.dm" #include "code\controllers\subsystem\garbage.dm" +#include "code\controllers\subsystem\holodeck.dm" #include "code\controllers\subsystem\icon_smooth.dm" #include "code\controllers\subsystem\idlenpcpool.dm" #include "code\controllers\subsystem\input.dm"