//
// $Id: SceneSummary.java,v 1.2 2001/12/17 00:58:04 mdb Exp $

package com.threerings.whirled.zone.data;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import com.samskivert.util.StringUtil;
import com.threerings.presents.io.Streamable;
import com.threerings.presents.io.StreamableUtil;

/**
 * The scene summary class is used to provide info about the connected
 * group of scenes that make up an island. The group of scenes that make
 * up an island is a self-contained set of scenes, connected with one
 * another (by portals) but not to any scenes outside the group.
 */
public class SceneSummary implements Streamable
{
    /** The id of this scene. */
    public int sceneId;

    /** The name of this scene. */
    public String name;

    /** The ids of the scenes to which this scene is connected via
     * portals. */
    public int[] neighbors;

    /**
     * Returns the population of this scene summary instance. This is
     * synchronized because the population can be updated by a background
     * thread.
     */
    public synchronized int getPopulation ()
    {
        return _population;
    }

    /**
     * Used to set the population of this scene summary instance.
     */
    public synchronized void setPopulation (int population)
    {
        _population = population;
    }

    // documentation inherited
    public void writeTo (DataOutputStream out)
        throws IOException
    {
        out.writeInt(sceneId);
        out.writeUTF(name);
        StreamableUtil.writeInts(out, neighbors);
        out.writeInt(_population);
    }

    // documentation inherited
    public void readFrom (DataInputStream in)
        throws IOException
    {
        sceneId = in.readInt();
        name = in.readUTF();
        neighbors = StreamableUtil.readInts(in);
        _population = in.readInt();
    }

    /**
     * Generates a string representation of this instance.
     */
    public String toString ()
    {
        return "[sceneId=" + sceneId + ", name=" + name +
            ", neighbors=" + StringUtil.toString(neighbors) + "]";
    }

    /** The number of people currently occupying this scene. */
    protected int _population;
}

@@ -26,17 +26,17 @@
 ava,v 1.
-2
+3
  2001/12
@@ -44,15 +44,15 @@
 17 0
-0:58:04
+3:38:50
  mdb
@@ -235,16 +235,103 @@
 ngUtil;%0A
+%0Aimport com.threerings.util.DirectionCodes;%0Aimport com.threerings.util.DirectionUtil;%0A%0A
 import c
@@ -989,16 +989,191 @@
 hbors;%0A%0A
+    /** The compass directions in which each of the neighbors lay. The%0A     * direction constants are as defined in %7B@link DirectionCodes%7D. */%0A    public int%5B%5D neighborDirs;%0A%0A
     /**%0A
@@ -1834,16 +1834,69 @@
 hbors);%0A
+        StreamableUtil.writeInts(out, neighborDirs);%0A
         
@@ -2145,24 +2145,76 @@
 adInts(in);%0A
+        neighborDirs = StreamableUtil.readInts(in);%0A
         _pop
@@ -2413,16 +2413,16 @@
  name +%0A
-
         
@@ -2474,16 +2474,87 @@
 hbors) +
+%0A            %22, neighborDirs=%22 + DirectionUtil.toString(neighborDirs) +
  %22%5D%22;%0A  

Add direction information to the scene summary.