ID:148283
 
I thought I might as well leave this here incase someone feels like fixing it for when I get back from school tomorrow! =)

GetHops() is called for all rooms until 0 is returned in all of them. That works fine(It seems). The problem seems to be that it doesn't actually assign the values at all, I think. The GetHopsTo procedure returns blank nomatter where to where its used.
room/proc/GetHopsTo(room/R)
var/savefile/S = new(ZONES_DIR + "[zone.name]")
S["rooms/[src.id]/hops/[R.id]"] >> .


room/proc/GetHops()
. = 0 // number of changes made as a result of running this proc
var/dirlist = list("north", "south", "east", "west", "northeast",
"southeast", "northwest", "southwest", "up", "down")
var/savefile/S = new(ZONES_DIR + "[zone.name].sav") // get the room's file
S.cd = "/rooms/[src.id]/hops/"
var/V
var/dir
var/hops
var/oldhops
var/room/R
var/room/R2
// explore rooms that are known to be reachable from here
for(V in S.dir)
R = mud.LocateRoom(V) // get a room by ID
S["[V]"] >> hops
// verify a neighbor is really a neighbor
if(hops == 1)
for(dir in dirlist)
if(vars[dir] == R) break
if(!dir)
++.
S:Remove(V) // that room isn't next door!
continue
// explore R's neighbors; each should be at most hops+1 hops away now
for(dir in dirlist)
R2 = R.vars[dir]
if(!R2) continue
S["[R2.id]"] >> oldhops
// R's neighbor R2 is not in the explored list, or is already marked as farther away
if(!oldhops || oldhops > hops + 1)
++.
world << "writing [hops + 1] to [S.cd]([R2.id])"
S["[R2.id]"] << hops + 1
// explore immediate neighbors
for(V in dirlist)
R = vars[V]
if(!R || R == src) continue // don't count non-exits or loopbacks
S["[R.id]"] >> hops

// if not recorded or it's listed too far away, mark it as a neighbor (1 hop)
if(!hops || hops != 1)
++.
S["[R.id]"] << 1


I don't suppose anyone would be able to spot a problem here? Perhaps im just too tired.
I don't think you're supposed to have a trailing slash after the directory name when you set S.cd.

Lummox JR
In response to Lummox JR
When exporting the savefile to a .txt, this is how it looks:

rooms
2
hops
3

That's ok, except that 3 should be more along the line of 3 = 1. (Room #2 and room #3 both have an exit leading to the other). The assignment of the hop appears to never happen.

The leading slash doesn't matter in that case I believe, using either results in the same savefile.