prettymuchbryce/easystarjs

Crash on calculateDirection() when allowCornerCutting == false while calculating path through directional tiles

Teslov-Mikhail opened this issue · 1 comments

When using easystar.disableCornerCutting(); app crashes when asked to calculate a path with obstacles that are accessible only from certain directions.

As long as there's at least one easystar.setDirectionalCondition() the app will crash when trying to calculate a path through these tiles.

C:\Users\Teslov\Desktop\openscape\node_modules\easystarjs\src\easystar.js:472
            var direction = calculateDirection(sourceNode.x - x, sourceNode.y - y)
                                                         ^

TypeError: Cannot read property 'x' of undefined
    at isTileWalkable (C:\Users\Teslov\Desktop\openscape\node_modules\easystarjs\src\easystar.js:472:58)
    at calculate (C:\Users\Teslov\Desktop\openscape\node_modules\easystarjs\src\easystar.js:404:26)
    at Socket.<anonymous> (C:\Users\Teslov\Desktop\openscape\index.js:131:14)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at C:\Users\Teslov\Desktop\openscape\node_modules\socket.io\lib\socket.js:513:12
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

I would be extremaly glad if someone would find a solution to this problem. This feature is crucial to my project and my expertise with advanced algorithms is lacking.

With corner cutting enabled characters are able to pass through walls.

Fixed by #57

Thanks for your help!