Finished up handling of bodies moving from place to place. Added callback
methods into PlaceManager that can be overridden to do things when bodies enter or leave a place. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@175 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: LocationProvider.java,v 1.1 2001/07/23 21:14:27 mdb Exp $
|
||||
// $Id: LocationProvider.java,v 1.2 2001/08/04 01:13:36 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.party.server;
|
||||
|
||||
@@ -28,9 +28,41 @@ public class LocationProvider extends InvocationProvider
|
||||
return createResponse("MoveFailed", "m.no_such_place");
|
||||
}
|
||||
|
||||
// acquire a lock on the body object to ensure that rapid fire
|
||||
// moveto requests don't break things
|
||||
if (!source.acquireLock("moveToLock")) {
|
||||
// if we're still locked, a previous moveTo request hasn't
|
||||
// been fully processed
|
||||
return createResponse("MoveFailed", "m.move_in_progress");
|
||||
}
|
||||
|
||||
// find out if they were previously in some other location
|
||||
if (source.location != -1) {
|
||||
// remove them from the occupant list of the previous location
|
||||
try {
|
||||
PlaceObject pold = (PlaceObject)
|
||||
CherServer.omgr.getObject(source.location);
|
||||
pold.removeFromOccupants(source.getOid());
|
||||
|
||||
} catch (ClassCastException cce) {
|
||||
Log.warning("Body claims to be at location which " +
|
||||
"references non-PlaceObject!? " +
|
||||
"[boid=" + source.getOid() +
|
||||
", poid=" + source.location + "].");
|
||||
}
|
||||
}
|
||||
|
||||
// add the body object id to the place object's occupant list
|
||||
PlaceObject place = (PlaceObject)pobj;
|
||||
place.addToOccupants(source.getOid());
|
||||
|
||||
// set their new location
|
||||
source.setLocation(place.getOid());
|
||||
|
||||
// and finally queue up a lock release event to release the lock
|
||||
// once all these events are processed
|
||||
source.releaseLock("moveToLock");
|
||||
|
||||
return createResponse("MoveSucceeded");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user