• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Discussion Is there a reason GM2 won't/can't report where a grid access out of bounds occurs?

P

ph101

Guest
Is there a reason GM2 won't/can't report where a grid access out of bounds occurs? They show in console but if does not show where in the code the attempted access was made. Why is that? It makes debugging unfairly tricky.
 
P

ph101

Guest
Hey. While I get that you can substitute a script in to debug this, and I may be forced to - I am trying to understand if there is an actual reason why it's not reported as an error because it really is a pain. The problem is with large existing projects I cant search replace ds_grid_get because frequently I'm using [# ] grid accesors so there is no easy way to subtitue this ine - it could take hours possibly even days to do so.

I do wonder why isn't it reported as an error saying where this happens, so you can debug your code easily?
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
so there is no easy way to subtitue this
GMEdit has regular expression search and replace, which can be utilized for this, depending on how complex does your code get.

I do wonder why isn't it reported as an error saying where this happens, so you can debug your code easily?
I doubt that there's an answer better than "warnings were added before debug_get_callstack and no one filed a suggestion about it while being vaguely upset on forums"
 

Hyomoto

Member
A faster, easier, way to do it would be to throw in some simple show_debug_message() calls into the areas you think are a culprit. Once you've narrowed down when it's happening, you can figure out why.

You shouldn't have replace anything. It seems to me you've either mis-formed your grid size, or are letting your numbers go out of bounds. Either way, it shouldn't take more than a few hours at worst to narrow it down.

As for why, probably because it's a warning. GML only gives those specifics when the project reaches an exception. It probably could be added, but I'd argue accessing outside a grid's bounds should just crash to make it explicit you are doing something wrong.
 
P

ph101

Guest
Ta for the thoughts. I do realise it shouldn't really happen with well organised code, but sometimes you find yourself working on or maintaining a large project that may have legacy code that is less than 100% perfect, yet still in use(!) I agree a crash would be just as welcome. This vaguely upset forum user is going to file a suggestion, just for the future. It might make things easier and more consistent with errors as found when accessing outside ds_lists or other ds_'s.
 

Hyomoto

Member
There's no problem with filling the suggestion, and I agree with you: it should give better feedback. That part of my comment is just because I don't think the warning is the proper response, given the result is unexpected behavior.
 
Top