diff --git a/src/java/com/threerings/crowd/server/BodyLocal.java b/src/java/com/threerings/crowd/server/BodyLocal.java index 27973da21..44ffab8d1 100644 --- a/src/java/com/threerings/crowd/server/BodyLocal.java +++ b/src/java/com/threerings/crowd/server/BodyLocal.java @@ -32,7 +32,6 @@ public class BodyLocal extends ClientLocal { /** * The time at which the {@link BodyObject#status} field was last updated. - * This is only available on the server. */ public long statusTime; } diff --git a/src/java/com/threerings/crowd/server/LocationManager.java b/src/java/com/threerings/crowd/server/LocationManager.java index 12f1239d8..e283f83d9 100644 --- a/src/java/com/threerings/crowd/server/LocationManager.java +++ b/src/java/com/threerings/crowd/server/LocationManager.java @@ -115,28 +115,19 @@ public class LocationManager } try { - PlaceObject plobj = pmgr.getPlaceObject(); - - // the doubly nested try catch is to prevent failure if one or the other of the - // transactions fails to start - plobj.startTransaction(); + source.startTransaction(); try { - source.startTransaction(); - try { - // remove them from any previous location - leaveOccupiedPlace(source); + // remove them from any previous location + leaveOccupiedPlace(source); - // let the place manager know that we're coming in - pmgr.bodyWillEnter(source); + // let the place manager know that we're coming in + pmgr.bodyWillEnter(source); - // let the body object know that it's going in - source.willEnterPlace(place, plobj); + // let the body object know that it's going in + source.willEnterPlace(place, pmgr.getPlaceObject()); - } finally { - source.commitTransaction(); - } } finally { - plobj.commitTransaction(); + source.commitTransaction(); } } finally { @@ -154,42 +145,22 @@ public class LocationManager public void leaveOccupiedPlace (BodyObject source) { Place oldloc = source.location; - int bodoid = source.getOid(); - - // nothing to do if they weren't previously in some location if (oldloc == null) { + return; // nothing to do if they weren't previously in some location + } + + PlaceManager pmgr = _plreg.getPlaceManager(oldloc.placeOid); + if (pmgr == null) { + log.warning("Body requested to leave no longer existent place?", + "boid", source.getOid(), "place", oldloc); return; } - // remove them from the occupant list - PlaceObject plobj = null; - try { - plobj = (PlaceObject)_omgr.getObject(oldloc.placeOid); - if (plobj != null) { - Integer key = Integer.valueOf(bodoid); - plobj.startTransaction(); - try { - // remove their occupant info (which is keyed on oid) - plobj.removeFromOccupantInfo(key); - // and remove them from the occupant list - plobj.removeFromOccupants(bodoid); - - } finally { - plobj.commitTransaction(); - } - - } else { - log.info("Body's prior location no longer around? [boid=" + bodoid + - ", place=" + oldloc + "]."); - } - - } catch (ClassCastException cce) { - log.warning("Body claims to occupy non-PlaceObject!? [boid=" + bodoid + - ", place=" + oldloc + ", error=" + cce + "]."); - } + // tell the place manager that they're on the way out + pmgr.bodyWillLeave(source); // clear out their location - source.didLeavePlace(plobj); + source.didLeavePlace(pmgr.getPlaceObject()); } /** diff --git a/src/java/com/threerings/crowd/server/PlaceManager.java b/src/java/com/threerings/crowd/server/PlaceManager.java index 4c04c0394..5574604d2 100644 --- a/src/java/com/threerings/crowd/server/PlaceManager.java +++ b/src/java/com/threerings/crowd/server/PlaceManager.java @@ -312,7 +312,10 @@ public class PlaceManager } /** - * This is called to inform the manager that a body is on the way in. + * This is called to inform the manager that a body is on the way in. This is called at the + * very beginning of the entry process before the client is informed that it is allowed to + * enter. This will be followed by a call to {@link #bodyEntered} once all events relating to + * body entry have been processed. */ public void bodyWillEnter (BodyObject body) { @@ -328,6 +331,23 @@ public class PlaceManager } } + /** + * Called to inform a manager that a body is about to leave this place. This will be followed + * by a call to {@link #bodyLeft} once all events relating to body entry have been processed. + */ + public void bodyWillLeave (BodyObject body) + { + _plobj.startTransaction(); + try { + // remove their occupant info (which is keyed on oid) + _plobj.removeFromOccupantInfo(body.getOid()); + // and remove them from the occupant list + _plobj.removeFromOccupants(body.getOid()); + } finally { + _plobj.commitTransaction(); + } + } + /** * Registers a particular message handler instance to be used when processing message events * with the specified name.