From caa0da51f27aeb4556a482ef02218c11623859ef Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Sun, 16 Dec 2001 08:07:53 +0000 Subject: [PATCH] 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 --- .../whirled/spot/server/SpotSceneManager.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java b/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java index f886544b3..232d0c6e3 100644 --- a/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java +++ b/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java @@ -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.