Runescape-Web-Walker-Engine icon indicating copy to clipboard operation
Runescape-Web-Walker-Engine copied to clipboard

ArrayIndexOutOfBoundsException on DaxPathFinder

Open BegTribot opened this issue 1 year ago • 4 comments

https://github.com/itsdax/Runescape-Web-Walker-Engine/blob/25d77106b5aa3db1bcc2bb867eb7460a88e6d0e7/src/main/java/dax/walker/utils/path/DaxPathFinder.java#L168 Weird one, shouldn't collisionData.length < home.getX() prevent the ArrayIndexOutOfBoundsException? Can getX return different results for different calls? Maybe should be cached into a variable, same for home.getY()

java.lang.ArrayIndexOutOfBoundsException: Index -5129 out of bounds for length 104
at scripts.api.dax.walker.utils.path.l.G(DaxPathFinder.java:168)
at scripts.api.dax.walker.utils.path.b.f(PathUtils.java:35)
at scripts.api.dax.walker_engine.d.G(WalkerEngine.java:105)

BegTribot avatar Oct 14 '23 06:10 BegTribot

huh I thought those fields were final. I guess not

we should probably store it in a local variable as you mentioned

itsdax avatar Oct 22 '23 20:10 itsdax

It's already being stored as a local variable. The X value being returned by home.getX() is -5129, and the function call is making sure it is less than 104 (so it is technically true). We could add a check to make sure it is >= 0, however this is caused by an underlying issue with TRiBot API.

FALSkills avatar Oct 23 '23 11:10 FALSkills

Maybe I'm misunderstanding something... but:

  • if home.getX() is -5129, then that contradicts with collisionData.length < home.getX()
  • collisionData.length can't be less than 0 so that means collisionData[home.getX()] shouldn't have ever triggered.
    • if it did trigger, then that means home.getX() > 0, which wouldn't have caused this stacktrace

My understanding is that home.getX() returned 2 different values mid branch.

itsdax avatar Oct 24 '23 03:10 itsdax

I must not have had my coffee yet when I was looking at this, because yes it is returning different values. It looks like this is due to how TRiBot calculates x/y when it is a local tile, as it is an active calculation based upon the map offset, and not simply returning an x or y. If I were to guess, this occurrs rarely while the next map chunk is being loaded. We can cache the x and y coords of the home tile rather than use the function calls and it should be fine.

FALSkills avatar Oct 24 '23 11:10 FALSkills