Exploratory widening/vararging.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@811 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -22,8 +22,6 @@
|
||||
package com.threerings.whirled.spot.client;
|
||||
|
||||
import com.samskivert.util.ResultListener;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.presents.client.BasicDirector;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.InvocationService.ConfirmListener;
|
||||
@@ -126,8 +124,7 @@ public class SpotSceneDirector extends BasicDirector
|
||||
// look up the destination scene and location
|
||||
SpotScene scene = (SpotScene)_scdir.getScene();
|
||||
if (scene == null) {
|
||||
log.warning("Requested to traverse portal when we have no scene " +
|
||||
"[portalId=" + portalId + "].");
|
||||
log.warning("Requested to traverse portal when we have no scene", "portalId", portalId);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -135,22 +132,22 @@ public class SpotSceneDirector extends BasicDirector
|
||||
int sceneId = _scdir.getScene().getId();
|
||||
int clSceneId = ScenePlace.getSceneId((BodyObject)_ctx.getClient().getClientObject());
|
||||
if (sceneId != clSceneId) {
|
||||
log.warning("Client and server differ in opinion of what scene we're in " +
|
||||
"[sSceneId=" + clSceneId + ", cSceneId=" + sceneId + "].");
|
||||
log.warning("Client and server differ in opinion of what scene we're in",
|
||||
"sSceneId", clSceneId, "cSceneId", sceneId);
|
||||
return false;
|
||||
}
|
||||
|
||||
// find the portal they're talking about
|
||||
Portal dest = scene.getPortal(portalId);
|
||||
if (dest == null) {
|
||||
log.warning("Requested to traverse non-existent portal [portalId=" + portalId +
|
||||
", portals=" + StringUtil.toString(scene.getPortals()) + "].");
|
||||
log.warning("Requested to traverse non-existent portal",
|
||||
"portalId", portalId, "portals", scene.getPortals());
|
||||
return false;
|
||||
}
|
||||
|
||||
// prepare to move to this scene (sets up pending data)
|
||||
if (!_scdir.prepareMoveTo(dest.targetSceneId, rl)) {
|
||||
log.info("Portal traversal vetoed by scene director [portalId=" + portalId + "].");
|
||||
log.info("Portal traversal vetoed by scene director", "portalId", portalId);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -204,8 +201,8 @@ public class SpotSceneDirector extends BasicDirector
|
||||
|
||||
SpotScene scene = (SpotScene)_scdir.getScene();
|
||||
if (scene == null) {
|
||||
log.warning("Requested to change locations, but we're not currently in any scene " +
|
||||
"[loc=" + loc + "].");
|
||||
log.warning("Requested to change locations, but we're not currently in any scene",
|
||||
"loc", loc);
|
||||
if (listener != null) {
|
||||
listener.requestFailed(new Exception("m.cant_get_there"));
|
||||
}
|
||||
@@ -213,7 +210,7 @@ public class SpotSceneDirector extends BasicDirector
|
||||
}
|
||||
|
||||
int sceneId = _scdir.getScene().getId();
|
||||
log.info("Sending changeLocation request [scid=" + sceneId + ", loc=" + loc + "].");
|
||||
log.info("Sending changeLocation request", "scid", sceneId, "loc", loc);
|
||||
|
||||
_pendingLoc = (Location)loc.clone();
|
||||
ConfirmListener clist = new ConfirmListener() {
|
||||
@@ -247,15 +244,15 @@ public class SpotSceneDirector extends BasicDirector
|
||||
{
|
||||
SpotScene scene = (SpotScene)_scdir.getScene();
|
||||
if (scene == null) {
|
||||
log.warning("Requested to join cluster, but we're not currently in any scene " +
|
||||
"[froid=" + froid + "].");
|
||||
log.warning("Requested to join cluster, but we're not currently in any scene",
|
||||
"froid", froid);
|
||||
if (listener != null) {
|
||||
listener.requestFailed(new Exception("m.cant_get_there"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("Joining cluster [friend=" + froid + "].");
|
||||
log.info("Joining cluster", "friend", froid);
|
||||
|
||||
_sservice.joinCluster(_ctx.getClient(), froid, new ConfirmListener() {
|
||||
public void requestProcessed () {
|
||||
@@ -295,15 +292,15 @@ public class SpotSceneDirector extends BasicDirector
|
||||
// make sure we're currently in a scene
|
||||
SpotScene scene = (SpotScene)_scdir.getScene();
|
||||
if (scene == null) {
|
||||
log.warning("Requested to speak to cluster, but we're not currently in any scene " +
|
||||
"[message=" + message + "].");
|
||||
log.warning("Requested to speak to cluster, but we're not currently in any scene",
|
||||
"message", message);
|
||||
return false;
|
||||
}
|
||||
|
||||
// make sure we're part of a cluster
|
||||
if (_self.getClusterOid() <= 0) {
|
||||
log.info("Ignoring cluster speak as we're not in a cluster " +
|
||||
"[cloid=" + _self.getClusterOid() + "].");
|
||||
log.info("Ignoring cluster speak as we're not in a cluster",
|
||||
"cloid", _self.getClusterOid());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -335,8 +332,7 @@ public class SpotSceneDirector extends BasicDirector
|
||||
// documentation inherited from interface
|
||||
public void requestFailed (int oid, ObjectAccessException cause)
|
||||
{
|
||||
log.warning("Unable to subscribe to cluster chat object [oid=" + oid +
|
||||
", cause=" + cause + "].");
|
||||
log.warning("Unable to subscribe to cluster chat object", "oid", oid, "cause", cause);
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
|
||||
@@ -24,14 +24,13 @@ package com.threerings.whirled.spot.data;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Makes available the spot scene information that the server needs to do
|
||||
* its business.
|
||||
* Makes available the spot scene information that the server needs to do its business.
|
||||
*/
|
||||
public interface SpotScene
|
||||
{
|
||||
/**
|
||||
* Returns a {@link Portal} object for the portal with the specified
|
||||
* id or null if no portal exists with that id.
|
||||
* Returns a {@link Portal} object for the portal with the specified id or null if no portal
|
||||
* exists with that id.
|
||||
*/
|
||||
public Portal getPortal (int portalId);
|
||||
|
||||
@@ -46,24 +45,21 @@ public interface SpotScene
|
||||
public Iterator<Portal> getPortals ();
|
||||
|
||||
/**
|
||||
* Returns the portal id that should be assigned to the next portal
|
||||
* added to this scene.
|
||||
* Returns the portal id that should be assigned to the next portal added to this scene.
|
||||
*/
|
||||
public short getNextPortalId ();
|
||||
|
||||
/**
|
||||
* Returns the portal that represents the default entrance to this
|
||||
* scene. If a body enters the scene at logon time rather than
|
||||
* entering from some other scene, this is the portal at which they
|
||||
* would appear.
|
||||
* Returns the portal that represents the default entrance to this scene. If a body enters the
|
||||
* scene at logon time rather than entering from some other scene, this is the portal at which
|
||||
* they would appear.
|
||||
*/
|
||||
public Portal getDefaultEntrance ();
|
||||
|
||||
/**
|
||||
* Adds a portal to this scene, immediately making the requisite
|
||||
* modifications to the underlying scene model. The portal id should
|
||||
* have already been assigned using the value obtained from {@link
|
||||
* #getNextPortalId}.
|
||||
* Adds a portal to this scene, immediately making the requisite modifications to the
|
||||
* underlying scene model. The portal id should have already been assigned using the value
|
||||
* obtained from {@link #getNextPortalId}.
|
||||
*/
|
||||
public void addPortal (Portal portal);
|
||||
|
||||
@@ -73,8 +69,8 @@ public interface SpotScene
|
||||
public void removePortal (Portal portal);
|
||||
|
||||
/**
|
||||
* Sets the default entrance in this scene, immediately making the
|
||||
* requisite modifications to the underlying scene model.
|
||||
* Sets the default entrance in this scene, immediately making the requisite modifications to
|
||||
* the underlying scene model.
|
||||
*/
|
||||
public void setDefaultEntrance (Portal portal);
|
||||
}
|
||||
|
||||
@@ -34,8 +34,7 @@ public class SpotSceneImpl
|
||||
implements SpotScene
|
||||
{
|
||||
/**
|
||||
* Creates an instance that will obtain data from the supplied spot
|
||||
* scene model.
|
||||
* Creates an instance that will obtain data from the supplied spot scene model.
|
||||
*/
|
||||
public SpotSceneImpl (SpotSceneModel smodel)
|
||||
{
|
||||
@@ -46,8 +45,7 @@ public class SpotSceneImpl
|
||||
protected void readPortals ()
|
||||
{
|
||||
_portals.clear();
|
||||
for (int ii = 0, ll = _smodel.portals.length; ii < ll; ii++) {
|
||||
Portal port = _smodel.portals[ii];
|
||||
for (Portal port : _smodel.portals) {
|
||||
_portals.put(port.portalId, port);
|
||||
}
|
||||
}
|
||||
@@ -103,8 +101,7 @@ public class SpotSceneImpl
|
||||
public void addPortal (Portal portal)
|
||||
{
|
||||
if (portal.portalId <= 0) {
|
||||
log.warning("Refusing to add zero-id portal " +
|
||||
"[scene=" + this + ", portal=" + portal + "].");
|
||||
log.warning("Refusing to add zero-id portal", "scene", this, "portal", portal);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -140,8 +137,8 @@ public class SpotSceneImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be called if a scene update was received that caused
|
||||
* our underlying scene model to change.
|
||||
* This should be called if a scene update was received that caused our underlying scene model
|
||||
* to change.
|
||||
*/
|
||||
public void updateReceived ()
|
||||
{
|
||||
@@ -154,7 +151,7 @@ public class SpotSceneImpl
|
||||
/** A mapping from portal id to portal. */
|
||||
protected HashIntMap<Portal> _portals = new HashIntMap<Portal>();
|
||||
|
||||
/** We don't allow more than ~32k portals in a scene. Things would
|
||||
* slow down *way* before we got there. */
|
||||
/** We don't allow more than ~32k portals in a scene. Things would slow down *way* before we
|
||||
* got there. */
|
||||
protected static final int MAX_PORTAL_ID = Short.MAX_VALUE;
|
||||
}
|
||||
|
||||
@@ -30,10 +30,9 @@ import com.threerings.whirled.data.AuxModel;
|
||||
import com.threerings.whirled.data.SceneModel;
|
||||
|
||||
/**
|
||||
* The spot scene model extends the standard scene model with information
|
||||
* on portals. Portals are referenced by an identifier, unique within the
|
||||
* scene and unchanging, so that portals can stably reference the target
|
||||
* portal in the scene to which they connect.
|
||||
* The spot scene model extends the standard scene model with information on portals. Portals are
|
||||
* referenced by an identifier, unique within the scene and unchanging, so that portals can stably
|
||||
* reference the target portal in the scene to which they connect.
|
||||
*/
|
||||
public class SpotSceneModel extends SimpleStreamableObject
|
||||
implements AuxModel
|
||||
@@ -41,9 +40,8 @@ public class SpotSceneModel extends SimpleStreamableObject
|
||||
/** An array containing all portals in this scene. */
|
||||
public Portal[] portals = new Portal[0];
|
||||
|
||||
/** The portal id of the default entrance to this scene. If a body
|
||||
* enters the scene without coming from another scene, this is the
|
||||
* portal at which they would appear. */
|
||||
/** The portal id of the default entrance to this scene. If a body enters the scene without
|
||||
* coming from another scene, this is the portal at which they would appear. */
|
||||
public int defaultEntranceId = -1;
|
||||
|
||||
/**
|
||||
@@ -79,16 +77,15 @@ public class SpotSceneModel extends SimpleStreamableObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates and returns the {@link SpotSceneModel} among the auxiliary
|
||||
* scene models associated with the supplied scene
|
||||
* model. <code>null</code> is returned if no spot scene model could
|
||||
* Locates and returns the {@link SpotSceneModel} among the auxiliary scene models associated
|
||||
* with the supplied scene model. <code>null</code> is returned if no spot scene model could
|
||||
* be found.
|
||||
*/
|
||||
public static SpotSceneModel getSceneModel (SceneModel model)
|
||||
{
|
||||
for (int ii = 0; ii < model.auxModels.length; ii++) {
|
||||
if (model.auxModels[ii] instanceof SpotSceneModel) {
|
||||
return (SpotSceneModel)model.auxModels[ii];
|
||||
for (AuxModel auxModel : model.auxModels) {
|
||||
if (auxModel instanceof SpotSceneModel) {
|
||||
return (SpotSceneModel)auxModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -24,10 +24,9 @@ package com.threerings.whirled.spot.server;
|
||||
import com.threerings.whirled.server.WhirledSession;
|
||||
|
||||
/**
|
||||
* Extends the Whirled client and handles the necessary notifications that
|
||||
* take place when a user logs off to let the clients displaying the scene
|
||||
* they were occupying know that they didn't exit via a portal, but
|
||||
* instead just disappeared.
|
||||
* Extends the Whirled client and handles the necessary notifications that take place when a user
|
||||
* logs off to let the clients displaying the scene they were occupying know that they didn't exit
|
||||
* via a portal, but instead just disappeared.
|
||||
*/
|
||||
public class SpotClient extends WhirledSession
|
||||
{
|
||||
|
||||
@@ -147,8 +147,7 @@ public class SpotSceneManager extends SceneManager
|
||||
while (cliter.hasNext()) {
|
||||
ClusterRecord clrec = cliter.next();
|
||||
if (clrec.containsKey(bodyOid)) {
|
||||
log.info("Pruning departed body from cluster [boid=" + bodyOid +
|
||||
", cluster=" + clrec + "].");
|
||||
log.info("Pruning departed body from cluster", "boid", bodyOid, "cluster", clrec);
|
||||
clrec.removeBody(bodyOid);
|
||||
if (clrec.size() == 0) {
|
||||
// if we just removed the last body, destroy the cluster, need to use the
|
||||
@@ -180,16 +179,15 @@ public class SpotSceneManager extends SceneManager
|
||||
if (from != null && from.targetPortalId != -1) {
|
||||
entry = _sscene.getPortal(from.targetPortalId);
|
||||
if (entry == null) {
|
||||
log.warning("Body mapped at invalid portal [where=" + where() +
|
||||
", who=" + body.who() + ", from=" + from + "].");
|
||||
log.warning("Body mapped at invalid portal",
|
||||
"where", where(), "who", body.who(), "from", from);
|
||||
entry = _sscene.getDefaultEntrance();
|
||||
}
|
||||
} else {
|
||||
entry = _sscene.getDefaultEntrance();
|
||||
}
|
||||
|
||||
// Log.debug("Positioning entering body [who=" + body.who() +
|
||||
// ", where=" + entry.getOppLocation() + "].");
|
||||
// log.debug("Positioning entering body", "who", body.who(), "where", entry.getOppLocation());
|
||||
|
||||
// create a scene location for them located on the entrance portal but facing the opposite
|
||||
// direction
|
||||
@@ -216,8 +214,8 @@ public class SpotSceneManager extends SceneManager
|
||||
{
|
||||
SpotScene scene = (SpotScene)getScene();
|
||||
if (scene == null) {
|
||||
log.warning("No scene in moveBodyToDefaultPortal()? [who=" + body.who() +
|
||||
", where=" + where() + "].");
|
||||
log.warning("No scene in moveBodyToDefaultPortal()?",
|
||||
"who", body.who(), "where", where());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -225,8 +223,8 @@ public class SpotSceneManager extends SceneManager
|
||||
Location eloc = scene.getDefaultEntrance().getLocation();
|
||||
handleChangeLoc(body, eloc);
|
||||
} catch (InvocationException ie) {
|
||||
log.warning("Could not move user to default portal [where=" + where() +
|
||||
", who=" + body.who() + ", error=" + ie + "].");
|
||||
log.warning("Could not move user to default portal",
|
||||
"where", where(), "who", body.who(), "error", ie);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,8 +243,8 @@ public class SpotSceneManager extends SceneManager
|
||||
{
|
||||
// make sure they are in our scene
|
||||
if (!_ssobj.occupants.contains(source.getOid())) {
|
||||
log.warning("Refusing change loc from non-scene occupant [where=" + where() +
|
||||
", who=" + source.who() + ", loc=" + loc + "].");
|
||||
log.warning("Refusing change loc from non-scene occupant",
|
||||
"where", where(), "who", source.who(), "loc", loc);
|
||||
throw new InvocationException(INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
@@ -281,8 +279,8 @@ public class SpotSceneManager extends SceneManager
|
||||
SceneLocation sloc = new SceneLocation(loc, source.getOid());
|
||||
if (!_ssobj.occupantLocs.contains(sloc)) {
|
||||
// complain if they don't already have a location configured
|
||||
log.warning("Changing loc for occupant without previous loc [where=" + where() +
|
||||
", who=" + source.who() + ", nloc=" + loc + "].", new Exception());
|
||||
log.warning("Changing loc for occupant without previous loc",
|
||||
"where", where(), "who", source.who(), "nloc", loc, new Exception());
|
||||
_ssobj.addToOccupantLocs(sloc);
|
||||
} else {
|
||||
_ssobj.updateOccupantLocs(sloc);
|
||||
@@ -313,17 +311,17 @@ public class SpotSceneManager extends SceneManager
|
||||
// otherwise see if they sent us the user's oid
|
||||
DObject tobj = _omgr.getObject(targetOid);
|
||||
if (!(tobj instanceof BodyObject)) {
|
||||
log.info("Can't join cluster, missing target [creator=" + joiner.who() +
|
||||
", targetOid=" + targetOid + "].");
|
||||
log.info("Can't join cluster, missing target",
|
||||
"creator", joiner.who(), "targetOid", targetOid);
|
||||
throw new InvocationException(NO_SUCH_CLUSTER);
|
||||
}
|
||||
|
||||
// make sure we're in the same scene as said user
|
||||
BodyObject friend = (BodyObject)tobj;
|
||||
if (friend.getPlaceOid() != joiner.getPlaceOid()) {
|
||||
log.info("Refusing cluster join from non-proximate user [joiner=" + joiner.who() +
|
||||
", jloc=" + joiner.location + ", target=" + friend.who() +
|
||||
", tloc=" + friend.location + "].");
|
||||
log.info("Refusing cluster join from non-proximate user",
|
||||
"joiner", joiner.who(), "jloc", joiner.location, "target", friend.who(),
|
||||
"tloc", friend.location);
|
||||
throw new InvocationException(NO_SUCH_CLUSTER);
|
||||
}
|
||||
|
||||
@@ -338,7 +336,7 @@ public class SpotSceneManager extends SceneManager
|
||||
checkCanCluster(joiner, friend);
|
||||
|
||||
// otherwise we create a new cluster and add our charter members!
|
||||
// Log.debug("Creating cluster [starter=" + joiner.who() + ", tgt=" + friend.who() + "].");
|
||||
// log.debug("Creating cluster", "starter", joiner.who(), "tgt", friend.who());
|
||||
clrec = createClusterRecord();
|
||||
clrec.addBody(friend);
|
||||
clrec.addBody(joiner);
|
||||
@@ -395,8 +393,8 @@ public class SpotSceneManager extends SceneManager
|
||||
* Called by the {@link SpotProvider} when we receive a cluster speak request.
|
||||
*/
|
||||
@Deprecated
|
||||
protected void handleClusterSpeakRequest (int sourceOid, Name source, String bundle,
|
||||
String message, byte mode)
|
||||
protected void handleClusterSpeakRequest (
|
||||
int sourceOid, Name source, String bundle, String message, byte mode)
|
||||
{
|
||||
handleClusterMessageRequest(sourceOid, new UserMessage(source, bundle, message, mode));
|
||||
}
|
||||
@@ -408,9 +406,9 @@ public class SpotSceneManager extends SceneManager
|
||||
{
|
||||
ClusterRecord clrec = getCluster(sourceOid);
|
||||
if (clrec == null) {
|
||||
log.warning("Non-clustered user requested cluster speak [where=" + where() +
|
||||
", chatter=" + message.speaker + " (" + sourceOid + "), " +
|
||||
"msg=" + message + "].");
|
||||
log.warning("Non-clustered user requested cluster speak",
|
||||
"where", where(), "chatter", (message.speaker + " (" + sourceOid + ")"),
|
||||
"msg", message);
|
||||
} else {
|
||||
SpeakUtil.sendMessage(clrec.getClusterObject(), message);
|
||||
}
|
||||
@@ -473,8 +471,8 @@ public class SpotSceneManager extends SceneManager
|
||||
throws InvocationException
|
||||
{
|
||||
if (!(body instanceof ClusteredBodyObject)) {
|
||||
log.warning("Refusing to add non-clustered body to cluster [cloid=" +
|
||||
_clobj.getOid() + ", size=" + size() + ", who=" + body.who() + "].");
|
||||
log.warning("Refusing to add non-clustered body to cluster",
|
||||
"cloid", _clobj.getOid(), "size", size(), "who", body.who());
|
||||
throw new InvocationException(INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
@@ -511,7 +509,7 @@ public class SpotSceneManager extends SceneManager
|
||||
_ssobj.commitTransaction();
|
||||
}
|
||||
|
||||
// Log.debug("Added " + body.who() + " to "+ this + ".");
|
||||
// log.debug("Added " + body.who() + " to "+ this + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -519,8 +517,8 @@ public class SpotSceneManager extends SceneManager
|
||||
{
|
||||
BodyObject body = (BodyObject)remove(bodyOid);
|
||||
if (body == null) {
|
||||
log.warning("Requested to remove unknown body from cluster [cloid=" +
|
||||
_clobj.getOid() + ", size=" + size() + ", who=" + bodyOid + "].");
|
||||
log.warning("Requested to remove unknown body from cluster",
|
||||
"cloid", _clobj.getOid(), "size", size(), "who", bodyOid);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -547,7 +545,7 @@ public class SpotSceneManager extends SceneManager
|
||||
}
|
||||
}
|
||||
|
||||
// Log.debug("Removed " + bodyOid + " from "+ this + ".");
|
||||
// log.debug("Removed " + bodyOid + " from "+ this + ".");
|
||||
|
||||
}
|
||||
|
||||
@@ -569,7 +567,7 @@ public class SpotSceneManager extends SceneManager
|
||||
|
||||
protected void destroy (boolean doRemoval)
|
||||
{
|
||||
// Log.debug("Cluster empty, going away [cloid=" + _clobj.getOid() + "].");
|
||||
// log.debug("Cluster empty, going away", "cloid", _clobj.getOid());
|
||||
_ssobj.removeFromClusters(_cluster.getKey());
|
||||
|
||||
// if we've also been requested to remove ourself from the clusters list, do that
|
||||
@@ -593,5 +591,5 @@ public class SpotSceneManager extends SceneManager
|
||||
protected HashIntMap<ClusterRecord> _clusters = new HashIntMap<ClusterRecord>();
|
||||
|
||||
/** A mapping of entering bodies to portal ids. */
|
||||
protected HashMap<Integer,Portal> _enterers = new HashMap<Integer,Portal>();
|
||||
protected HashMap<Integer, Portal> _enterers = new HashMap<Integer, Portal>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user