Don't get sidetracked by the code pasted above. It's not the main concern here, but I thought it might help to outline the problem. I want the proc to cast "moonlight" over ALL turfs in the world. And it works for all turfs with the exception of those that have been "stacked" or "layered" in the map. By this, I refer to when one turf is laid down on the map, and then another turf is placed on top of it using the ctrl+click command. What actually happens when I use the proc is this:
It finds a turf by itself, non-layered, it casts moonlight, no problem.
It comes across a location where one turf is layered over the other, it casts moonlight over the topmost layer, ignores the bottommost.
What might be causing this behavior?