Ignore request to start up an in-play game; moved code that starts a game
when all players have arrived in the game room into a method that can be overridden. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1000 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: GameManager.java,v 1.20 2002/02/13 18:50:15 mdb Exp $
|
// $Id: GameManager.java,v 1.21 2002/02/14 07:28:12 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.parlor.game;
|
package com.threerings.parlor.game;
|
||||||
|
|
||||||
@@ -137,6 +137,19 @@ public class GameManager extends PlaceManager
|
|||||||
shutdown();
|
shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when all players have arrived in the game room. By default,
|
||||||
|
* this starts up the game, but a manager may wish to override this
|
||||||
|
* and start the game according to different criterion.
|
||||||
|
*/
|
||||||
|
protected void playersAllHere ()
|
||||||
|
{
|
||||||
|
// start up the game (if we haven't already)
|
||||||
|
if (_gameobj.state == GameObject.AWAITING_PLAYERS) {
|
||||||
|
startGame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is called when the game is ready to start (all players
|
* This is called when the game is ready to start (all players
|
||||||
* involved have delivered their "am ready" notifications). It calls
|
* involved have delivered their "am ready" notifications). It calls
|
||||||
@@ -147,6 +160,13 @@ public class GameManager extends PlaceManager
|
|||||||
*/
|
*/
|
||||||
public void startGame ()
|
public void startGame ()
|
||||||
{
|
{
|
||||||
|
// complain if we're already started
|
||||||
|
if (_gameobj.state == GameObject.IN_PLAY) {
|
||||||
|
Log.warning("Requested to start an already in-play game " +
|
||||||
|
"[game=" + _gameobj + "].");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// let the derived class do its pre-start stuff
|
// let the derived class do its pre-start stuff
|
||||||
gameWillStart();
|
gameWillStart();
|
||||||
|
|
||||||
@@ -250,8 +270,7 @@ public class GameManager extends PlaceManager
|
|||||||
public void handleEvent (MessageEvent event, PlaceManager pmgr)
|
public void handleEvent (MessageEvent event, PlaceManager pmgr)
|
||||||
{
|
{
|
||||||
int cloid = event.getSourceOid();
|
int cloid = event.getSourceOid();
|
||||||
BodyObject body = (BodyObject)
|
BodyObject body = (BodyObject)CrowdServer.omgr.getObject(cloid);
|
||||||
CrowdServer.omgr.getObject(cloid);
|
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
Log.warning("Player sent am ready notification and then " +
|
Log.warning("Player sent am ready notification and then " +
|
||||||
"disappeared [event=" + event + "].");
|
"disappeared [event=" + event + "].");
|
||||||
@@ -270,10 +289,9 @@ public class GameManager extends PlaceManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if everyone is now ready to go, start up the game (if we
|
// if everyone is now ready to go, make a note of it
|
||||||
// haven't already)
|
if (allSet) {
|
||||||
if (allSet && _gameobj.state == GameObject.AWAITING_PLAYERS) {
|
playersAllHere();
|
||||||
startGame();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user