Use the new method on BodyLocator to translate ClientObjects into BodyObjects.

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@1021 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Par Winzell
2010-11-29 21:11:47 +00:00
parent fe560b0dfd
commit d03e77beb7
3 changed files with 15 additions and 8 deletions
@@ -39,6 +39,7 @@ import com.threerings.presents.server.InvocationManager;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.PlaceConfig; import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.server.BodyLocator;
import com.threerings.crowd.server.LocationManager; import com.threerings.crowd.server.LocationManager;
import com.threerings.crowd.server.LocationProvider; import com.threerings.crowd.server.LocationProvider;
import com.threerings.crowd.server.PlaceManager; import com.threerings.crowd.server.PlaceManager;
@@ -189,7 +190,7 @@ public class SceneRegistry
public void moveTo (ClientObject caller, int sceneId, int sceneVer, public void moveTo (ClientObject caller, int sceneId, int sceneVer,
SceneService.SceneMoveListener listener) SceneService.SceneMoveListener listener)
{ {
BodyObject body = (BodyObject)caller; BodyObject body = _locator.forClient(caller);
resolveScene(sceneId, new SceneMoveHandler(_locman, body, sceneVer, listener)); resolveScene(sceneId, new SceneMoveHandler(_locman, body, sceneVer, listener));
} }
@@ -339,6 +340,9 @@ public class SceneRegistry
/** The invoker on which we do database operations. */ /** The invoker on which we do database operations. */
@Inject protected @MainInvoker Invoker _invoker; @Inject protected @MainInvoker Invoker _invoker;
/** Used to translate ClientObjects into BodyObjects. */
@Inject protected BodyLocator _locator;
/** Provides access to place managers. */ /** Provides access to place managers. */
@Inject protected PlaceRegistry _plreg; @Inject protected PlaceRegistry _plreg;
@@ -116,7 +116,7 @@ public class SpotSceneRegistry extends SceneRegistry
throws InvocationException throws InvocationException
{ {
// le sanity check // le sanity check
BodyObject body = (BodyObject)caller; BodyObject body = _locator.forClient(caller);
int cSceneId = ScenePlace.getSceneId(body); int cSceneId = ScenePlace.getSceneId(body);
if (cSceneId != sceneId) { if (cSceneId != sceneId) {
log.info("Ignoring stale traverse portal request", log.info("Ignoring stale traverse portal request",
@@ -162,7 +162,7 @@ public class SpotSceneRegistry extends SceneRegistry
SpotService.ConfirmListener listener) SpotService.ConfirmListener listener)
throws InvocationException throws InvocationException
{ {
BodyObject source = (BodyObject)caller; BodyObject source = _locator.forClient(caller);
int cSceneId = ScenePlace.getSceneId(source); int cSceneId = ScenePlace.getSceneId(source);
if (cSceneId != sceneId) { if (cSceneId != sceneId) {
log.info("Rejecting changeLocation for invalid scene", log.info("Rejecting changeLocation for invalid scene",
@@ -190,7 +190,7 @@ public class SpotSceneRegistry extends SceneRegistry
SpotService.ConfirmListener listener) SpotService.ConfirmListener listener)
throws InvocationException throws InvocationException
{ {
BodyObject source = (BodyObject)caller; BodyObject source = _locator.forClient(caller);
int sceneId = ScenePlace.getSceneId(source); int sceneId = ScenePlace.getSceneId(source);
// look up the scene manager for the specified scene // look up the scene manager for the specified scene
@@ -212,7 +212,7 @@ public class SpotSceneRegistry extends SceneRegistry
public void clusterSpeak (ClientObject caller, String message, byte mode) public void clusterSpeak (ClientObject caller, String message, byte mode)
{ {
// ensure the caller has normal chat access // ensure the caller has normal chat access
BodyObject source = (BodyObject)caller; BodyObject source = _locator.forClient(caller);
String errmsg = source.checkAccess(ChatCodes.CHAT_ACCESS, null); String errmsg = source.checkAccess(ChatCodes.CHAT_ACCESS, null);
if (errmsg != null) { if (errmsg != null) {
SpeakUtil.sendFeedback(source, MessageManager.GLOBAL_BUNDLE, errmsg); SpeakUtil.sendFeedback(source, MessageManager.GLOBAL_BUNDLE, errmsg);
@@ -32,6 +32,7 @@ import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationManager; import com.threerings.presents.server.InvocationManager;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.server.BodyLocator;
import com.threerings.crowd.server.LocationManager; import com.threerings.crowd.server.LocationManager;
import com.threerings.crowd.server.LocationProvider; import com.threerings.crowd.server.LocationProvider;
@@ -152,7 +153,7 @@ public class ZoneRegistry
// look up the caller's current zone id and make sure it is happy about their departure // look up the caller's current zone id and make sure it is happy about their departure
// from the current zone // from the current zone
BodyObject body = (BodyObject)caller; BodyObject body = _locator.forClient(caller);
ZoneManager ozmgr = getZoneManager(((ZonedBodyObject)caller).getZoneId()); ZoneManager ozmgr = getZoneManager(((ZonedBodyObject)caller).getZoneId());
if (ozmgr != null) { if (ozmgr != null) {
String msg = ozmgr.ratifyBodyExit(body); String msg = ozmgr.ratifyBodyExit(body);
@@ -170,8 +171,7 @@ public class ZoneRegistry
} }
// resolve the zone and move the user // resolve the zone and move the user
zmgr.resolveZone(zoneId, createZoneMoveHandler( zmgr.resolveZone(zoneId, createZoneMoveHandler(zmgr, body, sceneId, sceneVer, listener));
zmgr, (BodyObject)caller, sceneId, sceneVer, listener));
} }
/** /**
@@ -192,4 +192,7 @@ public class ZoneRegistry
/** Provides location services. */ /** Provides location services. */
@Inject protected LocationManager _locman; @Inject protected LocationManager _locman;
/** Used to translate ClientObjects into BodyObjects. */
@Inject protected BodyLocator _locator;
} }