ID:156229
 
proc
cleanturf()
for(var/turf/t in world)
t.check()

turf/var/list/checklist=list()
turf/proc
check()//duplicates
for(var/buildable/t in src.contents)
src.checklist.Add(t)
if(src.checklist.len<=1)
return//no dupes or not built on
while(src.checklist.len>0)
var/buildable/a=pick(src.checklist)
for(var/buildable/b in src.checklist)
if(b.build==a.build)
del(b)
checklist-=a//reiterate for all turfs.


Notes: yes buildable is a datumn and all the verbs exist.

Problem: when i run the code i get a bunch of errors from most turfs saying that they cant modify null.contents? when im specifying a variable?

Any insights on how to improve this would be helpfull. I am using Lummox jr swapmaps and just want cleaner and smaller maps, thanks.

-R-
A much more efficient method would be preventing the duplicates from happening in the first place.

buildable
Move(NewLoc)
if(isturf(NewLoc))
var/buildable/found = locate(src.type) in NewLoc
if(found) // If an object of the same type is found.
return 0 // Prevent the movement.
..()
In response to Nadrew
ah i see, the move proc can handle this. I tried editing the buildables New() function before and it gave me runtime errors when i tried to create new objects. Thanks for your help

EDIT: you even taught me a new, type var, this would have made my life so much easier in earlier projects :S