diff --git a/src/java/com/threerings/parlor/game/GameManager.java b/src/java/com/threerings/parlor/game/GameManager.java index 5d8fe869b..393f20b26 100644 --- a/src/java/com/threerings/parlor/game/GameManager.java +++ b/src/java/com/threerings/parlor/game/GameManager.java @@ -1,5 +1,5 @@ // -// $Id: GameManager.java,v 1.40 2002/09/06 22:52:27 shaper Exp $ +// $Id: GameManager.java,v 1.41 2002/09/18 04:01:29 shaper Exp $ package com.threerings.parlor.game; @@ -235,14 +235,6 @@ public class GameManager extends PlaceManager return (_AIs != null && _AIs[pidx] != -1); } - /** - * Returns whether the game is over. - */ - public boolean isGameOver () - { - return (_gameobj.state == GameObject.GAME_OVER); - } - /** * Returns the unique round identifier for the current round. */ @@ -344,8 +336,8 @@ public class GameManager extends PlaceManager Log.info("Game room empty. Going away. " + "[gameOid=" + _gameobj.getOid() + "]."); - // cancel the game if it wasn't over. - if (_gameobj.state != GameObject.GAME_OVER) { + // cancel the game if it was in play + if (_gameobj.state == GameObject.IN_PLAY) { _gameobj.setState(GameObject.CANCELLED); } @@ -485,6 +477,12 @@ public class GameManager extends PlaceManager */ public void endGame () { + if (_gameobj.state != GameObject.IN_PLAY) { + Log.debug("Refusing to end game that was not in play " + + "[game=" + _gameobj.which() + "]."); + return; + } + // figure out who won... // transition to the game over state diff --git a/src/java/com/threerings/parlor/game/GameObject.dobj b/src/java/com/threerings/parlor/game/GameObject.dobj index 126ba652e..9b7df5109 100644 --- a/src/java/com/threerings/parlor/game/GameObject.dobj +++ b/src/java/com/threerings/parlor/game/GameObject.dobj @@ -1,5 +1,5 @@ // -// $Id: GameObject.dobj,v 1.11 2002/08/14 19:07:53 mdb Exp $ +// $Id: GameObject.dobj,v 1.12 2002/09/18 04:01:29 shaper Exp $ package com.threerings.parlor.game; @@ -58,4 +58,13 @@ public class GameObject extends PlaceObject return (players == null) ? -1 : ListUtil.indexOfEqual(players, username); } + + /** + * Returns whether the game is in play. A game that is not in play + * could either be awaiting players, ended, or cancelled. + */ + public boolean isInPlay () + { + return (state == IN_PLAY); + } } diff --git a/src/java/com/threerings/parlor/game/GameObject.java b/src/java/com/threerings/parlor/game/GameObject.java index 700b93e78..315c0bcc5 100644 --- a/src/java/com/threerings/parlor/game/GameObject.java +++ b/src/java/com/threerings/parlor/game/GameObject.java @@ -1,5 +1,5 @@ // -// $Id: GameObject.java,v 1.6 2002/08/14 19:07:53 mdb Exp $ +// $Id: GameObject.java,v 1.7 2002/09/18 04:01:29 shaper Exp $ package com.threerings.parlor.game; @@ -74,6 +74,15 @@ public class GameObject extends PlaceObject ListUtil.indexOfEqual(players, username); } + /** + * Returns whether the game is in play. A game that is not in play + * could either be awaiting players, ended, or cancelled. + */ + public boolean isInPlay () + { + return (state == IN_PLAY); + } + /** * Requests that the service field be set to the specified * value. The local value will be updated immediately and an event