Ill try to draw a picture of this if that wasnt clear.
[Home]
|
|
[FolderI]
| |
| |
| [FolderA]
| [FolderB]
| | |
| | [Folder1]
| | |
| | [Foldera]
| | ...
| |
| [FolderC]
|
[FolderII]
[FolderIII]
...
So what I am trying to prevent is putting FolderI inside of FolderB or any of the folders inside of FolderB. I just need a way to check because although the system I have now wont allow the actual move of the containers, it still updates the variables associated with what is in that container as if something was moved there.
This is what I sort of came up with
proc
//The goal of this proc is to make check is src is in C or any of Cs subcontainers
Check_Move_Container(obj/item/C)
if(ChkContain(src)) //This just basically checks to see if something is a container
if(src in C) return 0
else
for(var/obj/item/I in C)
if(src in I) return 0
else
for(var/obj/item/O in I)
// Gave up here because I figured out the way I was doing it,
//I would never be able to accommodate all possibilities
//because that would require and infinite amount of programming
else return 1
I also tried using
while(ChkContain(C))
and the continuosly changeing C until it ran through all of Cs contents but I couldnt figure that out
Thank you in advanced for any help you can give.
This will return 1 if it is safe to move and 0 if it is not.
Working it backwards, you don't need to mess with all those lists of contents, since each object will only ever be inside of one other object.