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.
You should be initializing the list as a list:
I can see why you made this mistake, coming from C#, but yeah.