From 543705b935e5542b3a7f3a1ad4e6741da0696a5d Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 4 Feb 2003 03:12:07 +0000 Subject: [PATCH] Added a method for adding a portal. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2234 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../whirled/spot/server/RuntimeSpotScene.java | 11 +++++- .../spot/server/RuntimeSpotSceneImpl.java | 39 ++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/java/com/threerings/whirled/spot/server/RuntimeSpotScene.java b/src/java/com/threerings/whirled/spot/server/RuntimeSpotScene.java index 393de12aa..1ffc4ebe2 100644 --- a/src/java/com/threerings/whirled/spot/server/RuntimeSpotScene.java +++ b/src/java/com/threerings/whirled/spot/server/RuntimeSpotScene.java @@ -1,5 +1,5 @@ // -// $Id: RuntimeSpotScene.java,v 1.4 2002/04/17 00:20:56 mdb Exp $ +// $Id: RuntimeSpotScene.java,v 1.5 2003/02/04 03:12:07 mdb Exp $ package com.threerings.whirled.spot.server; @@ -62,6 +62,15 @@ public interface RuntimeSpotScene extends RuntimeScene */ public int getTargetLocationId (int locationId); + /** + * Adds a portal to this runtime scene, immediately making the + * requisite modifications to the underlying scene model. + * + * @return the location id assigned to the newly created portal. + */ + public int addPortal (int locX, int locY, int orient, + int targetSceneId, int targetLocId); + /** * Returns a reference to the underlying model. */ diff --git a/src/java/com/threerings/whirled/spot/server/RuntimeSpotSceneImpl.java b/src/java/com/threerings/whirled/spot/server/RuntimeSpotSceneImpl.java index 4e4aff855..c6856af9d 100644 --- a/src/java/com/threerings/whirled/spot/server/RuntimeSpotSceneImpl.java +++ b/src/java/com/threerings/whirled/spot/server/RuntimeSpotSceneImpl.java @@ -1,5 +1,5 @@ // -// $Id: RuntimeSpotSceneImpl.java,v 1.5 2002/12/11 23:06:24 shaper Exp $ +// $Id: RuntimeSpotSceneImpl.java,v 1.6 2003/02/04 03:12:07 mdb Exp $ package com.threerings.whirled.spot.server; @@ -91,6 +91,43 @@ public class RuntimeSpotSceneImpl extends RuntimeSceneImpl return (pidx == -1) ? -1 : _model.targetLocIds[pidx]; } + // make or may not make it into the public interface + public int addLocation (int locX, int locY, int orient, int cluster) + { + // compute the highest location id already used in the scene and + // add one to it for our new location id + int nlocid = Math.max( + IntListUtil.getMaxValue(_model.locationIds), 0) + 1; + + // expand the necessary arrays + _model.locationIds = IntListUtil.append(_model.locationIds, nlocid); + _model.locationX = IntListUtil.append(_model.locationX, locX); + _model.locationY = IntListUtil.append(_model.locationY, locY); + _model.locationOrients = + IntListUtil.append(_model.locationOrients, orient); + _model.locationClusters = + IntListUtil.append(_model.locationOrients, cluster); + + return nlocid; + } + + // documentation inherited from interface + public int addPortal (int locX, int locY, int orient, + int targetSceneId, int targetLocId) + { + // add the location information for this portal + int nlocid = addLocation(locX, locY, orient, 0); + + // expand the necessary portal arrays + _model.neighborIds = + IntListUtil.append(_model.neighborIds, targetSceneId); + _model.portalIds = IntListUtil.append(_model.portalIds, nlocid); + _model.targetLocIds = + IntListUtil.append(_model.targetLocIds, targetLocId); + + return nlocid; + } + // documentation inherited from interface public SpotSceneModel getModel () {