From 14b9708e9ef9b72dbdd6ac739d3ab52aaf5b0d4b Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 5 Dec 2001 09:20:10 +0000 Subject: [PATCH] Added facilities for obtaining a valid location id from the scene because it's the one that knows which location ids are in use. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@748 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../whirled/spot/tools/EditableSpotScene.java | 9 ++++++++- .../spot/tools/EditableSpotSceneImpl.java | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) 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; }