I have a simple game loop.
1 2 3 4 5 6 7 8
|
while(true)
{
//round initialisation stuff
while(true)
{
//capture input, make pieces move, blah blah
}
}
| |
I am faced with the decision of what is the best way of restarting the game. The problem is, the condition for restarting a game is very, very deep inside the game's logic. So returning returning... is not an option, or at least, it ain't gonna be pretty.
So one of my considerations is to use a goto label, like so:
1 2 3 4 5 6 7 8 9
|
while(true)
{
//round initialisation stuff
while(true)
{
//capture input, make pieces move, blah blah
}
restart_round:
}
| |
This seems to be the cleanest solution, since it allows me to fully reset the 'state' of the round, by first having all the destructors(pertaining to the round's objects) called, and then the constructors and other initialisation stuff.
Are there any subtleties that I am missing regarding this solution? Are there any clean alternatives that could be suggested?
Obviously, I will need to document this behaviour well since it is not typical. Lastly, I kindly ask to stay on topic, I do not want to start a goto(good^evil) debate :)