The adding of portals to scenes needs to be handled somewhat differently
now that all the scene updating stuff has been cleaned up. Basically we can't rely on the updating process itself to assign a portal id, updates must be created with all the information they need before they are applied to the scene. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3451 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -161,6 +161,12 @@ public class StageScene extends SceneImpl
|
||||
return _sdelegate.getPortals();
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public short getNextPortalId ()
|
||||
{
|
||||
return _sdelegate.getNextPortalId();
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public Portal getDefaultEntrance ()
|
||||
{
|
||||
|
||||
@@ -119,6 +119,7 @@ public class PortalTool extends MouseInputAdapter
|
||||
_portal.name = name;
|
||||
|
||||
// add the portal to the scene and pop up the editor dialog
|
||||
_portal.portalId = _scene.getNextPortalId();
|
||||
_scene.addPortal(_portal);
|
||||
_panel.editPortal(_portal);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SpotScene.java,v 1.2 2004/08/27 02:20:46 mdb Exp $
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -45,6 +45,12 @@ public interface SpotScene
|
||||
*/
|
||||
public Iterator getPortals ();
|
||||
|
||||
/**
|
||||
* Returns the portal id that should be assigned to the next portal
|
||||
* added to this scene.
|
||||
*/
|
||||
public short getNextPortalId ();
|
||||
|
||||
/**
|
||||
* Returns the portal that represents the default entrance to this
|
||||
* scene. If a body enters the scene at logon time rather than
|
||||
@@ -55,8 +61,9 @@ public interface SpotScene
|
||||
|
||||
/**
|
||||
* Adds a portal to this scene, immediately making the requisite
|
||||
* modifications to the underlying scene model. A portal id will be
|
||||
* assigned to the portal by this method.
|
||||
* modifications to the underlying scene model. The portal id should
|
||||
* have already been assigned using the value obtained from {@link
|
||||
* #getNextPortalId}.
|
||||
*/
|
||||
public void addPortal (Portal portal);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SpotSceneImpl.java,v 1.4 2004/08/27 02:20:46 mdb Exp $
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -78,6 +78,18 @@ public class SpotSceneImpl
|
||||
return _portals.values().iterator();
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public short getNextPortalId ()
|
||||
{
|
||||
// compute a new portal id for our friend the portal
|
||||
for (short ii = 1; ii < MAX_PORTAL_ID; ii++) {
|
||||
if (!_portals.containsKey(ii)) {
|
||||
return ii;
|
||||
}
|
||||
}
|
||||
return (short)-1;
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public Portal getDefaultEntrance ()
|
||||
{
|
||||
@@ -87,21 +99,13 @@ public class SpotSceneImpl
|
||||
// documentation inherited from interface
|
||||
public void addPortal (Portal portal)
|
||||
{
|
||||
// compute a new portal id for our friend the portal
|
||||
portal.portalId = 0;
|
||||
for (short ii = 1; ii < MAX_PORTAL_ID; ii++) {
|
||||
if (!_portals.containsKey(ii)) {
|
||||
portal.portalId = ii;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (portal.portalId == 0) {
|
||||
Log.warning("Unable to assign id to new portal " +
|
||||
"[scene=" + this + "].");
|
||||
if (portal.portalId <= 0) {
|
||||
Log.warning("Refusing to add zero-id portal " +
|
||||
"[scene=" + this + ", portal=" + portal + "].");
|
||||
return;
|
||||
}
|
||||
|
||||
// add this beyotch to our model
|
||||
// add it to our model
|
||||
_smodel.addPortal(portal);
|
||||
|
||||
// and slap it into our table
|
||||
|
||||
Reference in New Issue
Block a user