turf
var/currentc="#FFFFFF"
proc
Flood()
var/O = src.currentc
var/icon/G = icon(src.icon)
src.icon = G.Blend(usr.coloring, ICON_OVERLAY)
src.icon = G
var/turf/Blank/N = locate(src.x+1, src.y, src.z)
var/turf/Blank/Z = locate(src.x, src.y+1, src.z)
var/turf/Blank/X = locate(src.x-1, src.y, src.z)
var/turf/Blank/Y = locate(src.x, src.y-1, src.z)
if(N)
if(N.currentc == O)
var/icon/F = icon(N.icon)
N.icon = F.Blend(usr.coloring, ICON_OVERLAY)
N.icon = F
N.Flood()
if(Z)
if(Z.currentc == O)
var/icon/F = icon(Z.icon)
Z.icon = F.Blend(usr.coloring, ICON_OVERLAY)
Z.icon = F
Z.Flood()
if(X)
if(X.currentc == O)
var/icon/F = icon(X.icon)
X.icon = F.Blend(usr.coloring, ICON_OVERLAY)
X.icon = F
X.Flood()
if(Y)
if(Y.currentc == O)
var/icon/F = icon(Y.icon)
Y.icon = F.Blend(usr.coloring, ICON_OVERLAY)
Y.icon = F
Y.Flood()
Problem description:
Basically what happens here is that a certain turf gets it's color change through the blend command, and it changes the colors of the surrounding turfs if they have the same color.
This ends up with a straight line going right or if I place a spawn() before each part, it is extremely slow.
if(N) will call N.Flood, in N.Flood it will call N.Flood again until all of the Ns are done. It will then go and do the Z.Flood, The Z.Flood will call N.Flood, which will probably call N.Flood (until it runs out), and Z.Flood. (You get the point?)
Now when you spawn it, it does the same amount of work, but it puts them in a process queue, so it runs really slow. Icon processes really are not the fastest to begin with, but with the possible recursion and looping, it will slow it down all the more.
I think in this case, I would add all the turfs to a list (if its in the list no need to call flood on it again), color just one icon, and then loop through all the turfs in the list to change their icon to the new icon. (So minimal icon processes also.)
I'm not sure if this solution would work for you, so let me know if it doesn't and you want some help coming up with one to suit you.