Jump to content
  • Advertisement
Sign in to follow this  
RanmaruX

Exact same "=" operation giving 2 different values?

This topic is 4554 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

What I've got: In C++ I have a Line2D class which consists of 2 points ( ev2P0 and ev2P1 )... What I'm trying to do: At one point in my code, I need make a line from the position of my enemy to a point 100 pixels above my enemy... Line2D lEnemy; lEnemy.ev2P0 = pCurrentEnemy->ev2Position; lEnemy.ev2P1 = pCurrentEnemy->ev2Position + EasyVector2D( 0.0f, 100.0f ); For some reason when I watch these values in the Visual Studio 2005 debugger, they always end up as... ev2P0 {x=300.00000 y=600.00000 } ev2P1 {x=1.0000000 y=0.00000000 } ( I expected x=300 y=700 ) I thought maybe there was something wrong with the EasyVector2D "+" operator so just as an experiment I changed the code to... Line2D lEnemy; lEnemy.ev2P0 = pCurrentEnemy->ev2Position; lEnemy.ev2P1 = pCurrentEnemy->ev2Position; and this happened... ev2P0 {x=300.00000 y=600.00000 } ev2P1 {x=1.#QNAN00 y=-1.#IND000 } ( I expected x=300 y=600 ) I am at a loss. How on earth can the same code give 2 different values? pCurrentEnemy->ev2Position is definitely not being changed. If anyone can shed any light on this, it would be greatly appreciated! PS: I tried putting my code in source tags but it made the "+" sign not show up?

Share this post


Link to post
Share on other sites
Advertisement
Assuming you're using the debugger correctly, it sounds like something is happening in the member access of ev2Position -- specifically, that it's getting reset. Did you try looking there?

Share this post


Link to post
Share on other sites
I just have it as a public member so I'm fairly sure there isn't anything changing that value. I just looked again though and realised it's because the debugger is foobar.

lEnemy.ev2P0 = pCurrentEnemy->ev2Position;

According to the debugger, this line is actually changing lEnemy.pNext and...

lEnemy.ev2P1 = pCurrentEnemy->ev2Position;

...is changing lEnemy.ev2P0! I get the feeling the debugger is looking at the wrong address for the members of lEnemy :(

Share this post


Link to post
Share on other sites
Clean the project, and make sure you're project settings are set up for debugging (the Debug, not Release, configuration unless you've changed the configurations).

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!