Bug? Maybe? with Creep.moveTo() and visualization



  • So this started with an attempt to figure out why, sometimes, but not all the time, my creeps would recalculate a path every tick instead of every reusePath ticks. 

    Turns out that there is a flaw in Creep.moveTo()

     

    https://github.com/screeps/engine/blob/master/src/game/creeps.js#L266

     

    ```

    if(result == C.OK) {
      return C.OK;
     

    }```

     

    means that the function will continue to execure if the moveByPath command returns a not OK. ERR_TOO_TIRED is not OK. But that's fine right, cause moveTo checks fatigue. Except it doesn't.

     

    ```

    if(data(this.id).fatigue > 0 && (!opts || !opts.visualizePathStyle)) {
      return C.ERR_TIRED;
     

    }```

     

    If you have options and that options contains visualizePathStyle then this check is ignored and you re-calc path on ANY not OK from line 266 including ERR_TOO_TIRED

     

    This does not seems like the expected behavior. It seems like a bug. But I suppose it could be an undocumented feature.



  • I hate this forum, it never does what I expect.



  • And I can't use the pos editor to fix it because black on black is bad.