Jump to content

  • Log In with Google      Sign In   
  • Create Account


unexpected behavior with std list and pointers


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 freeworld   Members   -  Reputation: 325

Like
0Likes
Like

Posted 08 December 2012 - 06:35 PM

This is from my phone please excuse the grammar.

I've got a very simple state machine that stores states as pointers in a std list. States have a isAlive flag that tells the statemachine that the state needs to be deleted. I always only ever operate on the back of he list which should always be the newest state. When I say a state is added. The machine adds the state after the current state is fully processed including deleting of it.

So far my game flows like so. Menu state is added. Runs. A level loader state gets added and his states adds a level state. When the level is lost it flags it self as dead and adds a gameover state. The game Hoover state flags itself as dead and the stack is cleared back down to the level loader state. Which has no more levels to load so flags itself as dead. Now all other states get deleted properly but for some reason when it reaches the check to see if the load level state is dead it just skips it. And he debugger clearly shows the state as dead even the code that sets it as dead runs right.

It's a lot of separate code else I would've posted it. I'm just really stumped on this one. Why it won't delete this state but all the great get cleaned up just fine.
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.

Sponsor:

#2 JohnnyCode   Members   -  Reputation: 227

Like
0Likes
Like

Posted 08 December 2012 - 07:05 PM

you were too detailed about abstraction of your project, but did not provide technical point of problem. Could you state again where is your problem? A pointer in std::list still remains in list, or it does not "delete" in other abstract manner? You sad you operate at the end of the list only, but you perform some 'marking' magic on the members on as to free them, I would think about that. make sure you are removing std::list members, or marking them in order to be "deleted" in your pattern, and wheather this marking magic corellates with your std::list 'at the end operate' idea. Are you cutting of states from the first state that is ended all to way to the back of the list or how? Cannot get it, sorry. You should describe your problem more accurately to get better help. I am just stabbing in the dark.

#3 JTippetts   Moderators   -  Reputation: 8409

Like
0Likes
Like

Posted 08 December 2012 - 11:00 PM

Pare your code down to the simplest example that demonstrates your problem, and post that example here (if in doing this, you don't figure it out on your own, anyway; often this is a good way of finding bugs yourself). Without code to look at, we're all just like JohnnyCode, stabbing in the dark.

#4 freeworld   Members   -  Reputation: 325

Like
0Likes
Like

Posted 09 December 2012 - 06:45 PM

got it, i redefined the isAlive member in the derived class. it's always somthing so simple that takes so long to find.
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS