Serialization jockeying.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@720 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
//
|
||||
// $Id: MisoSceneModel.java,v 1.2 2001/11/29 00:17:14 mdb Exp $
|
||||
// $Id: MisoSceneModel.java,v 1.3 2001/11/30 21:54:34 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
/**
|
||||
@@ -30,6 +34,52 @@ public class MisoSceneModel
|
||||
* the object layer in (x, y, tile id) format. */
|
||||
public int[] objectTileIds;
|
||||
|
||||
// documentation inherited
|
||||
public void writeTo (DataOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
out.writeInt(width);
|
||||
out.writeInt(height);
|
||||
|
||||
// write out the base and fringe layers
|
||||
int tcount = width*height;
|
||||
for (int i = 0; i < tcount; i++) {
|
||||
out.writeInt(baseTileIds[i]);
|
||||
out.writeInt(fringeTileIds[i]);
|
||||
}
|
||||
|
||||
// write out the object layer
|
||||
int otc = objectTileIds.length;
|
||||
out.writeInt(otc);
|
||||
for (int i = 0; i < otc; i++) {
|
||||
out.writeInt(objectTileIds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
{
|
||||
width = in.readInt();
|
||||
height = in.readInt();
|
||||
|
||||
// read in the base and fringe layers
|
||||
int tcount = width*height;
|
||||
baseTileIds = new int[tcount];
|
||||
fringeTileIds = new int[tcount];
|
||||
for (int i = 0; i < tcount; i++) {
|
||||
baseTileIds[i] = in.readInt();
|
||||
fringeTileIds[i] = in.readInt();
|
||||
}
|
||||
|
||||
// read in the object layer
|
||||
int otc = in.readInt();
|
||||
objectTileIds = new int[otc];
|
||||
for (int i = 0; i < otc; i++) {
|
||||
objectTileIds[i] = in.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a string representation of this scene model.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SceneModel.java,v 1.3 2001/11/29 19:32:06 mdb Exp $
|
||||
// $Id: SceneModel.java,v 1.4 2001/11/30 21:54:34 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.data;
|
||||
|
||||
@@ -62,26 +62,6 @@ public class SceneModel implements Streamable
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a blank scene model.
|
||||
*/
|
||||
public static SceneModel blankSceneModel ()
|
||||
{
|
||||
SceneModel model = new SceneModel();
|
||||
populateBlankSceneModel(model);
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates a blank scene model with blank values.
|
||||
*/
|
||||
protected static void populateBlankSceneModel (SceneModel model)
|
||||
{
|
||||
model.sceneId = -1;
|
||||
model.version = 0;
|
||||
model.neighborIds = new int[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a string representation of this scene model.
|
||||
*/
|
||||
@@ -102,4 +82,24 @@ public class SceneModel implements Streamable
|
||||
buf.append(", version=").append(version);
|
||||
buf.append(", neighborIds=").append(StringUtil.toString(neighborIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a blank scene model.
|
||||
*/
|
||||
public static SceneModel blankSceneModel ()
|
||||
{
|
||||
SceneModel model = new SceneModel();
|
||||
populateBlankSceneModel(model);
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates a blank scene model with blank values.
|
||||
*/
|
||||
protected static void populateBlankSceneModel (SceneModel model)
|
||||
{
|
||||
model.sceneId = -1;
|
||||
model.version = 0;
|
||||
model.neighborIds = new int[0];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user