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
This commit is contained in:
Michael Bayne
2001-12-05 09:20:10 +00:00
parent 7fcc918797
commit 14b9708e9e
2 changed files with 26 additions and 2 deletions
@@ -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.
*/
@@ -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;
}