diff --git a/code/modules/holodeck/area_copy.dm b/code/modules/holodeck/area_copy.dm index b34c19b4e21..8b468020ed0 100644 --- a/code/modules/holodeck/area_copy.dm +++ b/code/modules/holodeck/area_copy.dm @@ -1,4 +1,7 @@ -/proc/DuplicateObject(var/atom/original, var/perfectcopy = TRUE, var/sameloc = FALSE, var/atom/newloc = null, var/nerf = FALSE, var/holoitem=FALSE) +//Vars that will not be copied when using /DuplicateObject +GLOBAL_LIST_INIT(duplicate_forbidden_vars,list("area","type","loc","locs","vars", "parent","parent_type", "verbs","ckey","key","power_supply","contents","reagents","stat","x","y","z","group")) + +/proc/DuplicateObject(atom/original, perfectcopy = TRUE, sameloc = FALSE, atom/newloc = null, nerf = FALSE, holoitem=FALSE) if(!original) return null var/atom/O @@ -9,9 +12,7 @@ O = new original.type(newloc) if(perfectcopy && O && original) - var/global/list/forbidden_vars = list("type","loc","locs","vars", "parent","parent_type", "verbs","ckey","key","power_supply","contents","reagents","stat","x","y","z","group") - - for(var/V in original.vars - forbidden_vars) + for(var/V in original.vars - GLOB.duplicate_forbidden_vars) if(istype(original.vars[V],/list)) var/list/L = original.vars[V] O.vars[V] = L.Copy() @@ -90,23 +91,24 @@ var/old_icon_state1 = T.icon_state var/old_icon1 = T.icon - B.ChangeTurf(T.type) + B = B.ChangeTurf(T.type) B.setDir(old_dir1) B.icon = old_icon1 B.icon_state = old_icon_state1 for(var/obj/O in T) var/obj/O2 = DuplicateObject(O , perfectcopy=TRUE, newloc = B, nerf=nerf_weapons, holoitem=TRUE) - if(!O2) continue + if(!O2) + continue copiedobjs += O2.GetAllContents() for(var/mob/M in T) - if(istype(M, /mob/camera)) continue // If we need to check for more mobs, I'll add a variable + if(istype(M, /mob/camera)) + continue // If we need to check for more mobs, I'll add a variable var/mob/SM = DuplicateObject(M , perfectcopy=TRUE, newloc = B, holoitem=TRUE) copiedobjs += SM.GetAllContents() - var/global/list/forbidden_vars = list("type","stat","loc","locs","vars", "parent", "parent_type","verbs","ckey","key","x","y","z","contents", "light_range", "light_power", "light_color", "light", "light_sources") - for(var/V in T.vars - forbidden_vars) + for(var/V in T.vars - GLOB.duplicate_forbidden_vars) if(V == "air") var/turf/open/O1 = B var/turf/open/O2 = T diff --git a/code/modules/holodeck/computer.dm b/code/modules/holodeck/computer.dm index c5d7b56ca7b..18be292e97f 100644 --- a/code/modules/holodeck/computer.dm +++ b/code/modules/holodeck/computer.dm @@ -45,34 +45,42 @@ var/list/effects = list() var/last_change = 0 -/obj/machinery/computer/holodeck/New() - - if(ispath(holodeck_type,/area)) - linked = locate(holodeck_type) - if(ispath(offline_program,/area)) - offline_program = locate(offline_program) - // the following is necessary for power reasons - var/area/AS = get_area(src) - if(istype(AS,/area/holodeck)) - log_world("### MAPPING ERROR") - log_world("Holodeck computer cannot be in a holodeck.") - log_world("This would cause circular power dependency.") - qdel(src) // todo handle constructed computers - return //l-lewd... - else - linked.linked = src // todo detect multiple/constructed computers - ..() + /obj/machinery/computer/holodeck/Initialize(mapload) . = mapload //late-initialize, area_copy need turfs to have air if(!mapload) ..() + + if(ispath(holodeck_type,/area)) + var/list/possible = get_areas(holodeck_type,subtypes = FALSE) + linked = pop(possible) + if(ispath(offline_program,/area)) + var/list/possible = get_areas(offline_program,subtypes = FALSE) + offline_program = pop(possible) + // the following is necessary for power reasons + if(!linked || !offline_program) + log_world("No matching holodeck area found") + qdel(src) + return + var/area/AS = get_area(src) + if(istype(AS,/area/holodeck)) + log_world("### MAPPING ERROR") + log_world("Holodeck computer cannot be in a holodeck.") + log_world("This would cause circular power dependency.") + qdel(src) // todo handle constructed computers + return //l-lewd... + else + linked.linked = src // todo detect multiple/constructed computers + program_cache = list() emag_programs = list() for(var/typekey in subtypesof(program_type)) var/area/holodeck/A = locate(typekey) - if(!A || A == offline_program) continue - if(A.contents.len == 0) continue // not loaded + if(!A || A == offline_program) + continue + if(A.contents.len == 0) + continue // not loaded if(A.restricted) emag_programs += A else @@ -191,8 +199,9 @@ nerf(!emagged) /obj/machinery/computer/holodeck/Destroy() - emergency_shutdown() - linked.linked = null + if(linked) + emergency_shutdown() + linked.linked = null return ..() /obj/machinery/computer/holodeck/emp_act(severity) diff --git a/code/modules/mapping/reader.dm b/code/modules/mapping/reader.dm index 25a7e6366b2..4073a97e9ec 100644 --- a/code/modules/mapping/reader.dm +++ b/code/modules/mapping/reader.dm @@ -276,8 +276,13 @@ GLOBAL_DATUM_INIT(_preloader, /dmm_suite/preloader, new) if(members[index] != /area/template_noop) var/atom/instance GLOB._preloader.setup(members_attributes[index])//preloader for assigning set variables on atom creation - - instance = locate(members[index]) + var/atype = members[index] + for(var/area/A in world) + if(A.type == atype) + instance = A + break + if(!instance) + instance = new atype(null) if(crds) instance.contents.Add(crds)