Skip to content

Adjusted for negative distance and fixed potential index-out-of-range when time%MOVE_DURATION != 0

Sebastian Strempfer requested to merge patch-1 into master

I noticed you allowed for negative distances, but some of the code still assumed a is positive.

When MOVE_DURATION doesn't evenly divide time, the for loop will go all the way to the end of the array, but after the for loop the next element will be accessed, which will be out of range in that case. I fixed this by simply increasing the size of the array when needed, but maybe the better fix would be to adjust the for loop condition, idk. At least this way it won't randomly crash.

Merge request reports

Loading