Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [Bug?] 2.0.20 Tier 2: agk::GetNextContact Reference Out of Bounds Exception

Author
Message
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 22nd Aug 2016 18:43 Edited at: 29th Aug 2016 20:46
Hello,

I have a basic while loop that attempts to go through the contact list and handle the collisions for each pair of Sprite IDs; my code is below--it's a rough draft, so be nice. By the time I get to the last line in the loop, it "contact = agk::GetNextContact();" I get an immediate Reference Out of Bounds Exception. If I take the line out, it works. If I put the line anywhere else, it breaks. I should get a 0 or 1, correct?. Any ideas with what I am doing wrong? I'm using VS2013 and Windows 7 if that matters,.




[EDIT] NOT AN AppGameKit BUG. MY POINTERS ARE GETTING SMASHED SOMEWHERE.
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 24th Aug 2016 05:32
Strange development: for some reason it works in XCode on Mac with the same code... I have no idea what's going on.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 27th Aug 2016 03:01
Are you using the correct libraries (in <agkdir>\Tier 2\platform\windows\Lib\VS2013)?

Have you tried using the debugger to watch values?

Are you sure that mVecNodes is getting initialized? And how is it defined?

As a general coding recommendation (I've been programming professionally for 38 years), if there is more than one logical thing in an 'if' statement, it is a good idea to group things with parenthesis to make sure that the code gets done in the order you want.

For instance, this "if(node1 != nullptr && node2 != nullptr)" would be better written as "if ((node1 != nullptr) && (node2 != nullptr))".

While compilers should follow the expected operator precedence, I've discovered that they sometimes don't.
Cheers,
Ancient Lady
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 29th Aug 2016 20:44

I'm using the 2013 libs. I took out the for loop, and I haven't seen an error yet which does point me to an issue with my objects possibly getting smashed somewhere. Odd that it is fine on Mac with the same code.

Login to post a reply

Server time is: 2024-04-19 23:09:02
Your offset time is: 2024-04-19 23:09:02