diff --git a/src/java/com/threerings/crowd/server/LocationProvider.java b/src/java/com/threerings/crowd/server/LocationProvider.java index 148f47a80..8a3462fd1 100644 --- a/src/java/com/threerings/crowd/server/LocationProvider.java +++ b/src/java/com/threerings/crowd/server/LocationProvider.java @@ -1,11 +1,12 @@ // -// $Id: LocationProvider.java,v 1.3 2001/08/11 00:05:58 mdb Exp $ +// $Id: LocationProvider.java,v 1.4 2001/08/11 00:22:55 mdb Exp $ package com.threerings.cocktail.party.server; import com.threerings.cocktail.cher.dobj.DObject; import com.threerings.cocktail.cher.server.CherServer; import com.threerings.cocktail.cher.server.InvocationProvider; +import com.threerings.cocktail.cher.util.Codes; import com.threerings.cocktail.party.Log; import com.threerings.cocktail.party.data.*; @@ -20,14 +21,33 @@ public class LocationProvider extends InvocationProvider */ public void handleMoveToRequest (BodyObject source, int invid, int placeId) + { + // try to do the actual move + String rcode = moveTo(source, placeId); + + // send the response + if (rcode.equals(Codes.SUCCESS)) { + sendResponse(source, invid, "MoveSucceeded"); + } else { + sendResponse(source, invid, "MoveFailed", rcode); + } + } + + /** + * Moves the specified body from whatever location they currently + * occupy to the location identified by the supplied place id. + * + * @return the string Codes.SUCCESS if the move was + * successful or a reason code for failure if not. + */ + public static String moveTo (BodyObject source, int placeId) { // make sure the place in question actually exists DObject pobj = CherServer.omgr.getObject(placeId); if (pobj == null || !(pobj instanceof PlaceObject)) { Log.info("Requested to move to non-existent place " + "[source=" + source + ", place=" + placeId + "]."); - sendResponse(source, invid, "MoveFailed", "m.no_such_place"); - return; + return "m.no_such_place"; } // acquire a lock on the body object to ensure that rapid fire @@ -35,8 +55,7 @@ public class LocationProvider extends InvocationProvider if (!source.acquireLock("moveToLock")) { // if we're still locked, a previous moveTo request hasn't // been fully processed - sendResponse(source, invid, "MoveFailed", "m.move_in_progress"); - return; + return "m.move_in_progress"; } // find out if they were previously in some other location @@ -66,7 +85,6 @@ public class LocationProvider extends InvocationProvider // once all these events are processed source.releaseLock("moveToLock"); - // send the response - sendResponse(source, invid, "MoveSucceeded"); + return Codes.SUCCESS; } }