diff --git a/src/java/com/threerings/parlor/client/ParlorDirector.java b/src/java/com/threerings/parlor/client/ParlorDirector.java
index 1557a3919..454040f64 100644
--- a/src/java/com/threerings/parlor/client/ParlorDirector.java
+++ b/src/java/com/threerings/parlor/client/ParlorDirector.java
@@ -1,5 +1,5 @@
//
-// $Id: ParlorDirector.java,v 1.7 2001/10/03 03:43:14 mdb Exp $
+// $Id: ParlorDirector.java,v 1.8 2001/10/06 00:25:29 mdb Exp $
package com.threerings.parlor.client;
@@ -191,26 +191,10 @@ public class ParlorDirector
* player is ready to begin.
*
* @param gameOid the object id of the game object.
- * @param config the configuration information for the started game.
*/
- public void handleGameReadyNotification (int gameOid, GameConfig config)
+ public void handleGameReadyNotification (int gameOid)
{
- Log.info("Handling game ready [goid=" + gameOid +
- ", config=" + config + "].");
-
- try {
- // create the game controller for this game
- GameController ctrl = (GameController)
- config.getControllerClass().newInstance();
-
- // initialize it and get things underway
- ctrl.init(_ctx, gameOid, config);
-
- } catch (Exception e) {
- Log.warning("Unable to instantiate game controller " +
- "[goid=" + gameOid + ", config=" + config +
- ", error=" + e + "].");
- }
+ Log.info("Handling game ready [goid=" + gameOid + "].");
}
/**
diff --git a/src/java/com/threerings/parlor/game/GameConfig.java b/src/java/com/threerings/parlor/game/GameConfig.java
index 8e9c46389..0220efa31 100644
--- a/src/java/com/threerings/parlor/game/GameConfig.java
+++ b/src/java/com/threerings/parlor/game/GameConfig.java
@@ -1,5 +1,5 @@
//
-// $Id: GameConfig.java,v 1.4 2001/10/03 03:43:37 mdb Exp $
+// $Id: GameConfig.java,v 1.5 2001/10/06 00:25:29 mdb Exp $
package com.threerings.parlor.data;
@@ -7,7 +7,7 @@ import java.io.IOException;
import java.io.DataInputStream;
import java.io.DataOutputStream;
-import com.threerings.cocktail.cher.io.Streamable;
+import com.threerings.cocktail.party.data.PlaceConfig;
/**
* The game config class encapsulates the configuration information for a
@@ -31,34 +31,16 @@ import com.threerings.cocktail.cher.io.Streamable;
* information and overriding {@link #writeTo} and {@link #readFrom} to
* provide code to serialize and unserialize the additional fields.
*/
-public abstract class GameConfig implements Streamable
+public abstract class GameConfig extends PlaceConfig
{
/** Indicates whether or not this game is rated. */
public boolean rated = false;
- /**
- * Returns the class that should be used to create a controller for
- * this game. The controller class must derive from {@link
- * com.threerings.parlor.client.GameController}.
- */
- public abstract Class getControllerClass ();
-
- /**
- * Returns the name of the class that should be used to create a
- * manager for this game. The manager class must derive from {@link
- * com.threerings.parlor.server.GameManager}. Note: this
- * method differs from {@link #getControllerClass} because we want to
- * avoid compile time linkage of the game config object (which is used
- * on the client) to server code. This allows a code optimizer (DashO
- * Pro, for example) to remove the server code from the client,
- * knowing that it is never used.
- */
- public abstract String getManagerClassName ();
-
// documentation inherited
public void writeTo (DataOutputStream out)
throws IOException
{
+ super.writeTo(out);
out.writeBoolean(rated);
}
@@ -66,33 +48,14 @@ public abstract class GameConfig implements Streamable
public void readFrom (DataInputStream in)
throws IOException
{
+ super.readFrom(in);
rated = in.readBoolean();
}
- /**
- * Generates a string representation of this object by calling the
- * overridable {@link #toString(StringBuffer)} which builds up the
- * string in a manner friendly to derived classes.
- */
- public String toString ()
- {
- StringBuffer buf = new StringBuffer();
- buf.append("[");
- toString(buf);
- buf.append("]");
- return buf.toString();
- }
-
- /**
- * An extensible mechanism for generating a string representation of
- * this object. Derived classes should override this method, calling
- * super and then appending their own data to the supplied string
- * buffer. The regular {@link #toString} function will call this
- * derived function to generate its string.
- */
+ // documentation inherited
protected void toString (StringBuffer buf)
{
- buf.append("type=").append(getClass().getName());
+ super.toString(buf);
buf.append(", rated=").append(rated);
}
}
diff --git a/src/java/com/threerings/parlor/game/GameController.java b/src/java/com/threerings/parlor/game/GameController.java
index 3e93662d8..53f19b6b4 100644
--- a/src/java/com/threerings/parlor/game/GameController.java
+++ b/src/java/com/threerings/parlor/game/GameController.java
@@ -1,5 +1,5 @@
//
-// $Id: GameController.java,v 1.1 2001/10/01 06:19:15 mdb Exp $
+// $Id: GameController.java,v 1.2 2001/10/06 00:25:29 mdb Exp $
package com.threerings.parlor.client;
@@ -8,6 +8,9 @@ import java.awt.event.ActionEvent;
import com.samskivert.swing.Controller;
import com.threerings.cocktail.cher.dobj.*;
+import com.threerings.cocktail.party.client.PlaceController;
+import com.threerings.cocktail.party.data.PlaceConfig;
+import com.threerings.cocktail.party.util.PartyContext;
import com.threerings.parlor.Log;
import com.threerings.parlor.data.GameConfig;
@@ -24,7 +27,8 @@ import com.threerings.parlor.util.ParlorContext;
* subscription to the game object and dispatch of commands and
* distributed object events.
*/
-public class GameController extends Controller implements Subscriber
+public abstract class GameController
+ extends PlaceController implements Subscriber
{
/**
* Initializes this game controller with the game configuration that
@@ -33,21 +37,17 @@ public class GameController extends Controller implements Subscriber
* game-specific configuration parameters but they should be sure to
* call super.init in such cases.
*
- * @param gameOid the object id of the game object for the game we are
- * intended to control.
+ * @param ctx the client context.
* @param config the configuration of the game we are intended to
* control.
*/
- public void init (ParlorContext ctx, int gameOid, GameConfig config)
+ public void init (PartyContext ctx, PlaceConfig config)
{
- // keep a reference to our context
- _ctx = ctx;
+ super.init(ctx, config);
- // subscribe to the game object
- _ctx.getDObjectManager().subscribeToObject(gameOid, this);
-
- // keep the config around for later
- _config = config;
+ // cast our references
+ _ctx = (ParlorContext)ctx;
+ _config = (GameConfig)config;
}
/**
@@ -57,21 +57,21 @@ public class GameController extends Controller implements Subscriber
*/
public boolean handleAction (ActionEvent action)
{
- return false;
+ return super.handleAction(action);
}
// documentation inherited
public void objectAvailable (DObject object)
{
- // keep a reference around to the game object
- _gobj = (GameObject)object;
+ Log.warning("Got call to objectAvailable()?! " +
+ "[object=" + object + "].");
}
// documentation inherited
public void requestFailed (int oid, ObjectAccessException cause)
{
- Log.warning("Unable to subscribe to game object!? [oid=" + oid +
- ", cause=" + cause + "].");
+ Log.warning("Got call to requestFailed()?! " +
+ "[oid=" + oid + ", cause=" + cause + "].");
}
// documentation inherited
diff --git a/src/java/com/threerings/parlor/game/GameManager.java b/src/java/com/threerings/parlor/game/GameManager.java
index f8d0466a4..f4fd3f79d 100644
--- a/src/java/com/threerings/parlor/game/GameManager.java
+++ b/src/java/com/threerings/parlor/game/GameManager.java
@@ -1,5 +1,5 @@
//
-// $Id: GameManager.java,v 1.3 2001/10/03 03:44:27 mdb Exp $
+// $Id: GameManager.java,v 1.4 2001/10/06 00:25:29 mdb Exp $
package com.threerings.parlor.server;
@@ -24,27 +24,34 @@ import com.threerings.parlor.data.GameObject;
public class GameManager
extends PlaceManager implements ParlorCodes
{
+ protected Class getPlaceObjectClass ()
+ {
+ return GameObject.class;
+ }
+
+ // documentation inherited
+ protected void didInit ()
+ {
+ super.didInit();
+
+ // cast our configuration object (do we need to do this?)
+ _gconfig = (GameConfig)_config;
+ }
+
/**
* Initializes the game manager with the supplied game configuration
* object. This happens before startup and before the game object has
* been created.
*
- * @param config the game configuration.
* @param players the usernames of all of the players in this game or
* null if the game has no specific set of players.
*/
- public void init (GameConfig config, String[] players)
+ public void setPlayers (String[] players)
{
// keep this info for later
- _config = config;
_players = players;
}
- protected Class getPlaceObjectClass ()
- {
- return GameObject.class;
- }
-
// documentation inherited
protected void didStartup ()
{
@@ -55,7 +62,7 @@ public class GameManager
// we have a specific set of players)
if (_players != null) {
Object[] args = new Object[] {
- new Integer(_gameobj.getOid()), _config };
+ new Integer(_gameobj.getOid()) };
for (int i = 0; i < _players.length; i++) {
BodyObject bobj = PartyServer.lookupBody(_players[i]);
// deliver a game ready notification to the player
@@ -76,7 +83,7 @@ public class GameManager
}
/** A reference to our game configuration. */
- protected GameConfig _config;
+ protected GameConfig _gconfig;
/** The usernames of the players of this game. */
protected String[] _players;
diff --git a/src/java/com/threerings/parlor/server/ParlorManager.java b/src/java/com/threerings/parlor/server/ParlorManager.java
index f7f501d3a..598507e69 100644
--- a/src/java/com/threerings/parlor/server/ParlorManager.java
+++ b/src/java/com/threerings/parlor/server/ParlorManager.java
@@ -1,5 +1,5 @@
//
-// $Id: ParlorManager.java,v 1.5 2001/10/03 03:45:16 mdb Exp $
+// $Id: ParlorManager.java,v 1.6 2001/10/06 00:25:29 mdb Exp $
package com.threerings.parlor.server;
@@ -168,9 +168,6 @@ public class ParlorManager
protected void processAcceptedInvitation (Invitation invite)
{
try {
- Class gmclass =
- Class.forName(invite.config.getManagerClassName());
-
// Log.info("Creating game manager [invite=" + invite +
// ", class=" + gmclass.getName() + "].");
@@ -180,12 +177,12 @@ public class ParlorManager
// started up (which is done by the place registry once the
// game object creation has completed)
GameManager gmgr = (GameManager)
- PartyServer.plreg.createPlace(gmclass);
+ PartyServer.plreg.createPlace(invite.config);
// provide the game manager with some initialization info
String[] players = new String[] {
invite.invitee.username, invite.inviter.username };
- gmgr.init(invite.config, players);
+ gmgr.setPlayers(players);
} catch (Exception e) {
Log.warning("Unable to create game manager [invite=" + invite +
diff --git a/tests/src/java/com/threerings/parlor/TestController.java b/tests/src/java/com/threerings/parlor/TestController.java
index f0041b104..67c00c3a1 100644
--- a/tests/src/java/com/threerings/parlor/TestController.java
+++ b/tests/src/java/com/threerings/parlor/TestController.java
@@ -1,11 +1,16 @@
//
-// $Id: TestController.java,v 1.1 2001/10/03 03:45:44 mdb Exp $
+// $Id: TestController.java,v 1.2 2001/10/06 00:25:29 mdb Exp $
package com.threerings.parlor.test;
+import com.threerings.cocktail.party.client.PlaceView;
import com.threerings.parlor.client.GameController;
public class TestController extends GameController
{
- // nothing doing
+ public PlaceView createPlaceView ()
+ {
+ // nothing doing
+ return null;
+ }
}