Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: fix runtimes in handcufs and holodec area copy #3980

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 18 additions & 51 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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))
Expand All @@ -831,29 +831,34 @@ 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)

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)
Expand Down Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions code/game/machinery/computer/HolodeckControl.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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!
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/items/weapons/handcuffs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Loading