Jump to content
  • Advertisement
Sign in to follow this  
Sammy0037

interesting access violation

This topic is 4838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Started debugging some new functions today. No compile errors but an access violation. After stepping through I found the offending line. Its a simple distance test that passes two locations and the radius of each object... one of the simpler forms of collision detection, right? So, I have pointers to the two objects, one from a std::list. Iterator = ObjectList.begin(); while ( Iterator != ObjectList.end() ) //'::Iterator' prototyped elswewhere { //-----The offending line is CollisionTest = CollisionDistance ( (*Iterator)->Location, Object->Location, (*Iterator)->Radius, pObject->Radius ); //--------------------------- ++Iterator }; //the collision function CollisionDistance(Vector &LocA, Vector &LocB, int RadiusA, int RadiusB) { //debugger exits here bool result; int DisSqrdX = (LocA.x - LocB.x) * (LocA.x - LocB.x); int DisSqrdY = (LocA.y - LocB.y) * (LocA.y - LocB.y); int RadiusSqrd = (RadiusA + RadiusB) * (RadiusA + RadiusB); (DisSqrdX + DisSqrdY < RadiusSqrd) ? result = true:result = false; return result; } (*iterator) is certainly different, so I suspect that. If I have them right, the iterators are dereferenced to the pointer values they hold. When passed, the values pointed to are received as references. However the error remains if received as simple values also. At least there are no compiler errors. Both values for 'Object' are defined according to the debugger. But all values in the iterator say the expression cannot be evaluated for all objects in the list. However I do not know if this is SOP when using the variables debug window, in that maybe it simply cannot access them. Well... at least I found where the problem was ;o) cheers

Share this post


Link to post
Share on other sites
Advertisement
GRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR!!!!!!!!!!!!

Found it. I am happy to say that the iterator dereferencing seems to work just fine... at least no errors. I was using the wrong dumb-ass variable that has a similar name to the one that should have been there. I need to go back and rename a few things so this doesnt happen again. So much for trying to be efficient!

cheers!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!