unexpected behavior with std list and pointers,
Members - Reputation: 341
Posted 08 December 2012 - 06:35 PM
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.
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.
Members - Reputation: 984
Posted 08 December 2012 - 07:05 PM
Moderators - Reputation: 12226
Posted 08 December 2012 - 11:00 PM