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:
@@ -1,10 +1,10 @@
|
||||
//
|
||||
// $Id: OccupantInfo.java,v 1.7 2002/04/17 22:19:40 mdb Exp $
|
||||
// $Id: OccupantInfo.java,v 1.8 2002/07/23 05:54:52 mdb Exp $
|
||||
|
||||
package com.threerings.crowd.data;
|
||||
|
||||
import com.threerings.io.SimpleStreamableObject;
|
||||
import com.threerings.presents.dobj.DSet;
|
||||
import com.threerings.presents.io.SimpleStreamableObject;
|
||||
|
||||
/**
|
||||
* The occupant info object contains all of the information about an
|
||||
@@ -23,11 +23,6 @@ import com.threerings.presents.io.SimpleStreamableObject;
|
||||
* that if derived classes add non-primitive attributes, they are
|
||||
* responsible for adding the code to clone those attributes when a clone
|
||||
* is requested.
|
||||
*
|
||||
* <p> Note also that this class extends {@link SimpleStreamableObject}
|
||||
* which means that public data members will automatically be serialized,
|
||||
* but if any non-public or data members are added, code must be added to
|
||||
* serialize them when this object is streamed.
|
||||
*/
|
||||
public class OccupantInfo extends SimpleStreamableObject
|
||||
implements DSet.Entry, Cloneable
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//
|
||||
// $Id: PlaceConfig.java,v 1.3 2002/03/26 22:57:52 mdb Exp $
|
||||
// $Id: PlaceConfig.java,v 1.4 2002/07/23 05:54:52 mdb Exp $
|
||||
|
||||
package com.threerings.crowd.data;
|
||||
|
||||
import com.threerings.presents.io.Streamable;
|
||||
import com.threerings.presents.io.SimpleStreamableObject;
|
||||
import com.threerings.io.SimpleStreamableObject;
|
||||
import com.threerings.crowd.client.PlaceController;
|
||||
|
||||
/**
|
||||
* The place config class encapsulates the configuration information for a
|
||||
@@ -18,30 +18,25 @@ import com.threerings.presents.io.SimpleStreamableObject;
|
||||
* associated place config derived class that overrides {@link
|
||||
* #getControllerClass} and {@link #getManagerClassName}, returning the
|
||||
* appropriate place controller and manager class for that place.
|
||||
*
|
||||
* <p> A place that has specific configuration needs would extend this
|
||||
* class (or an appropriate subclass) adding it's configuration
|
||||
* information and overriding {@link #writeTo} and {@link #readFrom} to
|
||||
* provide code to serialize and unserialize the additional fields.
|
||||
*/
|
||||
public abstract class PlaceConfig extends SimpleStreamableObject
|
||||
{
|
||||
/**
|
||||
* Returns the class that should be used to create a controller for
|
||||
* this place. The controller class must derive from {@link
|
||||
* com.threerings.crowd.client.PlaceController}.
|
||||
* PlaceController}.
|
||||
*/
|
||||
public abstract Class getControllerClass ();
|
||||
|
||||
/**
|
||||
* Returns the name of the class that should be used to create a
|
||||
* manager for this place. The manager class must derive from {@link
|
||||
* com.threerings.crowd.server.PlaceManager}. <em>Note:</em>
|
||||
* this method differs from {@link #getControllerClass} because we
|
||||
* want to avoid compile time linkage of the place config object
|
||||
* (which is used on the client) to server code. This allows a code
|
||||
* optimizer (DashO Pro, for example) to remove the server code from
|
||||
* the client, knowing that it is never used.
|
||||
* com.threerings.crowd.server.PlaceManager}. <em>Note:</em> this
|
||||
* method differs from {@link #getControllerClass} because we want to
|
||||
* avoid compile time linkage of the place config object (which is
|
||||
* used on the client) to server code. This allows a code optimizer
|
||||
* (DashO Pro, for example) to remove the server code from the client,
|
||||
* knowing that it is never used.
|
||||
*/
|
||||
public abstract String getManagerClassName ();
|
||||
}
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
//
|
||||
// $Id: Lobby.java,v 1.3 2002/02/01 23:43:45 mdb Exp $
|
||||
// $Id: Lobby.java,v 1.4 2002/07/23 05:54:52 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.presents.io.Marshaller;
|
||||
import com.threerings.presents.io.Streamable;
|
||||
import com.threerings.io.SimpleStreamableObject;
|
||||
|
||||
/**
|
||||
* A simple class for keeping track of information for each lobby in
|
||||
* operation on the server.
|
||||
*/
|
||||
public class Lobby implements Streamable
|
||||
public class Lobby extends SimpleStreamableObject
|
||||
{
|
||||
/** The object id of the lobby place object. */
|
||||
public int placeOid;
|
||||
@@ -43,24 +38,4 @@ public class Lobby implements Streamable
|
||||
public Lobby ()
|
||||
{
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void writeTo (DataOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
Marshaller.writeObject(out, this);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
{
|
||||
Marshaller.readObject(in, this);
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
{
|
||||
return "[oid=" + placeOid + ", ident=" + gameIdent +
|
||||
", name=" + name + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
//
|
||||
// $Id: LobbyConfig.java,v 1.5 2001/10/23 20:24:10 mdb Exp $
|
||||
// $Id: LobbyConfig.java,v 1.6 2002/07/23 05:54:52 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
@@ -13,6 +11,9 @@ import javax.swing.JLabel;
|
||||
import java.util.Properties;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
import com.threerings.parlor.game.GameConfig;
|
||||
import com.threerings.micasa.util.MiCasaContext;
|
||||
@@ -64,19 +65,23 @@ public class LobbyConfig extends PlaceConfig
|
||||
_gameConfigClass = getConfigValue(config, "game_config");
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void writeTo (DataOutputStream out)
|
||||
/**
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
out.defaultWriteObject();
|
||||
out.writeUTF(_gameConfigClass);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
/**
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
super.readFrom(in);
|
||||
in.defaultReadObject();
|
||||
_gameConfigClass = in.readUTF();
|
||||
}
|
||||
|
||||
@@ -84,7 +89,10 @@ public class LobbyConfig extends PlaceConfig
|
||||
protected void toString (StringBuffer buf)
|
||||
{
|
||||
super.toString(buf);
|
||||
buf.append(", game_config=").append(_gameConfigClass);
|
||||
if (buf.length() > 1) {
|
||||
buf.append(", ");
|
||||
}
|
||||
buf.append("game_config=").append(_gameConfigClass);
|
||||
}
|
||||
|
||||
/** Looks up a configuration property in the supplied properties
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//
|
||||
// $Id: LobbyProvider.java,v 1.3 2001/10/11 04:13:33 mdb Exp $
|
||||
// $Id: LobbyProvider.java,v 1.4 2002/07/23 05:54:52 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
import com.threerings.presents.server.InvocationProvider;
|
||||
import com.threerings.presents.util.StreamableArrayList;
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.presents.server.InvocationProvider;
|
||||
import com.threerings.util.StreamableArrayList;
|
||||
|
||||
/**
|
||||
* Handles server side of lobby-related invocation services.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TableLobbyObject.dobj,v 1.2 2002/02/08 23:55:24 mdb Exp $
|
||||
// $Id: TableLobbyObject.dobj,v 1.3 2002/07/23 05:54:52 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobby.table;
|
||||
|
||||
@@ -12,7 +12,7 @@ public class TableLobbyObject
|
||||
implements com.threerings.parlor.data.TableLobbyObject
|
||||
{
|
||||
/** A set containing all of the tables being managed by this lobby. */
|
||||
public DSet tableSet = new DSet(Table.class);
|
||||
public DSet tableSet = new DSet();
|
||||
|
||||
// documentation inherited
|
||||
public DSet getTables ()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TableLobbyObject.java,v 1.4 2002/03/18 23:21:26 mdb Exp $
|
||||
// $Id: TableLobbyObject.java,v 1.5 2002/07/23 05:54:52 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobby.table;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class TableLobbyObject
|
||||
public static final String TABLE_SET = "tableSet";
|
||||
|
||||
/** A set containing all of the tables being managed by this lobby. */
|
||||
public DSet tableSet = new DSet(Table.class);
|
||||
public DSet tableSet = new DSet();
|
||||
|
||||
// documentation inherited
|
||||
public DSet getTables ()
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
//
|
||||
// $Id: MisoSceneModel.java,v 1.8 2002/05/17 19:06:23 ray Exp $
|
||||
// $Id: MisoSceneModel.java,v 1.9 2002/07/23 05:54:52 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.io.SimpleStreamableObject;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
|
||||
/**
|
||||
@@ -19,7 +14,7 @@ import com.threerings.miso.Log;
|
||||
* scene in the Miso system. From the scene model, one would create an
|
||||
* instance of {@link DisplayMisoScene}.
|
||||
*/
|
||||
public class MisoSceneModel
|
||||
public class MisoSceneModel extends SimpleStreamableObject
|
||||
implements Cloneable
|
||||
{
|
||||
/** The width of the scene in tile units. */
|
||||
@@ -124,72 +119,6 @@ public class MisoSceneModel
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void writeTo (DataOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
int otc = objectTileIds.length;
|
||||
int btc = baseTileIds.length;
|
||||
|
||||
// write everything into a ByteBuffer, viewed as an IntBuffer and
|
||||
// then write the bytes from those operations out to the output
|
||||
// stream
|
||||
ByteBuffer bbuf = ByteBuffer.allocate(4*(btc + otc + 5));
|
||||
IntBuffer ibuf = bbuf.asIntBuffer();
|
||||
|
||||
// insert the dimensions
|
||||
ibuf.put(width);
|
||||
ibuf.put(height);
|
||||
ibuf.put(vwidth);
|
||||
ibuf.put(vheight);
|
||||
ibuf.put(otc);
|
||||
|
||||
// insert the layer data
|
||||
ibuf.put(baseTileIds);
|
||||
ibuf.put(objectTileIds);
|
||||
|
||||
// now write the binary data out to the output stream
|
||||
out.write(bbuf.array());
|
||||
|
||||
// next write out the object action strings
|
||||
int acount = otc/3;
|
||||
for (int i = 0; i < acount; i++) {
|
||||
out.writeUTF((objectActions[i] == null) ? "" : objectActions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
{
|
||||
// we can read these directly because the byte order of the byte
|
||||
// buffer we created to write out the data is big endian which is
|
||||
// what the data input stream expects
|
||||
width = in.readInt();
|
||||
height = in.readInt();
|
||||
vwidth = in.readInt();
|
||||
vheight = in.readInt();
|
||||
int otc = in.readInt();
|
||||
|
||||
// read in the base layer
|
||||
allocateBaseTileArray();
|
||||
for (int i = 0; i < baseTileIds.length; i++) {
|
||||
baseTileIds[i] = in.readInt();
|
||||
}
|
||||
|
||||
// read in the object layer
|
||||
objectTileIds = new int[otc];
|
||||
for (int i = 0; i < otc; i++) {
|
||||
objectTileIds[i] = in.readInt();
|
||||
}
|
||||
|
||||
// read in the object action strings
|
||||
objectActions = new String[otc/3];
|
||||
for (int i = 0; i < otc/3; i++) {
|
||||
objectActions[i] = in.readUTF();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an old school model to the new-style, baby.
|
||||
* TODO: Remove this method someday after we've converted all
|
||||
@@ -226,18 +155,6 @@ public class MisoSceneModel
|
||||
baseTileIds = new int[vwidth + vheight + ((vwidth * vheight) << 1)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a string representation of this scene model.
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
return "[width=" + width + ", height=" + height +
|
||||
", vwidth=" + vwidth + ", vheight=" + vheight +
|
||||
", baseTileIds=" + StringUtil.toString(baseTileIds) +
|
||||
", objectTileIds=" + StringUtil.toString(objectTileIds) +
|
||||
", objectActions=" + StringUtil.toString(objectActions) + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of this Miso scene model.
|
||||
*/
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
//
|
||||
// $Id: Table.java,v 1.9 2002/04/15 16:28:02 shaper Exp $
|
||||
// $Id: Table.java,v 1.10 2002/07/23 05:54:52 mdb Exp $
|
||||
|
||||
package com.threerings.parlor.data;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
import com.threerings.presents.dobj.DSet;
|
||||
import com.threerings.presents.io.ValueMarshaller;
|
||||
|
||||
import com.threerings.parlor.data.ParlorCodes;
|
||||
import com.threerings.parlor.game.GameConfig;
|
||||
@@ -34,12 +34,12 @@ public class Table
|
||||
public int gameOid = -1;
|
||||
|
||||
/** An array of the usernames of the occupants of this table (some
|
||||
* slots may not be filled. */
|
||||
* slots may not be filled). */
|
||||
public String[] occupants;
|
||||
|
||||
/** The body oids of the occupants of this table. (This is not
|
||||
* propagated to remote instances.) */
|
||||
public int[] bodyOids;
|
||||
public transient int[] bodyOids;
|
||||
|
||||
/** The game config for the game that is being matchmade. This config
|
||||
* instance will also implement {@link TableConfig}. */
|
||||
@@ -242,30 +242,6 @@ public class Table
|
||||
return tableId;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void writeTo (DataOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
out.writeInt(getTableId());
|
||||
out.writeInt(lobbyOid);
|
||||
out.writeInt(gameOid);
|
||||
ValueMarshaller.writeTo(out, occupants);
|
||||
ValueMarshaller.writeTo(out, config);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
{
|
||||
tableId = new Integer(in.readInt());
|
||||
lobbyOid = in.readInt();
|
||||
gameOid = in.readInt();
|
||||
occupants = (String[])ValueMarshaller.readFrom(in);
|
||||
// bodyOids = new int[occupants.length]; // not used
|
||||
config = (GameConfig)ValueMarshaller.readFrom(in);
|
||||
_tconfig = (TableConfig)config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this table is equal to the supplied object (which
|
||||
* must be a table with the same table id).
|
||||
@@ -279,6 +255,26 @@ public class Table
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
out.defaultWriteObject();
|
||||
out.writeObject(_tconfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
in.defaultReadObject();
|
||||
_tconfig = (TableConfig)in.readObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a string representation of this table instance.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: GameConfig.java,v 1.9 2002/06/05 00:47:13 ray Exp $
|
||||
// $Id: GameConfig.java,v 1.10 2002/07/23 05:54:52 mdb Exp $
|
||||
|
||||
package com.threerings.parlor.game;
|
||||
|
||||
@@ -21,11 +21,6 @@ import com.threerings.crowd.data.PlaceConfig;
|
||||
* the construction of the appropriate game config instance which is
|
||||
* provided to the server as part of an invitation or via some other
|
||||
* matchmaking mechanism.
|
||||
*
|
||||
* <p> A game that has specific configuration needs would extend this
|
||||
* class (or an appropriate subclass) adding it's configuration
|
||||
* information and overriding {@link #writeTo} and {@link #readFrom} to
|
||||
* provide code to serialize and unserialize the additional fields.
|
||||
*/
|
||||
public abstract class GameConfig extends PlaceConfig
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TableManager.java,v 1.5 2002/04/15 16:28:02 shaper Exp $
|
||||
// $Id: TableManager.java,v 1.6 2002/07/23 05:54:52 mdb Exp $
|
||||
|
||||
package com.threerings.parlor.server;
|
||||
|
||||
@@ -102,8 +102,8 @@ public class TableManager
|
||||
table.setOccupant(0, creator.username, creator.getOid());
|
||||
if (error != null) {
|
||||
Log.warning("Unable to add creator to position zero of " +
|
||||
"table!? [table=" + table +
|
||||
", creator=" + creator + "].");
|
||||
"table!? [table=" + table + ", creator=" + creator +
|
||||
", error=" + error + "].");
|
||||
// bail out now and abort the table creation process
|
||||
throw new ServiceFailedException(error);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// $Id: StreamableArrayList.java,v 1.1 2002/07/23 05:54:52 mdb Exp $
|
||||
|
||||
package com.threerings.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
import com.threerings.io.Streamable;
|
||||
|
||||
/**
|
||||
* An {@link ArrayList} extension that can be streamed. The contents of
|
||||
* the list must also be of streamable types.
|
||||
*
|
||||
* @see Streamable
|
||||
*/
|
||||
public class StreamableArrayList extends ArrayList
|
||||
implements Streamable
|
||||
{
|
||||
/**
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
int ecount = size();
|
||||
out.writeInt(ecount);
|
||||
for (int ii = 0; ii < ecount; ii++) {
|
||||
out.writeObject(get(ii));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
int ecount = in.readInt();
|
||||
for (int ii = 0; ii < ecount; ii++) {
|
||||
add(in.readObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user