From cee43ffbf3078a8834356cd4fea44c678c5a33d0 Mon Sep 17 00:00:00 2001 From: Mike Date: Sat, 10 May 2014 23:41:48 -0400 Subject: [PATCH] Fixes internal storage on ground Fixes not being able to remove items from internal storage when the master item is on the ground. --- code/_onclick/click.dm | 3 ++- .../objects/items/weapons/storage/internal.dm | 8 +++---- .../objects/items/weapons/storage/storage.dm | 24 ++++++++++++++++--- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index 02406ed507..7612b48453 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -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 diff --git a/code/game/objects/items/weapons/storage/internal.dm b/code/game/objects/items/weapons/storage/internal.dm index 11058f0dc5..67205c7619 100644 --- a/code/game/objects/items/weapons/storage/internal.dm +++ b/code/game/objects/items/weapons/storage/internal.dm @@ -80,8 +80,6 @@ if (M.s_active == src) src.close(M) return 1 - - - - - \ No newline at end of file + +/obj/item/weapon/storage/internal/Adjacent(var/atom/neighbor) + return master_item.Adjacent(neighbor) \ No newline at end of file diff --git a/code/game/objects/items/weapons/storage/storage.dm b/code/game/objects/items/weapons/storage/storage.dm index a4c5644598..6864e6aad3 100644 --- a/code/game/objects/items/weapons/storage/storage.dm +++ b/code/game/objects/items/weapons/storage/storage.dm @@ -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))