The upper limit of the test area should be the string's maxlength - 1, otherwise two errors occur when iterating through the area using the <= operator: 1) addresses beyond the last element are indexed, triggering UB; this occurs when object.vPos is on the last row of the vWorldMap matrix. 2) the test area will warp around the screen; this happens when object.vPos is on the last column of the matrix it will wrongly index the element from the first column in the next row, potentially detecting a collision with a rectangle in the wrong position. I believe this error was not detected because the map is surrounded with walls.pull/213/head
parent
8fb4feccfa
commit
99ec37ff7a
Loading…
Reference in new issue