GMS 2 Help with Debugger: How to trace grid out of bounds warning message?

S

Satori

Guest
My game uses a custom procedural map generation system using ds_grids in about 20 or so scripts. The game runs fine without any crashes or errors, but when I close the game, I see one or more warning messages in the output window that look something like this:

Grid 0, index out of bounds reading [34,90] - size is [90,90]

Since it doesn't crash the game, I don't have any indication which script is causing the error at what line. How would I go about tracking down this problem?
 

Bentley

Member
I'm just guessing here, but I think that the grid size is 90, 0-89, and you are writing to grid position 90. To track it down I would check the loops that write to the grid and make sure, for example, it is : for (var I = 0 I < 90 instead of for (var I = 0; I <= 90.

Like I said, I''m just guessing, I could be completely wrong.
 

Gzebra

Member
I'm just guessing here, but I think that the grid size is 90, 0-89, and you are writing to grid position 90. To track it down I would check the loops that write to the grid and make sure, for example, it is : for (var I = 0 I < 90 instead of for (var I = 0; I <= 90.

Like I said, I''m just guessing, I could be completely wrong.
It's a good guess, and I'd like to second it. Make sure you're counting through your arrays correctly.
 
S

Satori

Guest
Thanks for the replies, Bentley and Gzebra. You are correct that the valid range for the grid is 0-89 and that the message is caused by attempting to read the grid with an index of 90. (I'm pretty sure it would crash if it was a write.) Since the grid is being passed around between 20 different scripts, I'm trying to determine WHERE the error is taking place. Normally when you have a crash, it tells you the exact line of code that caused the error. Since this is only a warning, it doesn't give that information.

I guess my real question is if there's a way to use the debugger to show which script is causing the error. I'm not very well-versed in using the debugger, so I don't know if it's possible to do that or how to do it. Anyone know?
 

Gzebra

Member
Thanks for the replies, Bentley and Gzebra. You are correct that the valid range for the grid is 0-89 and that the message is caused by attempting to read the grid with an index of 90. (I'm pretty sure it would crash if it was a write.) Since the grid is being passed around between 20 different scripts, I'm trying to determine WHERE the error is taking place. Normally when you have a crash, it tells you the exact line of code that caused the error. Since this is only a warning, it doesn't give that information.

I guess my real question is if there's a way to use the debugger to show which script is causing the error. I'm not very well-versed in using the debugger, so I don't know if it's possible to do that or how to do it. Anyone know?
I get ya, unfortunately, I know next to nothing about using the actual debugger.. It's still a new feature to me :oops:
 
Top