From 313f153e751c6efa546f0432f8e72c67bb2a506b Mon Sep 17 00:00:00 2001 From: Dimach Date: Sat, 2 Dec 2023 16:43:43 +0200 Subject: [PATCH] bugfix: fix runtimes in handcufs and holodec area copy (#3980) --- code/__HELPERS/unsorted.dm | 69 +++++-------------- .../machinery/computer/HolodeckControl.dm | 13 ++-- code/game/objects/items/weapons/handcuffs.dm | 6 +- 3 files changed, 27 insertions(+), 61 deletions(-) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index cc1ba9ff393..5eb1cd82231 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -804,7 +804,7 @@ Returns 1 if the chain up to the area contains the given typepath -/proc/DuplicateObject(obj/original, var/perfectcopy = 0 , var/sameloc = 0, var/atom/newloc = null) +/proc/DuplicateObject(obj/original, perfectcopy = FALSE , sameloc = FALSE, atom/newloc = null) if(!original) return null @@ -816,8 +816,8 @@ Returns 1 if the chain up to the area contains the given typepath O=new original.type(newloc) if(perfectcopy) - if((O) && (original)) - var/static/list/forbidden_vars = list("type","loc","locs","vars", "parent","parent_type", "verbs","ckey","key","power_supply","contents","reagents","stat","x","y","z","group") + if(O) + var/static/list/forbidden_vars = list("type","loc","locs","vars", "parent","parent_type", "verbs","ckey","key","power_supply","contents","reagents","stat","x","y","z","group", "comp_lookup", "datum_components") for(var/V in original.vars - forbidden_vars) if(istype(original.vars[V],/list)) @@ -831,14 +831,15 @@ Returns 1 if the chain up to the area contains the given typepath O.update_icon() return O -/area/proc/copy_contents_to(var/area/A , var/platingRequired = 0 ) +/area/proc/copy_contents_to(area/A , platingRequired = FALSE, perfect_copy = TRUE) //Takes: Area. Optional: If it should copy to areas that don't have plating //Returns: Nothing. //Notes: Attempts to move the contents of one area to another area. // Movement based on lower left corner. Tiles that do not fit // into the new area will not be moved. - if(!A || !src) return 0 + if(!A || !src) + return FALSE var/list/turfs_src = get_area_turfs(src.type) var/list/turfs_trg = get_area_turfs(A.type) @@ -846,14 +847,18 @@ Returns 1 if the chain up to the area contains the given typepath var/src_min_x = 0 var/src_min_y = 0 for(var/turf/T in turfs_src) - if(T.x < src_min_x || !src_min_x) src_min_x = T.x - if(T.y < src_min_y || !src_min_y) src_min_y = T.y + if(T.x < src_min_x || !src_min_x) + src_min_x = T.x + if(T.y < src_min_y || !src_min_y) + src_min_y = T.y var/trg_min_x = 0 var/trg_min_y = 0 for(var/turf/T in turfs_trg) - if(T.x < trg_min_x || !trg_min_x) trg_min_x = T.x - if(T.y < trg_min_y || !trg_min_y) trg_min_y = T.y + if(T.x < trg_min_x || !trg_min_x) + trg_min_x = T.x + if(T.y < trg_min_y || !trg_min_y) + trg_min_y = T.y var/list/refined_src = new/list() for(var/turf/T in turfs_src) @@ -882,68 +887,30 @@ Returns 1 if the chain up to the area contains the given typepath for(var/turf/B in refined_trg) var/datum/coords/C_trg = refined_trg[B] if(C_src.x_pos == C_trg.x_pos && C_src.y_pos == C_trg.y_pos) - var/old_dir1 = T.dir var/old_icon_state1 = T.icon_state var/old_icon1 = T.icon if(platingRequired) - if(istype(B, /turf/space)) + if(isspaceturf(B)) continue moving - var/turf/X = new T.type(B) X.dir = old_dir1 X.icon_state = old_icon_state1 X.icon = old_icon1 //Shuttle floors are in shuttle.dmi while the defaults are floors.dmi - - var/list/objs = new/list() - var/list/newobjs = new/list() - var/list/mobs = new/list() - var/list/newmobs = new/list() - for(var/obj/O in T) - - if(!istype(O,/obj)) - continue - - objs += O - - - for(var/obj/O in objs) - newobjs += DuplicateObject(O , 1) - - - for(var/obj/O in newobjs) - O.loc = X + copiedobjs += DuplicateObject(O, perfect_copy, newloc = X) for(var/mob/M in T) - if(!M.move_on_shuttle) continue - mobs += M - - for(var/mob/M in mobs) - newmobs += DuplicateObject(M , 1) - - for(var/mob/M in newmobs) - M.loc = X - - copiedobjs += newobjs - copiedobjs += newmobs - - + copiedobjs += DuplicateObject(M, perfect_copy, newloc = X) for(var/V in T.vars) - if(!(V in list("type","loc","locs","vars", "parent", "parent_type","verbs","ckey","key","x","y","z","contents", "luminosity", "group"))) + if(!(V in list("type","loc","locs","vars", "parent", "parent_type","verbs","ckey","key","x","y","z","destination_z", "destination_x", "destination_y","contents", "luminosity", "group"))) X.vars[V] = T.vars[V] -// var/area/AR = X.loc - -// if(AR.lighting_use_dynamic) -// X.opacity = !X.opacity -// X.sd_set_opacity(!X.opacity) //TODO: rewrite this code so it's not messed by lighting ~Carn - toupdate += X refined_src -= T diff --git a/code/game/machinery/computer/HolodeckControl.dm b/code/game/machinery/computer/HolodeckControl.dm index 8d93b2ccb1f..eec74188a4a 100644 --- a/code/game/machinery/computer/HolodeckControl.dm +++ b/code/game/machinery/computer/HolodeckControl.dm @@ -237,15 +237,14 @@ visible_message("The [oldobj.name] fades away!") qdel(obj) -/obj/machinery/computer/HolodeckControl/proc/checkInteg(var/area/A) +/obj/machinery/computer/HolodeckControl/proc/checkInteg(area/A) for(var/turf/T in A) if(istype(T, /turf/space)) return 0 return 1 -/obj/machinery/computer/HolodeckControl/proc/togglePower(var/toggleOn = 0) - +/obj/machinery/computer/HolodeckControl/proc/togglePower(toggleOn = 0) if(toggleOn) var/area/targetsource = locate(/area/holodeck/source_emptycourt) holographic_items = targetsource.copy_contents_to(linkedholodeck) @@ -265,11 +264,11 @@ for(var/item in holographic_items) derez(item) var/area/targetsource = locate(/area/holodeck/source_plating) - targetsource.copy_contents_to(linkedholodeck , 1) + targetsource.copy_contents_to(linkedholodeck, TRUE) active = 0 -/obj/machinery/computer/HolodeckControl/proc/loadProgram(var/area/A) +/obj/machinery/computer/HolodeckControl/proc/loadProgram(area/A) if(world.time < (last_change + 25)) if(world.time < (last_change + 15))//To prevent super-spam clicking, reduced process size and annoyance -Sieve @@ -291,7 +290,7 @@ for(var/mob/living/simple_animal/hostile/carp/holocarp/C in linkedholodeck) qdel(C) - holographic_items = A.copy_contents_to(linkedholodeck , 1) + holographic_items = A.copy_contents_to(linkedholodeck, TRUE) if(emagged) for(var/obj/item/holo/H in linkedholodeck) @@ -320,7 +319,7 @@ loadProgram(target) var/area/targetsource = locate(/area/holodeck/source_plating) - targetsource.copy_contents_to(linkedholodeck , 1) + targetsource.copy_contents_to(linkedholodeck, TRUE) active = 0 // Holographic Items! diff --git a/code/game/objects/items/weapons/handcuffs.dm b/code/game/objects/items/weapons/handcuffs.dm index a2214bbe69d..33931942bfc 100644 --- a/code/game/objects/items/weapons/handcuffs.dm +++ b/code/game/objects/items/weapons/handcuffs.dm @@ -21,13 +21,13 @@ /obj/item/restraints/handcuffs/attack(mob/living/carbon/C, mob/living/user) - if(C.handcuffed) + if(!istype(C)) // Shouldn't be able to cuff anything but carbons. return - if(!user.IsAdvancedToolUser()) + if(C.handcuffed) return - if(!istype(C)) // Shouldn't be able to cuff anything but carbons. + if(!user.IsAdvancedToolUser()) return if((flags & NODROP) && !isrobot(user))