ID:2344009
 
Well, what i'm trying to do is determine if objects in a list are still "connected" to one another.

What i'm doing is allowing players to connect objects together in game, example: someone builds a wall 10 tiles long, every object in that wall is now in each others "ANCHOR_GROUP" to form a list of all the tiles that make up that particular wall, or whatever structure they are building.

Now if the center of the wall gets destroyed, how would i determine how to rebuild the remaining objects ANCHOR_GROUP lists based on what objects are still connected to each other ?

I hope that's not too confusing haha, i'm really bad at describing things.
Since lists are passed by reference (they're objects), you can give every wall a reference to the same list of tiles. You don't need to rebuild the list; simply remove the destroyed structure from the list, and every structure connected to it will see that it's gone (because they're all seeing the same list). The list doesn't live on any single structure.
obj/structure
var
// A list of structures connected to this one, including this one.
list/connections

proc
// Connect this structure to another structure.
// You might call this when a structure is created near other structures.
ConnectTo(obj/structure/other)
if(connections)
if(other.connections)
if(connections != other.connections)
// Merge connections into other.connections.
for(var/obj/structure/s in connections)
s.connections = other.connections += s
// else already connected.
else
other.connections = connections += other
else
if(other.connections)
connections = other.connections += src
else
connections = other.connections = list(src, other)

// Disconnect this structure from its connections.
// Call this when this structure is destroyed.
Disconnect()
if(connections)
if(connections.len > 2)
connections -= src
connections = null // Note that the list isn't deleted here, since other structures refer to it.
else
// There's only two structures before this one is disconnected, so just clear it out.
// This should cause the list to be garbage-collected, since nothing should be referring to it.
for(var/obj/structure/s in connections)
s.connections = null
Hey thanks for the reply, that's actually almost exactly how i was building the list (connecting), i tried what you laid out for disconnecting but it doesn't accomplish what I'm trying to do. If i break the middle tile of a row of 10 tiles, the end tiles still register as being in each others connections lists. Example, if i break the middle (5th) tile out of the row of 10 tiles, the end tiles are still in each others connections list even though there is no tile connecting them anymore, basically i want the wall to become two walls, is that possible to do?
In response to MightyMonte88
Oh, okay. You should probably look into flood-fill algorithms, then, as I'm not sure of a simple way to tell if a single wall tile is a bridge between two otherwise disconnected groups.

Here's one library that uses flood-fill to give you connected regions:
http://www.byond.com/developer/Theodis/Region
Hey thanks for all the help man , i really appreciate it. I very rarely use the forum, I've actually been a byond member since 2001 but have since then lost access to my original key names, the project i'm working on is one I've been working on for years now, and i believe i'm finally close to a playable state but this has been something that's stumped me for the longest time.