Merge pull request #11903 from Ghommie/Ghommie-cit687
fix for my relatively minuscule backend refactor for holodeck.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
56
code/controllers/subsystem/holodeck.dm
Normal file
56
code/controllers/subsystem/holodeck.dm
Normal file
@@ -0,0 +1,56 @@
|
||||
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()
|
||||
var/list/rejected_areas = 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 || !compatible_holodeck_comps)
|
||||
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)
|
||||
LAZYOR(SSholodeck.rejected_areas[typekey], compatible_holodeck_comps)
|
||||
continue
|
||||
var/list/info_this = list("name" = A.name, "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)
|
||||
@@ -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
|
||||
|
||||
/*
|
||||
@@ -15,6 +13,16 @@
|
||||
Asserts are to avoid the inevitable infinite loops
|
||||
*/
|
||||
|
||||
/area/holodeck/Initialize()
|
||||
. = ..()
|
||||
var/list/update_holodeck_cache = SSholodeck?.rejected_areas[type]
|
||||
if(update_holodeck_cache)
|
||||
var/list/info_this = list("name" = name, "type" = type)
|
||||
var/list/target = restricted ? SSholodeck.emag_program_cache : SSholodeck.program_cache
|
||||
for(var/A in update_holodeck_cache)
|
||||
LAZYADD(target[A], info_this)
|
||||
SSholodeck.rejected_areas -= type
|
||||
|
||||
/area/holodeck/powered(var/chan)
|
||||
if(!requires_power)
|
||||
return 1
|
||||
@@ -55,8 +63,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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -265,6 +265,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"
|
||||
|
||||
Reference in New Issue
Block a user