From aeab40a4115705e03e897cb4d2b056ac37f11a8f Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Sat, 14 Dec 2002 01:51:00 +0000 Subject: [PATCH] Let's be using the same code to enter a scene. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2067 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../whirled/server/SceneProvider.java | 51 +++++++++++-------- .../whirled/spot/server/SpotProvider.java | 25 ++------- 2 files changed, 35 insertions(+), 41 deletions(-) diff --git a/src/java/com/threerings/whirled/server/SceneProvider.java b/src/java/com/threerings/whirled/server/SceneProvider.java index dc9b49c42..4caac7d2a 100644 --- a/src/java/com/threerings/whirled/server/SceneProvider.java +++ b/src/java/com/threerings/whirled/server/SceneProvider.java @@ -1,5 +1,5 @@ // -// $Id: SceneProvider.java,v 1.13 2002/12/03 06:58:57 mdb Exp $ +// $Id: SceneProvider.java,v 1.14 2002/12/14 01:51:00 mdb Exp $ package com.threerings.whirled.server; @@ -76,31 +76,42 @@ public class SceneProvider BodyObject source, SceneManager scmgr, int sceneVersion, SceneMoveListener listener) { - // move to the place object associated with this scene - PlaceObject plobj = scmgr.getPlaceObject(); - int ploid = plobj.getOid(); - try { - // try doing the actual move - PlaceConfig config = _locprov.moveTo(source, ploid); - - // now that we've finally moved, we can update the user object - // with the new scene id - ((ScenedBodyObject)source).setSceneId(scmgr.getScene().getId()); - - // check to see if they need a newer version of the scene data - SceneModel model = scmgr.getSceneModel(); - if (sceneVersion < model.version) { - listener.moveSucceededPlusUpdate(ploid, config, model); - } else { - listener.moveSucceeded(ploid, config); - } - + effectSceneMove(source, scmgr, sceneVersion, listener); } catch (InvocationException sfe) { listener.requestFailed(sfe.getMessage()); } } + /** + * Moves the supplied body into the supplied (already resolved) scene + * and informs the supplied listener if the move is successfuly. + * + * @exception InvocationException thrown if a failure occurs + * attempting to move the user into the place associated with the + * scene. + */ + public void effectSceneMove (BodyObject source, SceneManager scmgr, + int sceneVersion, SceneMoveListener listener) + throws InvocationException + { + // move to the place object associated with this scene + int ploid = scmgr.getPlaceObject().getOid(); + PlaceConfig config = _locprov.moveTo(source, ploid); + + // now that we've finally moved, we can update the user object + // with the new scene id + ((ScenedBodyObject)source).setSceneId(scmgr.getScene().getId()); + + // check to see if they need a newer version of the scene data + SceneModel model = scmgr.getSceneModel(); + if (sceneVersion < model.version) { + listener.moveSucceededPlusUpdate(ploid, config, model); + } else { + listener.moveSucceeded(ploid, config); + } + } + /** * Ejects the specified body from their current scene and sends them a * request to move to the specified new scene. This is the diff --git a/src/java/com/threerings/whirled/spot/server/SpotProvider.java b/src/java/com/threerings/whirled/spot/server/SpotProvider.java index 6ea8a4ba5..1856a7e3f 100644 --- a/src/java/com/threerings/whirled/spot/server/SpotProvider.java +++ b/src/java/com/threerings/whirled/spot/server/SpotProvider.java @@ -1,5 +1,5 @@ // -// $Id: SpotProvider.java,v 1.13 2002/08/14 19:07:58 mdb Exp $ +// $Id: SpotProvider.java,v 1.14 2002/12/14 01:51:00 mdb Exp $ package com.threerings.whirled.spot.server; @@ -122,32 +122,15 @@ public class SpotProvider BodyObject source, SpotSceneManager scmgr, int sceneVer, int exitPortalId, int destLocId, SceneMoveListener listener) { - // move to the place object associated with this scene - PlaceObject plobj = scmgr.getPlaceObject(); - int ploid = plobj.getOid(); - int bodyOid = source.getOid(); - // let the destination scene manager know that we're coming in + int bodyOid = source.getOid(); scmgr.mapEnteringBody(bodyOid, destLocId); try { - // try doing the actual move - PlaceConfig config = _plreg.locprov.moveTo(source, ploid); - - // check to see if they need a newer version of the scene data - SceneModel model = scmgr.getSceneModel(); - if (sceneVer < model.version) { - // then send the moveTo response - listener.moveSucceededPlusUpdate(ploid, config, model); - - } else { - // then send the moveTo response - listener.moveSucceeded(ploid, config); - } - + // move to the place object associated with this scene + _screg.sceneprov.effectSceneMove(source, scmgr, sceneVer, listener); } catch (InvocationException sfe) { listener.requestFailed(sfe.getMessage()); - // and let the destination scene manager know that we're no // longer coming in scmgr.clearEnteringBody(bodyOid);