Brought things into line with new streaming world order.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1607 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-07-23 05:54:53 +00:00
parent c3191b9170
commit eb0f92fcef
16 changed files with 149 additions and 348 deletions
@@ -1,15 +1,11 @@
//
// $Id: SceneModel.java,v 1.7 2002/02/01 23:43:45 mdb Exp $
// $Id: SceneModel.java,v 1.8 2002/07/23 05:54:52 mdb Exp $
package com.threerings.whirled.data;
import java.io.IOException;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import com.samskivert.util.StringUtil;
import com.threerings.presents.io.Streamable;
import com.threerings.presents.io.StreamableUtil;
import com.threerings.io.SimpleStreamableObject;
/**
* The scene model is the bare bones representation of the data for a
@@ -22,8 +18,8 @@ import com.threerings.presents.io.StreamableUtil;
* what is transmitted over the wire when communicating scenes from the
* server to the client.
*/
public class SceneModel
implements Streamable, Cloneable
public class SceneModel extends SimpleStreamableObject
implements Cloneable
{
/** This scene's unique identifier. */
public int sceneId;
@@ -41,26 +37,6 @@ public class SceneModel
* is a scene that can be entered from this scene. */
public int[] neighborIds;
// documentation inherited
public void writeTo (DataOutputStream out)
throws IOException
{
out.writeInt(sceneId);
out.writeUTF(sceneName);
out.writeInt(version);
StreamableUtil.writeInts(out, neighborIds);
}
// documentation inherited
public void readFrom (DataInputStream in)
throws IOException
{
sceneId = in.readInt();
sceneName = in.readUTF();
version = in.readInt();
neighborIds = StreamableUtil.readInts(in);
}
/**
* Generates a string representation of this scene model.
*/
@@ -1,12 +1,8 @@
//
// $Id: SpotSceneModel.java,v 1.7 2002/05/02 19:34:51 mdb Exp $
// $Id: SpotSceneModel.java,v 1.8 2002/07/23 05:54:52 mdb Exp $
package com.threerings.whirled.spot.data;
import java.io.IOException;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import com.samskivert.util.StringUtil;
import com.threerings.whirled.data.SceneModel;
@@ -61,72 +57,6 @@ public class SpotSceneModel extends SceneModel
* values. */
public int[] targetLocIds;
// documentation inherited
public void writeTo (DataOutputStream out)
throws IOException
{
super.writeTo(out);
// write out our location info
int lcount = locationIds.length;
out.writeInt(lcount);
for (int i = 0; i < lcount; i++) {
out.writeInt(locationIds[i]);
out.writeInt(locationX[i]);
out.writeInt(locationY[i]);
out.writeInt(locationOrients[i]);
out.writeInt(locationClusters[i]);
}
// write out our default entrance id
out.writeInt(defaultEntranceId);
// write out our portal info; we need not serialize the portal
// count because our based class already did when writing out the
// neighborIds array
int pcount = portalIds.length;
for (int i = 0; i < pcount; i++) {
out.writeInt(portalIds[i]);
out.writeInt(targetLocIds[i]);
}
}
// documentation inherited
public void readFrom (DataInputStream in)
throws IOException
{
super.readFrom(in);
// read in our location info
int lcount = in.readInt();
locationIds = new int[lcount];
locationX = new int[lcount];
locationY = new int[lcount];
locationOrients = new int[lcount];
locationClusters = new int[lcount];
for (int i = 0; i < lcount;i++) {
locationIds[i] = in.readInt();
locationX[i] = in.readInt();
locationY[i] = in.readInt();
locationOrients[i] = in.readInt();
locationClusters[i] = in.readInt();
}
// read in our default entrance id
defaultEntranceId = in.readInt();
// and read in our portal info
int pcount = neighborIds.length;
portalIds = new int[pcount];
targetLocIds = new int[pcount];
for (int i = 0; i < pcount; i++) {
portalIds[i] = in.readInt();
targetLocIds[i] = in.readInt();
}
}
// documentation inherited
public Object clone ()
throws CloneNotSupportedException
@@ -1,10 +1,8 @@
//
// $Id: SceneSummary.java,v 1.3 2001/12/17 03:38:50 mdb Exp $
// $Id: SceneSummary.java,v 1.4 2002/07/23 05:54:53 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;
@@ -12,8 +10,9 @@ import com.samskivert.util.StringUtil;
import com.threerings.util.DirectionCodes;
import com.threerings.util.DirectionUtil;
import com.threerings.presents.io.Streamable;
import com.threerings.presents.io.StreamableUtil;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable;
/**
* The scene summary class is used to provide info about the connected
@@ -55,25 +54,23 @@ public class SceneSummary implements Streamable
_population = population;
}
// documentation inherited
public void writeTo (DataOutputStream out)
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
out.writeInt(sceneId);
out.writeUTF(name);
StreamableUtil.writeInts(out, neighbors);
StreamableUtil.writeInts(out, neighborDirs);
out.writeInt(_population);
out.defaultWriteObject();
out.writeInt(getPopulation());
}
// documentation inherited
public void readFrom (DataInputStream in)
throws IOException
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
sceneId = in.readInt();
name = in.readUTF();
neighbors = StreamableUtil.readInts(in);
neighborDirs = StreamableUtil.readInts(in);
in.defaultReadObject();
_population = in.readInt();
}
@@ -84,7 +81,8 @@ public class SceneSummary implements Streamable
{
return "[sceneId=" + sceneId + ", name=" + name +
", neighbors=" + StringUtil.toString(neighbors) +
", neighborDirs=" + DirectionUtil.toString(neighborDirs) + "]";
", neighborDirs=" + DirectionUtil.toString(neighborDirs) +
", pop=" + _population + "]";
}
/** The number of people currently occupying this scene. */
@@ -1,21 +1,18 @@
//
// $Id: ZoneSummary.java,v 1.3 2001/12/17 00:58:04 mdb Exp $
// $Id: ZoneSummary.java,v 1.4 2002/07/23 05:54:53 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.io.SimpleStreamableObject;
/**
* The zone summary contains information on a zone, including its name and
* summary info on all of the scenes in this zone (which can be used to
* generate a map of the zone on the client).
*/
public class ZoneSummary implements Streamable
public class ZoneSummary extends SimpleStreamableObject
{
/** The zone's fully qualified unique identifier. */
public int zoneId;
@@ -26,33 +23,6 @@ public class ZoneSummary implements Streamable
/** The summary information for all of the scenes in the zone. */
public SceneSummary[] scenes;
// documentation inherited
public void writeTo (DataOutputStream out)
throws IOException
{
out.writeInt(zoneId);
out.writeUTF(name);
int scount = scenes.length;
out.writeInt(scount);
for (int i = 0; i < scount; i++) {
scenes[i].writeTo(out);
}
}
// documentation inherited
public void readFrom (DataInputStream in)
throws IOException
{
zoneId = in.readInt();
name = in.readUTF();
int scount = in.readInt();
scenes = new SceneSummary[scount];
for (int i = 0; i < scount; i++) {
scenes[i] = new SceneSummary();
scenes[i].readFrom(in);
}
}
/**
* Generates a string representation of this instance.
*/