diff --git a/src/java/com/threerings/whirled/spot/tools/EditableSpotScene.java b/src/java/com/threerings/whirled/spot/tools/EditableSpotScene.java index f0e5effe4..2a0301bd3 100644 --- a/src/java/com/threerings/whirled/spot/tools/EditableSpotScene.java +++ b/src/java/com/threerings/whirled/spot/tools/EditableSpotScene.java @@ -1,5 +1,5 @@ // -// $Id: EditableSpotScene.java,v 1.4 2001/12/05 03:38:09 mdb Exp $ +// $Id: EditableSpotScene.java,v 1.5 2001/12/05 09:20:10 mdb Exp $ package com.threerings.whirled.tools.spot; @@ -27,6 +27,13 @@ public interface EditableSpotScene */ public void setDefaultEntranceId (int defaultEntranceId); + /** + * Returns the next valid location id for this scene. Newly created + * portals or locations should be assigned a new location id via this + * method. + */ + public int getNextLocationId (); + /** * Adds a location to this scene. */ diff --git a/src/java/com/threerings/whirled/spot/tools/EditableSpotSceneImpl.java b/src/java/com/threerings/whirled/spot/tools/EditableSpotSceneImpl.java index 575bb3101..4b72c1f86 100644 --- a/src/java/com/threerings/whirled/spot/tools/EditableSpotSceneImpl.java +++ b/src/java/com/threerings/whirled/spot/tools/EditableSpotSceneImpl.java @@ -1,9 +1,10 @@ // -// $Id: EditableSpotSceneImpl.java,v 1.7 2001/12/05 08:45:06 mdb Exp $ +// $Id: EditableSpotSceneImpl.java,v 1.8 2001/12/05 09:20:10 mdb Exp $ package com.threerings.whirled.tools.spot; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import com.threerings.crowd.data.PlaceConfig; @@ -80,6 +81,13 @@ public class EditableSpotSceneImpl extends EditableSceneImpl port.targetPortalName = _emodel.targetPortalNames[i]; portals.set(i, port); } + + // determine the highest location id in use by this scene + Iterator iter = _delegate.getLocations().iterator(); + while (iter.hasNext()) { + _nextLocationId = Math.max(_nextLocationId, + ((Location)iter.next()).locationId); + } } /** @@ -123,6 +131,12 @@ public class EditableSpotSceneImpl extends EditableSceneImpl _model.defaultEntranceId = defaultEntranceId; } + // documentation inherited + public int getNextLocationId () + { + return ++_nextLocationId; + } + // documentation inherited public void addLocation (Location loc) { @@ -219,4 +233,7 @@ public class EditableSpotSceneImpl extends EditableSceneImpl /** Our display spot scene delegate. */ protected DisplaySpotSceneImpl _delegate; + + /** A location id counter used for assigning ids to new locations. */ + protected int _nextLocationId; }