Clear out a user's previous location when they move to a new location or

flee the scene.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@800 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-12-16 08:07:53 +00:00
parent 75c9c55dc4
commit caa0da51f2
@@ -1,5 +1,5 @@
//
// $Id: SpotSceneManager.java,v 1.2 2001/12/16 05:15:27 mdb Exp $
// $Id: SpotSceneManager.java,v 1.3 2001/12/16 08:07:53 mdb Exp $
package com.threerings.whirled.spot.server;
@@ -136,6 +136,18 @@ public class SpotSceneManager extends SceneManager
throw new ServiceFailedException(INTERNAL_ERROR);
}
// clear out any location they previously occupied
if (soi.locationId > 0) {
int oldlocidx = _sscene.getLocationIndex(soi.locationId);
if (oldlocidx == -1) {
Log.warning("Changing location for body that was " +
"previously in an invalid location " +
"[info=" + soi + "].");
} else {
_locationOccs[oldlocidx] = 0;
}
}
// stick our new friend into that location
_locationOccs[locidx] = bodyOid;
// update their occupant info
@@ -182,6 +194,22 @@ public class SpotSceneManager extends SceneManager
}
}
/**
* When an occupant leaves the room, we want to clear out any location
* they may have occupied.
*/
protected void bodyLeft (int bodyOid)
{
super.bodyLeft(bodyOid);
for (int i = 0; i < _locationOccs.length; i++) {
if (_locationOccs[i] == bodyOid) {
_locationOccs[i] = 0;
break;
}
}
}
/**
* Returns the location index of the location occupied by the
* specified body oid or -1 if they occupy no location.