Jump to content
  • Advertisement
Sign in to follow this  
matthughson

Weird Bug

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

Hey All, I've got this weird bug in my engine with regards to my stopwatch (timer) class. It seems to be getting filled with garbage, but only when it is declared in certain places. For example, if I make the stopwatch instance a member of the class I'm working on, when i call its 'getElapsedTime' function, it returns a garbage value (the same one every time actually). However, if I declare it as a local member of one of the classes functions, it actually works perfectly! My guess is I've over run some memory somewhere, but I can't seem to find anything. So I'm wondering if this behaviour points anyone in a certain direction to what the problem may be. I have installed a memory manager, which detects no leaks. And when I turn on it's stress tester, the timer works perfectly no matter where it's declared! Sigh... Thanks guys, Matt Hughson

Share this post


Link to post
Share on other sites
Advertisement
hehe nevermind [embarrass]

Turns out the problem was that the object with the timer was being created before the main game timer (which the stopwatch depends on for calculations). Thus, when the stopwatch was created as a member its timer was messed up. But when i made it a local variable in a function it got recreated every frame, and by that time the main game timer had been initialized.

Thanks anyway though!
Matt Hughson

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!