Keep track of of players that have arrived and players that are ready separately. The old check
would start the game as soon as everyone had arrived and *one* person called playerReady(). Now we do the right thing and only start the game once everyone has arrived and everyone has called playerReady(). As with the old code, this only affects clients that use the playerInRoom() method. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@442 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -607,6 +607,9 @@ public class GameManager extends PlaceManager
|
||||
|
||||
// make a note of this player's oid
|
||||
_playerOids[pidx] = caller.getOid();
|
||||
|
||||
// this player is not necessarily ready to play yet
|
||||
_pendingOids.add(caller.getOid());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -617,6 +620,9 @@ public class GameManager extends PlaceManager
|
||||
{
|
||||
playerInRoom(caller);
|
||||
|
||||
// This player is no longer pending
|
||||
_pendingOids.remove(caller.getOid());
|
||||
|
||||
// if everyone is now ready to go, get things underway
|
||||
if (allPlayersReady()) {
|
||||
playersAllHere();
|
||||
@@ -645,7 +651,8 @@ public class GameManager extends PlaceManager
|
||||
public boolean playerIsReady (int pidx)
|
||||
{
|
||||
return (!_gameobj.isOccupiedPlayer(pidx) || // unoccupied slot
|
||||
_playerOids[pidx] != 0 || // player is ready
|
||||
// player is ready
|
||||
(_playerOids[pidx] != 0 && !_pendingOids.contains(_playerOids[pidx])) ||
|
||||
isAI(pidx)); // player is AI
|
||||
}
|
||||
|
||||
@@ -767,6 +774,9 @@ public class GameManager extends PlaceManager
|
||||
// instantiate a player oid array which we'll fill in later
|
||||
_playerOids = new int[getPlayerSlots()];
|
||||
|
||||
// instantiate the pending player list
|
||||
_pendingOids = new ArrayIntSet();
|
||||
|
||||
// give delegates a chance to do their thing
|
||||
super.didStartup();
|
||||
|
||||
@@ -1285,6 +1295,9 @@ public class GameManager extends PlaceManager
|
||||
/** The oids of our player and AI body objects. */
|
||||
protected int[] _playerOids;
|
||||
|
||||
/** The list of players that have arrived in the room, but are not ready to play. */
|
||||
protected ArrayIntSet _pendingOids;
|
||||
|
||||
/** If AIs are present, contains their configuration, or null at human player indexes. */
|
||||
protected GameAI[] _AIs;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user