Make it easy for derived classes to opt-out of the no show timer; fixed

checkForNoShows() to only claim a partial no-show when one or more players
have not reported readiness.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2006 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-11-29 20:56:06 +00:00
parent f7c27a1afa
commit 5f4108823c
@@ -1,5 +1,5 @@
//
// $Id: GameManager.java,v 1.55 2002/11/26 09:12:10 mdb Exp $
// $Id: GameManager.java,v 1.56 2002/11/29 20:56:06 mdb Exp $
package com.threerings.parlor.game;
@@ -384,8 +384,8 @@ public class GameManager extends PlaceManager
ParlorSender.gameIsReady(bobj, _gameobj.getOid());
}
// start up a no-show timer unless this is a party game
if (!_gameconfig.isPartyGame()) {
// start up a no-show timer if needed
if (needsNoShowTimer()) {
IntervalManager.register(new SafeInterval(CrowdServer.omgr) {
public void run () {
checkForNoShows();
@@ -394,6 +394,16 @@ public class GameManager extends PlaceManager
}
}
/**
* Returns true if this game requires a no-show timer. The default
* implementation returns true for non-party games and false for party
* games. Derived classes may wish to change or augment this behavior.
*/
protected boolean needsNoShowTimer ()
{
return !_gameconfig.isPartyGame();
}
// documentation inherited
protected void didShutdown ()
{
@@ -468,7 +478,13 @@ public class GameManager extends PlaceManager
placeBecameEmpty();
} else {
handlePartialNoShow();
// do the right thing if we have any no-show players
for (int ii = 0; ii < getPlayerSlots(); ii++) {
if (!playerIsReady(ii)) {
handlePartialNoShow();
return;
}
}
}
}
@@ -756,15 +772,26 @@ public class GameManager extends PlaceManager
protected boolean allPlayersReady ()
{
for (int ii = 0; ii < getPlayerSlots(); ii++) {
if (_gameobj.isOccupiedPlayer(ii) &&
(_playerOids[ii] == 0) &&
(_AIs == null || _AIs[ii] == -1)) {
if (!playerIsReady(ii)) {
return false;
}
}
return true;
}
/**
* Returns true if the player at the specified slot is ready (or if
* there is meant to be no player in that slot), false if there is
* meant to be a player in the specified slot and they have not yet
* reported that they are ready.
*/
protected boolean playerIsReady (int pidx)
{
return (!_gameobj.isOccupiedPlayer(pidx) || // unoccupied slot
_playerOids[pidx] != 0 || // player is ready
(_AIs != null && _AIs[pidx] != -1)); // player is AI
}
// documentation inherited from interface
public void startPartyGame (ClientObject caller)
{