diff --git a/src/as/com/threerings/ezgame/client/EZGameController.as b/src/as/com/threerings/ezgame/client/EZGameController.as index 166125c0..85c57ad4 100644 --- a/src/as/com/threerings/ezgame/client/EZGameController.as +++ b/src/as/com/threerings/ezgame/client/EZGameController.as @@ -34,6 +34,7 @@ import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.util.CrowdContext; import com.threerings.parlor.game.client.GameController; +import com.threerings.parlor.game.data.GameConfig; import com.threerings.parlor.game.data.GameObject; import com.threerings.parlor.turn.client.TurnGameController; @@ -58,6 +59,13 @@ public class EZGameController extends GameController */ public function userCodeIsConnected (autoReady :Boolean) :void { + // if we're not a player, we don't need to report anything to the server + var bobj :BodyObject = (_ctx.getClient().getClientObject() as BodyObject); + if (_gconfig.getMatchType() != GameConfig.PARTY && + _gobj.getPlayerIndex(bobj.getVisibleName()) != -1) { + return; + } + if (autoReady) { // let the game manager know that we're here and we want to start the game now playerIsReady(); @@ -99,6 +107,14 @@ public class EZGameController extends GameController _panel.backend.turnDidChange(); } + // from GameController + override protected function shouldAutoPlayerReady (bobj :BodyObject) :Boolean + { + // we don't want to auto-player ready in willEnterPlace(), we'll do it ourselves after the + // client code has connected + return false; + } + // from GameController override public function attributeChanged (event :AttributeChangedEvent) :void { @@ -116,22 +132,6 @@ public class EZGameController extends GameController } } - // from GameController - override protected function playerReady () :void - { - // we require the user to be connected, and we redundantly only do this if the user is in - // the players array - if (_panel.backend.isConnected()) { - var bobj :BodyObject = (_ctx.getClient().getClientObject() as BodyObject); - if (_gobj.getPlayerIndex(bobj.getVisibleName()) != -1) { - super.playerReady(); - } - - } else { - log.debug("Waiting to call playerReady, userCode not yet connected."); - } - } - // from GameController override protected function gameDidStart () :void { diff --git a/src/as/com/threerings/ezgame/client/GameControlBackend.as b/src/as/com/threerings/ezgame/client/GameControlBackend.as index 1b80e968..4552e983 100644 --- a/src/as/com/threerings/ezgame/client/GameControlBackend.as +++ b/src/as/com/threerings/ezgame/client/GameControlBackend.as @@ -540,7 +540,8 @@ public class GameControlBackend } /** - * Called by the client code when it is ready for the game to be started. + * Called by the client code when it is ready for the game to be started (if called before the + * game ever starts) or rematched (if called after the game has ended). */ protected function playerReady_v1 () :void { diff --git a/src/as/com/threerings/parlor/game/client/GameController.as b/src/as/com/threerings/parlor/game/client/GameController.as index 44b8f4ec..f478f318 100644 --- a/src/as/com/threerings/parlor/game/client/GameController.as +++ b/src/as/com/threerings/parlor/game/client/GameController.as @@ -95,14 +95,15 @@ public /*abstract*/ class GameController extends PlaceController // and add ourselves as a listener _gobj.addListener(this); - // we don't want to claim to be finished until any derived classes that overrode this - // method have executed, so we'll queue up a runnable here that will let the game manager - // know that we're ready on the next pass through the distributed event loop - log.info("Entering game " + _gobj.which() + "."); - if (_gobj.getPlayerIndex(bobj.getVisibleName()) != -1) { - // finally let the game manager know that we're ready to roll + // potentially let the game manager know that we're ready to roll + if (shouldAutoPlayerReady(bobj)) { + // we don't want to claim to be finished until any derived classes that overrode this + // method have executed, so we'll queue up a runnable here that will let the game + // manager know that we're ready on the next pass through the distributed event loop _ctx.getClient().callLater(playerReady); } + + log.info("Entered game " + _gobj.which() + "."); } /** @@ -222,6 +223,14 @@ public /*abstract*/ class GameController extends PlaceController return false; } + /** + * Returns true if we should automatically call playerReady() in willEnterPlace(). + */ + protected function shouldAutoPlayerReady (bobj :BodyObject) :Boolean + { + return (_gobj.getPlayerIndex(bobj.getVisibleName()) != -1); + } + /** * Called after we've entered the game and everything has initialized * to notify the server that we, as a player, are ready to play.