ID:1951538
 
This isn't all of them. But if I can come to realize what I did wrong when initializing/declaring these lists then I can probably just fix the rest on my own. Why don't I post them all now? Well, the procedures are being killed mid-way because of the errors.

Pathfinder
var
list
SearchNode
searchNodes[][] // Stores an array of the walkable search nodes.


Errors contain 4 lines up from the line number and 4 lines down from the line number. The error is just about in the center.

/* runtime error: cannot read from list
proc name: InitializeSearchNodes (/Pathfinder/proc/InitializeSearchNodes)
source file: A-Star Pathfinding.dm,234
usr: Xirre (/mob)
src: /Pathfinder (/Pathfinder)
call stack:
/Pathfinder (/Pathfinder): InitializeSearchNodes()
/Pathfinder (/Pathfinder): New(5, 3, 1)
Xirre (/mob): Login() */


return null

// Split the map in to a grid of nodes.
InitializeSearchNodes()
searchNodes = new/SearchNode[levelWidth][levelHeight]

// For every tile on the map, create a search node for it.
for(var/x = 1; x < levelWidth; x++)
for(var/y = 1; y < levelHeight; y++)

----

/* runtime error: cannot read from list
proc name: ResetSearchNodes (/Pathfinder/proc/ResetSearchNodes)
source file: A-Star Pathfinding.dm,65
usr: Xirre (/mob)
src: /Pathfinder (/Pathfinder)
call stack:
/Pathfinder (/Pathfinder): ResetSearchNodes()
/Pathfinder (/Pathfinder): FindPath(Point (/Point), Point (/Point))
Xirre (/mob): Login() */


closedList = new/list()

for(var/x = 1; x < levelWidth; x++)
for(var/y = 1; y < levelHeight; y++)
var/SearchNode/node = searchNodes[x][y]

if(node == null)
continue

----

/* runtime error: cannot read from list
proc name: FindPath (/Pathfinder/proc/FindPath)
source file: A-Star Pathfinding.dm,125
usr: Xirre (/mob)
src: /Pathfinder (/Pathfinder)
call stack:
/Pathfinder (/Pathfinder): FindPath(Point (/Point), Point (/Point))
Xirre (/mob): Login() */


ResetSearchNodes()

// Store references to the start and end nodes for convenience.
var/SearchNode/startNode = searchNodes[startPoint.x][startPoint.y]
var/SearchNode/endNode = searchNodes[endPoint.x][endPoint.y]


My first assumption is rather than new/SearchNode[][], put new/list[][]. That doesn't work either though. Any enlightenment on the matter would be greatly appreciated.
InitializeSearchNodes()
searchNodes = new/SearchNode[levelWidth][levelHeight]

You should be initializing the list as a list:
searchNodes = new /list (levelWidth, levelHeight)
// /list can be left out because searchNodes is a /list variable

I can see why you made this mistake, coming from C#, but yeah.
In response to Kaiochao
list (levelWidth, levelHeight)

Wouldn't this make the list have 2 indexes only and not a 2D list?

And yeah, I'm constantly throwing in a lot of C# practices in to DM now that I'm using DM again.

Edit:

Apparently "new"/list() makes it a 2D array. I didn't know that. Testing now.
In response to Xirre
Probably not a good idea, since there is no collusion of C# and DM.
In response to AERProductions
AERProductions wrote:
Probably not a good idea, since there is no collusion of C# and DM.

What..?
In response to AERProductions
C# is a common outlier.. If only more people realized this.
Well, everything works. The pathfinding is all good to go. I could use an update that allows for diagonal movement easily.



All I have to do is say "if location[i+1] is to the left or right of location[i] then skip location[i] and move to location[i+1].