Adds DropLocation(). To generally be preferred to get_turf() (#29814)

Fixes #29802

Unlike get_turf()this will sensibly pick if loc can be safely used
This commit is contained in:
Jordan Brown
2017-08-18 00:44:20 -04:00
committed by oranges
parent 076c533285
commit 728aefbd70
11 changed files with 36 additions and 21 deletions

View File

@@ -477,3 +477,9 @@ GLOBAL_LIST_EMPTY(teleportlocs)
valid_territory = FALSE
blob_allowed = FALSE
addSorted()
/area/AllowDrop()
CRASH("Bad op: area/AllowDrop() called")
/area/drop_location()
CRASH("Bad op: area/drop_location() called")

View File

@@ -211,8 +211,8 @@
return TRUE
return container_type & DRAWABLE_1
/atom/proc/allow_drop()
return 1
/atom/proc/AllowDrop()
return FALSE
/atom/proc/CheckExit()
return 1
@@ -614,5 +614,11 @@ GLOBAL_LIST_EMPTY(blood_splatter_icons)
.["Trigger EM pulse"] = "?_src_=vars;emp=\ref[src]"
.["Trigger explosion"] = "?_src_=vars;explode=\ref[src]"
/atom/proc/drop_location()
var/atom/L = loc
if(!L)
return null
return L.AllowDrop() ? L : get_turf(L)
/atom/Entered(atom/movable/AM, atom/oldLoc)
SendSignal(COMSIG_ATOM_ENTERED, AM, oldLoc)

View File

@@ -473,9 +473,6 @@ Class Procs:
/obj/machinery/proc/on_deconstruction()
return
/obj/machinery/allow_drop()
return 0
// Hook for html_interface module to prevent updates to clients who don't have this as their active machine.
/obj/machinery/proc/hiIsValidClient(datum/html_interface_client/hclient, datum/html_interface/hi)
if (hclient.client.mob && (hclient.client.mob.stat == 0 || IsAdminGhost(hclient.client.mob)))

View File

@@ -42,9 +42,6 @@
var/inject_amount = 10
salvageable = 0
/obj/item/mecha_parts/mecha_equipment/medical/sleeper/allow_drop()
return 0
/obj/item/mecha_parts/mecha_equipment/medical/sleeper/Destroy()
for(var/atom/movable/AM in src)
AM.forceMove(get_turf(src))

View File

@@ -1047,9 +1047,6 @@ GLOBAL_VAR_INIT(year_integer, text2num(year)) // = 2013???
return 1
return 0
/obj/mecha/allow_drop()
return 0
/obj/mecha/update_remote_sight(mob/living/user)
if(occupant_sight_flags)
if(user == occupant)

View File

@@ -416,6 +416,8 @@
handle_item_insertion(W, 0 , user)
/obj/item/weapon/storage/AllowDrop()
return TRUE
/obj/item/storage/attack_hand(mob/user)
if(user.s_active == src && loc == user) //if you're already looking inside the storage item

View File

@@ -110,7 +110,12 @@
return 1
/obj/structure/closet/proc/dump_contents()
var/turf/T = get_turf(src)
var/atom/L = loc
if(!L)
for(var/I in src)
qdel(I)
return
var/turf/T = L.drop_location()
for(var/atom/movable/AM in src)
AM.forceMove(T)
if(throwing) // you keep some momentum when getting out of a thrown closet
@@ -119,7 +124,10 @@
throwing.finalize(FALSE)
/obj/structure/closet/proc/take_contents()
var/turf/T = get_turf(src)
var/atom/L = loc
if(!L)
return
var/turf/T = L.drop_location()
for(var/atom/movable/AM in T)
if(AM != src && insert(AM) == -1) // limit reached
break
@@ -448,3 +456,6 @@
/obj/structure/closet/singularity_act()
dump_contents()
..()
/obj/structure/closet/AllowDrop()
return TRUE

View File

@@ -535,3 +535,6 @@
else
return I
return I
/turf/AllowDrop()
return TRUE

View File

@@ -234,15 +234,11 @@
/mob/proc/drop_all_held_items()
if(!loc || !loc.allow_drop())
return
for(var/obj/item/I in held_items)
dropItemToGround(I)
//Drops the item in our active hand.
/mob/proc/drop_item()
if(!loc || !loc.allow_drop())
return
var/obj/item/held = get_active_held_item()
return dropItemToGround(held)
@@ -272,7 +268,7 @@
//for when you want the item to end up on the ground
//will force move the item to the ground and call the turf's Entered
/mob/proc/dropItemToGround(obj/item/I, force = FALSE)
return doUnEquip(I, force, loc, FALSE)
return doUnEquip(I, force, drop_location(), FALSE)
//for when the item will be immediately placed in a loc other than the ground
/mob/proc/transferItemToLoc(obj/item/I, newloc = null, force = FALSE)

View File

@@ -24,7 +24,7 @@
if(!check_functionality())
return FALSE
var/obj/item/paper/P = new/obj/item/paper(get_turf(holder))
var/obj/item/paper/P = new/obj/item/paper(holder.drop_location())
// Damaged printer causes the resulting paper to be somewhat harder to read.
if(damage > damage_malfunction)

View File

@@ -121,8 +121,8 @@
T.assume_air(gas)
T.air_update_turf()
/obj/structure/disposalholder/allow_drop()
return 1
/obj/structure/disposalholder/AllowDrop()
return TRUE
/obj/structure/disposalholder/ex_act(severity, target)
return