Restructured things to work with the new mechanism for creating distributed
objects. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@53 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -24,6 +24,7 @@ package com.threerings.micasa.lobby;
|
||||
import java.util.Properties;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
import com.threerings.crowd.server.PlaceManager;
|
||||
import com.threerings.micasa.Log;
|
||||
|
||||
@@ -44,8 +45,8 @@ public class LobbyManager extends PlaceManager
|
||||
_gameIdent = getConfigValue(config, "ugi");
|
||||
_name = getConfigValue(config, "name");
|
||||
|
||||
// keep this for later
|
||||
_lobreg = lobreg;
|
||||
// let the lobby registry know that we're up and running
|
||||
lobreg.lobbyReady(_plobj.getOid(), _gameIdent, _name);
|
||||
|
||||
Log.info("Lobby manager initialized [ident=" + _gameIdent +
|
||||
", name=" + _name + "].");
|
||||
@@ -64,19 +65,10 @@ public class LobbyManager extends PlaceManager
|
||||
return value;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected Class getPlaceObjectClass ()
|
||||
@Override // from PlaceManager
|
||||
protected PlaceObject createPlaceObject ()
|
||||
{
|
||||
return LobbyObject.class;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected void didStartup ()
|
||||
{
|
||||
super.didStartup();
|
||||
|
||||
// let the lobby registry know that we're up and running
|
||||
_lobreg.lobbyReady(_plobj.getOid(), _gameIdent, _name);
|
||||
return new LobbyObject();
|
||||
}
|
||||
|
||||
/** The universal game identifier for the game matchmade by this
|
||||
@@ -85,7 +77,4 @@ public class LobbyManager extends PlaceManager
|
||||
|
||||
/** The human readable name of this lobby. */
|
||||
protected String _name;
|
||||
|
||||
/** A reference to the lobby registry. */
|
||||
protected LobbyRegistry _lobreg;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public class LobbyRegistry
|
||||
// lobbyReady() when it has obtained a reference to its lobby
|
||||
// object and is ready to roll
|
||||
LobbyManager lobmgr = (LobbyManager)
|
||||
MiCasaServer.plreg.createPlace(config, null);
|
||||
MiCasaServer.plreg.createPlace(config);
|
||||
lobmgr.init(this, props);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -34,7 +34,6 @@ import com.threerings.presents.server.InvocationManager;
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
import com.threerings.crowd.server.PlaceManager;
|
||||
import com.threerings.crowd.server.PlaceRegistry.CreationObserver;
|
||||
import com.threerings.crowd.server.PlaceRegistry;
|
||||
|
||||
import com.threerings.parlor.game.data.GameAI;
|
||||
@@ -83,7 +82,7 @@ public class SimulatorManager
|
||||
new CreateGameTask(source, config, simClass, playerCount);
|
||||
}
|
||||
|
||||
public class CreateGameTask implements CreationObserver
|
||||
public class CreateGameTask
|
||||
{
|
||||
public CreateGameTask (
|
||||
BodyObject source, GameConfig config, String simClass,
|
||||
@@ -97,10 +96,8 @@ public class SimulatorManager
|
||||
|
||||
try {
|
||||
// create the game manager and begin its initialization
|
||||
// process. the game manager will take care of notifying
|
||||
// the players that the game has been created once it has
|
||||
// been started up (which is done by the place registry
|
||||
// once the game object creation has completed)
|
||||
// process. the game manager will take care of notifying the
|
||||
// players that the game has been created
|
||||
|
||||
// configure the game config with the player names
|
||||
config.players = new Name[_playerCount];
|
||||
@@ -108,23 +105,16 @@ public class SimulatorManager
|
||||
for (int ii = 1; ii < _playerCount; ii++) {
|
||||
config.players[ii] = new Name("simulant" + ii);
|
||||
}
|
||||
|
||||
// we needn't hang around and wait for game object
|
||||
// creation if it's just us
|
||||
CreationObserver obs = (_playerCount == 1) ? null : this;
|
||||
_gmgr = (GameManager)_plreg.createPlace(config, obs);
|
||||
_gmgr = (GameManager)_plreg.createPlace(config);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.warning("Unable to create game manager [e=" + e + "].");
|
||||
Log.logStackTrace(e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void placeCreated (PlaceObject place, PlaceManager pmgr)
|
||||
{
|
||||
// cast the place to the game object for the game we're creating
|
||||
_gobj = (GameObject)place;
|
||||
_gobj = (GameObject)_gmgr.getPlaceObject();
|
||||
|
||||
// determine the AI player skill level
|
||||
byte skill;
|
||||
@@ -142,19 +132,15 @@ public class SimulatorManager
|
||||
// resolve the simulant body objects
|
||||
ClientResolutionListener listener = new ClientResolutionListener()
|
||||
{
|
||||
public void clientResolved (Name username, ClientObject clobj)
|
||||
{
|
||||
public void clientResolved (Name username, ClientObject clobj) {
|
||||
// hold onto the body object for later game creation
|
||||
_sims.add(clobj);
|
||||
|
||||
// create the game if we've received all body objects
|
||||
if (_sims.size() == (_playerCount - 1)) {
|
||||
createSimulants();
|
||||
}
|
||||
}
|
||||
|
||||
public void resolutionFailed (Name username, Exception cause)
|
||||
{
|
||||
public void resolutionFailed (Name username, Exception cause) {
|
||||
Log.warning("Unable to create simulant body object " +
|
||||
"[error=" + cause + "].");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user