This is just a bunch of random thoughts on C++ programming, so you might wish to skip this post ;-).
One of my greatest programming challenges ever was the moment when the player's character dies. I used to solve this problem by having a lot of returns. That made my code looking like this:
Hero->LoseHP (10); if (Hero->HP == 0) return;
It hardly worked, but I've never had a better idea. And it only sometimes crashed. But I knew how much it sucked. In roguelike games you have plenty of different situations when your character can die, which means that you always get a lot of junk on the call stack. For example:
... PointDirection --> ThrowItem --> Defend --> LoseHP
This is the case when the player throws an item and it explodes right into their face (this is possible in the next version, 0.7.4).
Of course I had to provide a return statement following the HP check on every of these levels. Each time I did this, I dreamed of a language mechanism to nicely unwind the call stack to the specified level. But hey, we already have such a mechanism in C++, it's called 'exceptions'!
Some of you may say "But... you're breaking the Rule No. 1; never abuse exceptions!". Chill out dudes, I know this rule, I've always obeyed it and I don't think I'm breaking it now. The death of the main character is an exceptional situation. It's the same kind of problem as if your hard drive broke during the gameplay (not only because you start swearing in both cases). Unwinding provided by exceptions is the only thing that really prevents a disaster here. All you need is to catch the exception somewhere near your main loop and you're safe and sound. So this is my new friend:
class CHeroDeath : public CException { // ... };
I throw this stuff just in one place and catch it just in one place, too. These are the only places in the code I had to modify. I've even left the HP checks alone - they're redundant now, but shouldn't hurt. And the game stopped crashing.
I'm so smart, am I not? ;-P