diff --git a/src/java/com/threerings/whirled/spot/data/Portal.java b/src/java/com/threerings/whirled/spot/data/Portal.java index 7af78126..5b83b627 100644 --- a/src/java/com/threerings/whirled/spot/data/Portal.java +++ b/src/java/com/threerings/whirled/spot/data/Portal.java @@ -47,7 +47,8 @@ public class Portal extends SimpleStreamableObject public int targetSceneId; /** The portal identifier of the portal at which a body will enter - * the target scene when they "use" this portal. */ + * the target scene when they "use" this portal, or -1 to specify + * that the body enters on the default portal, whatever id it is. */ public short targetPortalId; /** @@ -78,7 +79,9 @@ public class Portal extends SimpleStreamableObject */ public boolean isValid () { - return (targetSceneId > 0) && (targetPortalId > 0); + return (targetSceneId > 0) && + // the target portal must be positive, or -1 + ((targetPortalId > 0) || (targetPortalId == -1)); } /** diff --git a/src/java/com/threerings/whirled/spot/data/SpotSceneImpl.java b/src/java/com/threerings/whirled/spot/data/SpotSceneImpl.java index a7d87609..8820c274 100644 --- a/src/java/com/threerings/whirled/spot/data/SpotSceneImpl.java +++ b/src/java/com/threerings/whirled/spot/data/SpotSceneImpl.java @@ -63,6 +63,9 @@ public class SpotSceneImpl // documentation inherited from interface public Portal getPortal (int portalId) { + if (portalId == -1) { + portalId = _smodel.defaultEntranceId; + } return (Portal)_portals.get(portalId); } @@ -93,7 +96,7 @@ public class SpotSceneImpl // documentation inherited from interface public Portal getDefaultEntrance () { - return getPortal(_smodel.defaultEntranceId); + return getPortal(-1); // -1 is a shortcut meaning "default" } // documentation inherited from interface diff --git a/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java b/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java index b6f6e130..dce5a014 100644 --- a/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java +++ b/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java @@ -91,7 +91,12 @@ public class SpotSceneManager extends SceneManager */ public void mapEnteringBody (BodyObject body, int portalId) { - _enterers.put(body.getOid(), portalId); + // small optimization: don't save portalId -1, because it simply means + // "use the default entrance" and retrieving an unset value will + // return -1 anyway + if (portalId != -1) { + _enterers.put(body.getOid(), portalId); + } } /**