I hate adding random booleans, but it is an easy mistake to miss a case where

turnDidStart() results in an immediate call to endTurn() and things then spiral
off into infinite loop land. If someone genuinely does want to end a turn
mmediately in turnDidStart() they can queue up a dobj unit to do so.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@27 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2006-07-19 02:55:08 +00:00
parent 19e5b04b41
commit db8125271b
@@ -144,7 +144,17 @@ public class TurnGameManagerDelegate extends GameManagerDelegate
// and start the next turn if desired
if (_turnIdx != -1) {
// prevent infinite loops if the game manager decides to
// unwittingly call endTurn() in turnDidStart()
if (_startingTurn) {
Log.warning("Refusing to start looping in endTurn() " +
"[game=" + where() + "].");
Thread.dumpStack();
} else {
_startingTurn = true;
startTurn();
}
_startingTurn = false;
} else {
// otherwise, clear out the turn holder
@@ -243,4 +253,8 @@ public class TurnGameManagerDelegate extends GameManagerDelegate
/** The player index of the current turn holder or <code>-1</code> if
* it's no one's turn. */
protected int _turnIdx = -1;
/** Used to avoid infinite loops in buggy game managers that call endTurn()
* from startTurn(). */
protected boolean _startingTurn;
}