Return ERR_NO_PATH in more situations


  • TMB

    ERR_NO_PATH can be returned by the following methods :

    • Room.findExitTo, Game.map.findExitTo
    • Game.map.findRoute
    • Creep.moveTo, if a new path is being calculated

    ERR_NO_PATH will NOT be returned in the following situations :

    • RoomPosition.findPathTo, if the target can't be reached
    • Creep.move, Creep.moveByPath if trying to move onto an obstructed tile
    • Creep.moveTo, if trying to move onto an obstructed tile while using a cached path

    I understand the two last points aren't really pathfinding errors, but I still would expect them to return some kind of error. And ERR_NO_PATH is at this time the best I see to describe the problem.

    Still, about RoomPosition.findPathTo, why does it return an "incomplete" path instead of an error ? If I wanted to get "within range" of the target, I'd just pass the range option to the parameter.

    Otherwise, did I miss something that would let me know when a creep's movement is being obstructed, or when FindPathTo returns an incomplete path ?


  • Dev Team

    Checking obstacles for players would be incorrect. There are a few cases when such check is excessive, like a creep stepping over a structure which will be destroyed at the next tick. These cases are more or less rare but still, it's breaking change.

    As for your other questions, well, if you're asking this then you're probably experienced enough to migrate to PathFinder.search which provides lots of necessary information (sooner or later, this happens to all of us).

    👍