Fixes internal storage on ground

Fixes not being able to remove items from internal storage when the
master item is on the ground.
This commit is contained in:
Mike
2014-05-10 23:41:48 -04:00
parent 70ac5726dd
commit cee43ffbf3
3 changed files with 26 additions and 9 deletions

View File

@@ -118,7 +118,8 @@
return
// Allows you to click on a box's contents, if that box is on the ground, but no deeper than that
if(isturf(A) || isturf(A.loc) || (A.loc && isturf(A.loc.loc)))
sdepth = A.storage_depth_turf()
if(isturf(A) || isturf(A.loc) || (sdepth != -1 && sdepth <= 1))
next_move = world.time + 10
if(A.Adjacent(src)) // see adjacent.dm

View File

@@ -80,8 +80,6 @@
if (M.s_active == src)
src.close(M)
return 1
/obj/item/weapon/storage/internal/Adjacent(var/atom/neighbor)
return master_item.Adjacent(neighbor)

View File

@@ -456,12 +456,30 @@
O.hear_talk(M, text)
//Returns the storage depth of an atom. This is the number of storage items the atom is contained in before reaching toplevel (the area).
//Returns -1 if the atom was not found on user.
/atom/proc/storage_depth(mob/user)
//Returns -1 if the atom was not found on container.
/atom/proc/storage_depth(atom/container)
var/depth = 0
var/atom/cur_atom = src
while (cur_atom && !(cur_atom in user.contents))
while (cur_atom && !(cur_atom in container.contents))
if (isarea(cur_atom))
return -1
if (istype(cur_atom.loc, /obj/item/weapon/storage))
depth++
cur_atom = cur_atom.loc
if (!cur_atom)
return -1 //inside something with a null loc.
return depth
//Like storage depth, but returns the depth to the nearest turf
//Returns -1 if no top level turf (a loc was null somewhere, or a non-turf atom's loc was an area somehow).
/atom/proc/storage_depth_turf()
var/depth = 0
var/atom/cur_atom = src
while (cur_atom && !isturf(cur_atom))
if (isarea(cur_atom))
return -1
if (istype(cur_atom.loc, /obj/item/weapon/storage))