Rebuilt various bits using the code generator. Annotated some Java sources
along the way. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@99 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -36,6 +36,11 @@ import com.threerings.whirled.client.SceneController;
|
|||||||
*/
|
*/
|
||||||
public class DefaultSceneConfig extends PlaceConfig
|
public class DefaultSceneConfig extends PlaceConfig
|
||||||
{
|
{
|
||||||
|
public function DefaultSceneConfig ()
|
||||||
|
{
|
||||||
|
// nothing needed
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
override public function getManagerClassName () :String
|
override public function getManagerClassName () :String
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import com.threerings.util.Cloneable;
|
|||||||
|
|
||||||
import com.threerings.io.ObjectInputStream;
|
import com.threerings.io.ObjectInputStream;
|
||||||
import com.threerings.io.ObjectOutputStream;
|
import com.threerings.io.ObjectOutputStream;
|
||||||
import com.threerings.io.Streamable;
|
import com.threerings.io.SimpleStreamableObject;
|
||||||
import com.threerings.io.TypedArray;
|
import com.threerings.io.TypedArray;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,8 +38,8 @@ import com.threerings.io.TypedArray;
|
|||||||
* what is transmitted over the wire when communicating scenes from the
|
* what is transmitted over the wire when communicating scenes from the
|
||||||
* server to the client.
|
* server to the client.
|
||||||
*/
|
*/
|
||||||
public class SceneModel
|
public class SceneModel extends SimpleStreamableObject
|
||||||
implements Streamable, Cloneable
|
implements Cloneable
|
||||||
{
|
{
|
||||||
/** This scene's unique identifier. */
|
/** This scene's unique identifier. */
|
||||||
public var sceneId :int;
|
public var sceneId :int;
|
||||||
@@ -56,6 +56,21 @@ public class SceneModel
|
|||||||
/** Auxiliary scene model information. */
|
/** Auxiliary scene model information. */
|
||||||
public var auxModels :TypedArray = TypedArray.create(AuxModel);
|
public var auxModels :TypedArray = TypedArray.create(AuxModel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and returns a blank scene model.
|
||||||
|
*/
|
||||||
|
public static function blankSceneModel () :SceneModel
|
||||||
|
{
|
||||||
|
var model :SceneModel = new SceneModel();
|
||||||
|
populateBlankSceneModel(model);
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function SceneModel ()
|
||||||
|
{
|
||||||
|
// nothing needed
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the specified auxiliary model to this scene model.
|
* Adds the specified auxiliary model to this scene model.
|
||||||
*/
|
*/
|
||||||
@@ -81,31 +96,23 @@ public class SceneModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface Streamable
|
// documentation inherited from interface Streamable
|
||||||
public function writeObject (out :ObjectOutputStream) :void
|
override public function readObject (ins :ObjectInputStream) :void
|
||||||
{
|
|
||||||
out.writeInt(sceneId);
|
|
||||||
out.writeField(name);
|
|
||||||
out.writeInt(version);
|
|
||||||
out.writeObject(auxModels);
|
|
||||||
}
|
|
||||||
|
|
||||||
// documentation inherited from interface Streamable
|
|
||||||
public function readObject (ins :ObjectInputStream) :void
|
|
||||||
{
|
{
|
||||||
|
super.readObject(ins);
|
||||||
sceneId = ins.readInt();
|
sceneId = ins.readInt();
|
||||||
name = (ins.readField(String) as String);
|
name = (ins.readField(String) as String);
|
||||||
version = ins.readInt();
|
version = ins.readInt();
|
||||||
auxModels = (ins.readObject() as TypedArray);
|
auxModels = (ins.readObject() as TypedArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// documentation inherited from interface Streamable
|
||||||
* Creates and returns a blank scene model.
|
override public function writeObject (out :ObjectOutputStream) :void
|
||||||
*/
|
|
||||||
public static function blankSceneModel () :SceneModel
|
|
||||||
{
|
{
|
||||||
var model :SceneModel = new SceneModel();
|
super.writeObject(out);
|
||||||
populateBlankSceneModel(model);
|
out.writeInt(sceneId);
|
||||||
return model;
|
out.writeField(name);
|
||||||
|
out.writeInt(version);
|
||||||
|
out.writeObject(auxModels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,26 +29,36 @@ import com.threerings.io.ObjectInputStream;
|
|||||||
import com.threerings.io.ObjectOutputStream;
|
import com.threerings.io.ObjectOutputStream;
|
||||||
import com.threerings.io.Streamable;
|
import com.threerings.io.Streamable;
|
||||||
|
|
||||||
|
import com.threerings.util.Cloneable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to encapsulate updates to scenes in such a manner that updates can
|
* Used to encapsulate updates to scenes in such a manner that updates can
|
||||||
* be stored persistently and sent to clients to update their own local
|
* be stored persistently and sent to clients to update their own local
|
||||||
* copies of scenes.
|
* copies of scenes.
|
||||||
*/
|
*/
|
||||||
public class SceneUpdate
|
public class SceneUpdate
|
||||||
implements Streamable /*, Cloneable */
|
implements Streamable, Cloneable
|
||||||
{
|
{
|
||||||
/**
|
public function SceneUpdate ()
|
||||||
* Initializes this scene update such that it will operate on a scene
|
|
||||||
* with the specified target scene and version number.
|
|
||||||
*
|
|
||||||
* @param targetId the id of the scene on which we are to operate.
|
|
||||||
* @param targetVersion the version of the scene on which we are to
|
|
||||||
* operate.
|
|
||||||
*/
|
|
||||||
public function init (targetId :int, targetVersion :int) :void
|
|
||||||
{
|
{
|
||||||
_targetId = targetId;
|
// nothing needed
|
||||||
_targetVersion = targetVersion;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies this update to the specified scene model. Derived classes
|
||||||
|
* will want to override this method and apply updates of their own,
|
||||||
|
* being sure to call <code>super.apply</code>.
|
||||||
|
*/
|
||||||
|
public function apply (model :SceneModel) :void
|
||||||
|
{
|
||||||
|
// increment the version; disallowing integer overflow
|
||||||
|
model.version = Math.max(_targetVersion + 1, model.version);
|
||||||
|
|
||||||
|
// sanity check for the amazing two billion updates
|
||||||
|
if (model.version == _targetVersion) {
|
||||||
|
Log.getLog(this).warning("Egads! This scene has been updated two" +
|
||||||
|
" billion times [model=" + model + ", update=" + this + "].");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,6 +77,44 @@ public class SceneUpdate
|
|||||||
return _targetVersion;
|
return _targetVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a string representation of this instance.
|
||||||
|
*/
|
||||||
|
public function toString () :String
|
||||||
|
{
|
||||||
|
var buf :StringBuilder = new StringBuilder("[");
|
||||||
|
toStringBuilder(buf);
|
||||||
|
return buf.append("]").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes this scene update such that it will operate on a scene
|
||||||
|
* with the specified target scene and version number.
|
||||||
|
*
|
||||||
|
* @param targetId the id of the scene on which we are to operate.
|
||||||
|
* @param targetVersion the version of the scene on which we are to
|
||||||
|
* operate.
|
||||||
|
*/
|
||||||
|
public function init (targetId :int, targetVersion :int) :void
|
||||||
|
{
|
||||||
|
_targetId = targetId;
|
||||||
|
_targetVersion = targetVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
// from interface Streamable
|
||||||
|
public function writeObject (out :ObjectOutputStream) :void
|
||||||
|
{
|
||||||
|
out.writeInt(_targetId);
|
||||||
|
out.writeInt(_targetVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
// from interface Streamable
|
||||||
|
public function readObject (ins :ObjectInputStream) :void
|
||||||
|
{
|
||||||
|
_targetId = ins.readInt();
|
||||||
|
_targetVersion = ins.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to ensure that the scene is in the appropriate state prior
|
* Called to ensure that the scene is in the appropriate state prior
|
||||||
* to applying the update.
|
* to applying the update.
|
||||||
@@ -90,54 +138,17 @@ public class SceneUpdate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// from interface Cloneable
|
||||||
* Applies this update to the specified scene model. Derived classes
|
public function clone () :Object
|
||||||
* will want to override this method and apply updates of their own,
|
|
||||||
* being sure to call <code>super.apply</code>.
|
|
||||||
*/
|
|
||||||
public function apply (model :SceneModel) :void
|
|
||||||
{
|
{
|
||||||
// increment the version; disallowing integer overflow
|
throw new Error("Not implemented.");
|
||||||
model.version = Math.max(_targetVersion + 1, model.version);
|
|
||||||
|
|
||||||
// sanity check for the amazing two billion updates
|
|
||||||
if (model.version == _targetVersion) {
|
|
||||||
Log.getLog(this).warning("Egads! This scene has been updated two" +
|
|
||||||
" billion times [model=" + model + ", update=" + this + "].");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// documentation inherited from interface Streamable
|
|
||||||
public function writeObject (out :ObjectOutputStream) :void
|
|
||||||
//throws IOException
|
|
||||||
{
|
|
||||||
out.writeInt(_targetId);
|
|
||||||
out.writeInt(_targetVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
// documentation inherited from interface Streamable
|
|
||||||
public function readObject (ins :ObjectInputStream) :void
|
|
||||||
//throws IOException, ClassNotFoundException
|
|
||||||
{
|
|
||||||
_targetId = ins.readInt();
|
|
||||||
_targetVersion = ins.readInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a string representation of this instance.
|
|
||||||
*/
|
|
||||||
public function toString () :String
|
|
||||||
{
|
|
||||||
var buf :StringBuilder = new StringBuilder("[");
|
|
||||||
toStringBuf(buf);
|
|
||||||
return buf.append("]").toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An extensible mechanism for generating a string representation of
|
* An extensible mechanism for generating a string representation of
|
||||||
* this instance.
|
* this instance.
|
||||||
*/
|
*/
|
||||||
protected function toStringBuf (buf :StringBuilder) :void
|
protected function toStringBuilder (buf :StringBuilder) :void
|
||||||
{
|
{
|
||||||
buf.append("sceneId=").append(_targetId);
|
buf.append("sceneId=").append(_targetId);
|
||||||
buf.append(", version=").append(_targetVersion);
|
buf.append(", version=").append(_targetVersion);
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ package com.threerings.whirled.spot.data {
|
|||||||
|
|
||||||
import flash.geom.Rectangle;
|
import flash.geom.Rectangle;
|
||||||
|
|
||||||
|
import com.threerings.util.Hashable;
|
||||||
|
|
||||||
import com.threerings.io.Streamable;
|
import com.threerings.io.Streamable;
|
||||||
import com.threerings.io.ObjectInputStream;
|
import com.threerings.io.ObjectInputStream;
|
||||||
import com.threerings.io.ObjectOutputStream;
|
import com.threerings.io.ObjectOutputStream;
|
||||||
@@ -33,38 +35,23 @@ import com.threerings.presents.dobj.DSet_Entry;
|
|||||||
* Contains information on clusters.
|
* Contains information on clusters.
|
||||||
*/
|
*/
|
||||||
public class Cluster extends Rectangle
|
public class Cluster extends Rectangle
|
||||||
implements DSet_Entry, Streamable
|
implements DSet_Entry, Streamable /*, Hashable */
|
||||||
{
|
{
|
||||||
/** A unique identifier for this cluster (also the distributed object
|
/** A unique identifier for this cluster (also the distributed object
|
||||||
* id of the cluster chat object). */
|
* id of the cluster chat object). */
|
||||||
public var clusterOid :int;
|
public var clusterOid :int;
|
||||||
|
|
||||||
// documentation inherited from interface DSet_Entry
|
public function Cluster ()
|
||||||
public function getKey () :Object
|
{
|
||||||
|
// nothing needed
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
|
public function hashCode () :int
|
||||||
{
|
{
|
||||||
return clusterOid;
|
return clusterOid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface Streamable
|
|
||||||
public function writeObject (out :ObjectOutputStream) :void
|
|
||||||
{
|
|
||||||
out.writeInt(x);
|
|
||||||
out.writeInt(y);
|
|
||||||
out.writeInt(width);
|
|
||||||
out.writeInt(height);
|
|
||||||
out.writeInt(clusterOid);
|
|
||||||
}
|
|
||||||
|
|
||||||
// documentation inherited from interface Streamable
|
|
||||||
public function readObject (ins :ObjectInputStream) :void
|
|
||||||
{
|
|
||||||
x = ins.readInt();
|
|
||||||
y = ins.readInt();
|
|
||||||
width = ins.readInt();
|
|
||||||
height = ins.readInt();
|
|
||||||
clusterOid = ins.readInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a string representation of this instance.
|
* Generates a string representation of this instance.
|
||||||
*/
|
*/
|
||||||
@@ -72,5 +59,26 @@ public class Cluster extends Rectangle
|
|||||||
{
|
{
|
||||||
return super.toString() + ", clusterOid=" + clusterOid;
|
return super.toString() + ", clusterOid=" + clusterOid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// documentation inherited from interface DSet_Entry
|
||||||
|
public function getKey () :Object
|
||||||
|
{
|
||||||
|
return clusterOid;
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited from interface Streamable
|
||||||
|
public function readObject (ins :ObjectInputStream) :void
|
||||||
|
{
|
||||||
|
clusterOid = ins.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited from interface Streamable
|
||||||
|
public function writeObject (out :ObjectOutputStream) :void
|
||||||
|
{
|
||||||
|
out.writeInt(clusterOid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Used for {@link #getKey}. */
|
||||||
|
protected var _key :int;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,17 +39,9 @@ public class ModifyPortalsUpdate extends SceneUpdate
|
|||||||
/** The portals to be added to the scene. */
|
/** The portals to be added to the scene. */
|
||||||
public var portalsAdded :TypedArray;
|
public var portalsAdded :TypedArray;
|
||||||
|
|
||||||
/**
|
public function ModifyPortalsUpdate ()
|
||||||
* Initialize the update with all necessary data.
|
|
||||||
*/
|
|
||||||
public function initialize (
|
|
||||||
targetId :int, targetVersion :int, removed :TypedArray,
|
|
||||||
added :TypedArray) :void
|
|
||||||
{
|
{
|
||||||
init(targetId, targetVersion);
|
// nothing needed
|
||||||
|
|
||||||
portalsRemoved = removed;
|
|
||||||
portalsAdded = added;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function apply (model :SceneModel) :void
|
override public function apply (model :SceneModel) :void
|
||||||
@@ -72,20 +64,33 @@ public class ModifyPortalsUpdate extends SceneUpdate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function writeObject (out :ObjectOutputStream) :void
|
/**
|
||||||
|
* Initialize the update with all necessary data.
|
||||||
|
*/
|
||||||
|
public function initialize (
|
||||||
|
targetId :int, targetVersion :int, removed :TypedArray,
|
||||||
|
added :TypedArray) :void
|
||||||
{
|
{
|
||||||
super.writeObject(out);
|
init(targetId, targetVersion);
|
||||||
|
|
||||||
out.writeObject(portalsRemoved);
|
portalsRemoved = removed;
|
||||||
out.writeObject(portalsAdded);
|
portalsAdded = added;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// from interface Streamable
|
||||||
override public function readObject (ins :ObjectInputStream) :void
|
override public function readObject (ins :ObjectInputStream) :void
|
||||||
{
|
{
|
||||||
super.readObject(ins);
|
super.readObject(ins);
|
||||||
|
|
||||||
portalsRemoved = (ins.readObject() as TypedArray);
|
portalsRemoved = (ins.readObject() as TypedArray);
|
||||||
portalsAdded = (ins.readObject() as TypedArray);
|
portalsAdded = (ins.readObject() as TypedArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// from interface Streamable
|
||||||
|
override public function writeObject (out :ObjectOutputStream) :void
|
||||||
|
{
|
||||||
|
super.writeObject(out);
|
||||||
|
out.writeObject(portalsRemoved);
|
||||||
|
out.writeObject(portalsAdded);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,12 @@ package com.threerings.whirled.spot.data {
|
|||||||
|
|
||||||
import com.threerings.util.ClassUtil;
|
import com.threerings.util.ClassUtil;
|
||||||
import com.threerings.util.Cloneable;
|
import com.threerings.util.Cloneable;
|
||||||
|
import com.threerings.util.Hashable;
|
||||||
|
import com.threerings.util.StringBuilder;
|
||||||
|
|
||||||
import com.threerings.io.Streamable;
|
|
||||||
import com.threerings.io.ObjectInputStream;
|
import com.threerings.io.ObjectInputStream;
|
||||||
import com.threerings.io.ObjectOutputStream;
|
import com.threerings.io.ObjectOutputStream;
|
||||||
|
import com.threerings.io.SimpleStreamableObject;
|
||||||
|
|
||||||
import com.threerings.util.Hashable;
|
import com.threerings.util.Hashable;
|
||||||
|
|
||||||
@@ -39,15 +41,14 @@ import com.threerings.util.Hashable;
|
|||||||
* when using this portal and the location at which the body sprite should
|
* when using this portal and the location at which the body sprite should
|
||||||
* appear in that target scene.
|
* appear in that target scene.
|
||||||
*/
|
*/
|
||||||
public class Portal
|
public class Portal extends SimpleStreamableObject
|
||||||
implements Streamable, Hashable, Cloneable
|
implements Cloneable, Hashable
|
||||||
{
|
{
|
||||||
/** This portal's unique identifier. */
|
/** This portal's unique identifier. */
|
||||||
public var portalId :int;
|
public var portalId :int;
|
||||||
|
|
||||||
/** The location of the portal. Typically this is a base Location (2d)
|
/** The location of the portal.
|
||||||
* class, but different games could use a different subclass of
|
* This field is present on client and server, it is streamed specially. */
|
||||||
* Location. */
|
|
||||||
public var loc :Location;
|
public var loc :Location;
|
||||||
|
|
||||||
/** The scene identifier of the scene to which a body will exit when
|
/** The scene identifier of the scene to which a body will exit when
|
||||||
@@ -55,16 +56,13 @@ public class Portal
|
|||||||
public var targetSceneId :int;
|
public var targetSceneId :int;
|
||||||
|
|
||||||
/** The portal identifier of the portal at which a body will enter
|
/** 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 var targetPortalId :int;
|
public var targetPortalId :int;
|
||||||
|
|
||||||
/**
|
public function Portal ()
|
||||||
* Returns a location instance configured with the location and
|
|
||||||
* orientation of this portal.
|
|
||||||
*/
|
|
||||||
public function getLocation () :Location
|
|
||||||
{
|
{
|
||||||
return (loc.clone() as Location);
|
// nothing needed
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,34 +77,10 @@ public class Portal
|
|||||||
return loc.getOpposite();
|
return loc.getOpposite();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// documentation inherited from interface Hashable
|
||||||
* Returns true if the portal has a potentially valid target scene and
|
public function hashCode () :int
|
||||||
* portal id (they are not guaranteed to exist, but they are at least
|
|
||||||
* potentially valid values rather than 0).
|
|
||||||
*/
|
|
||||||
public function isValid () :Boolean
|
|
||||||
{
|
{
|
||||||
return (targetSceneId > 0) &&
|
return portalId;
|
||||||
// the target portal must be positive, or -1
|
|
||||||
((targetPortalId > 0) || (targetPortalId == -1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// documentation inherited from interface Streamable
|
|
||||||
public function writeObject (out :ObjectOutputStream) :void
|
|
||||||
{
|
|
||||||
out.writeShort(portalId);
|
|
||||||
out.writeObject(loc);
|
|
||||||
out.writeInt(targetSceneId);
|
|
||||||
out.writeShort(targetPortalId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// documentation inherited from interface Streamable
|
|
||||||
public function readObject (ins :ObjectInputStream) :void
|
|
||||||
{
|
|
||||||
portalId = ins.readShort();
|
|
||||||
loc = (ins.readObject() as Location);
|
|
||||||
targetSceneId = ins.readInt();
|
|
||||||
targetPortalId = ins.readShort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface Cloneable
|
// documentation inherited from interface Cloneable
|
||||||
@@ -127,16 +101,53 @@ public class Portal
|
|||||||
((other as Portal).portalId == portalId);
|
((other as Portal).portalId == portalId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface Hashable
|
/**
|
||||||
public function hashCode () :int
|
* Returns a location instance configured with the location and
|
||||||
|
* orientation of this portal.
|
||||||
|
*/
|
||||||
|
public function getLocation () :Location
|
||||||
{
|
{
|
||||||
return portalId;
|
return (loc.clone() as Location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toString () :String
|
/**
|
||||||
|
* Returns true if the portal has a potentially valid target scene and
|
||||||
|
* portal id (they are not guaranteed to exist, but they are at least
|
||||||
|
* potentially valid values rather than 0).
|
||||||
|
*/
|
||||||
|
public function isValid () :Boolean
|
||||||
{
|
{
|
||||||
return "Portal[id=" + portalId + ", destScene=" + targetSceneId +
|
return (targetSceneId > 0) &&
|
||||||
", loc=" + loc + "].";
|
// the target portal must be positive, or -1
|
||||||
|
((targetPortalId > 0) || (targetPortalId == -1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// from interface Streamable
|
||||||
|
override public function readObject (ins :ObjectInputStream) :void
|
||||||
|
{
|
||||||
|
super.readObject(ins);
|
||||||
|
portalId = ins.readShort();
|
||||||
|
loc = (ins.readObject() as Location);
|
||||||
|
targetSceneId = ins.readInt();
|
||||||
|
targetPortalId = ins.readShort();
|
||||||
|
}
|
||||||
|
|
||||||
|
// from interface Streamable
|
||||||
|
override public function writeObject (out :ObjectOutputStream) :void
|
||||||
|
{
|
||||||
|
super.writeObject(out);
|
||||||
|
out.writeShort(portalId);
|
||||||
|
out.writeObject(loc);
|
||||||
|
out.writeInt(targetSceneId);
|
||||||
|
out.writeShort(targetPortalId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// from SimpleStreamableObject
|
||||||
|
override protected function toStringBuilder (buf :StringBuilder): void
|
||||||
|
{
|
||||||
|
buf.append("id=").append(portalId);
|
||||||
|
buf.append(", destScene=").append(targetSceneId);
|
||||||
|
buf.append(", loc=").append(loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import com.threerings.util.Hashable;
|
|||||||
|
|
||||||
import com.threerings.io.ObjectInputStream;
|
import com.threerings.io.ObjectInputStream;
|
||||||
import com.threerings.io.ObjectOutputStream;
|
import com.threerings.io.ObjectOutputStream;
|
||||||
|
import com.threerings.io.SimpleStreamableObject;
|
||||||
|
|
||||||
import com.threerings.presents.dobj.DSet_Entry;
|
import com.threerings.presents.dobj.DSet_Entry;
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ import com.threerings.presents.dobj.DSet_Entry;
|
|||||||
* Extends {@link Location} with the data and functionality needed to
|
* Extends {@link Location} with the data and functionality needed to
|
||||||
* represent a particular user's location in a scene.
|
* represent a particular user's location in a scene.
|
||||||
*/
|
*/
|
||||||
public class SceneLocation
|
public class SceneLocation extends SimpleStreamableObject
|
||||||
implements DSet_Entry, Hashable
|
implements DSet_Entry, Hashable
|
||||||
{
|
{
|
||||||
/** The oid of the body that occupies this location. */
|
/** The oid of the body that occupies this location. */
|
||||||
@@ -50,10 +51,10 @@ public class SceneLocation
|
|||||||
this.bodyOid = bodyOid;
|
this.bodyOid = bodyOid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface DSet_Entry
|
// documentation inherited from interface Hashable
|
||||||
public function getKey () :Object
|
public function hashCode () :int
|
||||||
{
|
{
|
||||||
return bodyOid;
|
return loc.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface Hashable
|
// documentation inherited from interface Hashable
|
||||||
@@ -63,24 +64,29 @@ public class SceneLocation
|
|||||||
this.loc.equals((other as SceneLocation).loc);
|
this.loc.equals((other as SceneLocation).loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface Hashable
|
// documentation inherited from interface DSet_Entry
|
||||||
public function hashCode () :int
|
public function getKey () :Object
|
||||||
{
|
{
|
||||||
return loc.hashCode();
|
return bodyOid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from superinterface Streamable
|
// documentation inherited from superinterface Streamable
|
||||||
public function writeObject (out :ObjectOutputStream) :void
|
override public function readObject (ins :ObjectInputStream) :void
|
||||||
{
|
{
|
||||||
|
super.readObject(ins);
|
||||||
|
bodyOid = ins.readInt();
|
||||||
|
loc = (ins.readObject() as Location);
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited from superinterface Streamable
|
||||||
|
override public function writeObject (out :ObjectOutputStream) :void
|
||||||
|
{
|
||||||
|
super.writeObject(out);
|
||||||
out.writeInt(bodyOid);
|
out.writeInt(bodyOid);
|
||||||
out.writeObject(loc);
|
out.writeObject(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from superinterface Streamable
|
/** Used for {@link #getKey}. */
|
||||||
public function readObject (ins :ObjectInputStream) :void
|
protected var _key :int;
|
||||||
{
|
|
||||||
bodyOid = ins.readInt();
|
|
||||||
loc = (ins.readObject() as Location);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ package com.threerings.whirled.spot.data {
|
|||||||
import com.threerings.util.ArrayUtil;
|
import com.threerings.util.ArrayUtil;
|
||||||
import com.threerings.util.ClassUtil;
|
import com.threerings.util.ClassUtil;
|
||||||
|
|
||||||
import com.threerings.io.Streamable;
|
|
||||||
import com.threerings.io.ObjectInputStream;
|
import com.threerings.io.ObjectInputStream;
|
||||||
import com.threerings.io.ObjectOutputStream;
|
import com.threerings.io.ObjectOutputStream;
|
||||||
|
import com.threerings.io.SimpleStreamableObject;
|
||||||
import com.threerings.io.TypedArray;
|
import com.threerings.io.TypedArray;
|
||||||
|
|
||||||
import com.threerings.whirled.data.AuxModel;
|
import com.threerings.whirled.data.AuxModel;
|
||||||
@@ -38,8 +38,8 @@ import com.threerings.whirled.data.SceneModel;
|
|||||||
* scene and unchanging, so that portals can stably reference the target
|
* scene and unchanging, so that portals can stably reference the target
|
||||||
* portal in the scene to which they connect.
|
* portal in the scene to which they connect.
|
||||||
*/
|
*/
|
||||||
public class SpotSceneModel
|
public class SpotSceneModel extends SimpleStreamableObject
|
||||||
implements Streamable, AuxModel
|
implements AuxModel
|
||||||
{
|
{
|
||||||
/** An array containing all portals in this scene. */
|
/** An array containing all portals in this scene. */
|
||||||
public var portals :TypedArray = TypedArray.create(Portal);
|
public var portals :TypedArray = TypedArray.create(Portal);
|
||||||
@@ -49,48 +49,6 @@ public class SpotSceneModel
|
|||||||
* portal at which they would appear. */
|
* portal at which they would appear. */
|
||||||
public var defaultEntranceId :int = -1;
|
public var defaultEntranceId :int = -1;
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a portal to this scene model.
|
|
||||||
*/
|
|
||||||
public function addPortal (portal :Portal) :void
|
|
||||||
{
|
|
||||||
portals.push(portal);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a portal from this model.
|
|
||||||
*/
|
|
||||||
public function removePortal (portal :Portal) :void
|
|
||||||
{
|
|
||||||
ArrayUtil.removeFirst(portals, portal);
|
|
||||||
}
|
|
||||||
|
|
||||||
// documentation inherited from superinterface Cloneable
|
|
||||||
public function clone () :Object
|
|
||||||
{
|
|
||||||
var clazz :Class = ClassUtil.getClass(this);
|
|
||||||
var model :SpotSceneModel = new clazz();
|
|
||||||
|
|
||||||
for each (var portal :Portal in portals) {
|
|
||||||
model.portals.push(portal.clone());
|
|
||||||
}
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
// documentation inherited from interface Streamable
|
|
||||||
public function writeObject (out :ObjectOutputStream) :void
|
|
||||||
{
|
|
||||||
out.writeObject(portals);
|
|
||||||
out.writeInt(defaultEntranceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// documentation inherited from interface Streamable
|
|
||||||
public function readObject (ins :ObjectInputStream) :void
|
|
||||||
{
|
|
||||||
portals = (ins.readObject() as TypedArray);
|
|
||||||
defaultEntranceId = ins.readInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locates and returns the {@link SpotSceneModel} among the auxiliary
|
* Locates and returns the {@link SpotSceneModel} among the auxiliary
|
||||||
* scene models associated with the supplied scene
|
* scene models associated with the supplied scene
|
||||||
@@ -106,5 +64,54 @@ public class SpotSceneModel
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function SpotSceneModel ()
|
||||||
|
{
|
||||||
|
// nothing needed
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a portal from this model.
|
||||||
|
*/
|
||||||
|
public function removePortal (portal :Portal) :void
|
||||||
|
{
|
||||||
|
ArrayUtil.removeFirst(portals, portal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a portal to this scene model.
|
||||||
|
*/
|
||||||
|
public function addPortal (portal :Portal) :void
|
||||||
|
{
|
||||||
|
portals.push(portal);
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited from superinterface Cloneable
|
||||||
|
public function clone () :Object
|
||||||
|
{
|
||||||
|
var clazz :Class = ClassUtil.getClass(this);
|
||||||
|
var model :SpotSceneModel = new clazz();
|
||||||
|
|
||||||
|
for each (var portal :Portal in portals) {
|
||||||
|
model.portals.push(portal.clone());
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
// from interface Streamable
|
||||||
|
override public function readObject (ins :ObjectInputStream) :void
|
||||||
|
{
|
||||||
|
super.readObject(ins);
|
||||||
|
portals = (ins.readObject() as TypedArray);
|
||||||
|
defaultEntranceId = ins.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
// from interface Streamable
|
||||||
|
override public function writeObject (out :ObjectOutputStream) :void
|
||||||
|
{
|
||||||
|
super.writeObject(out);
|
||||||
|
out.writeObject(portals);
|
||||||
|
out.writeInt(defaultEntranceId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.samskivert.util.StringUtil;
|
|||||||
import com.threerings.io.ObjectInputStream;
|
import com.threerings.io.ObjectInputStream;
|
||||||
import com.threerings.io.ObjectOutputStream;
|
import com.threerings.io.ObjectOutputStream;
|
||||||
import com.threerings.io.Streamable;
|
import com.threerings.io.Streamable;
|
||||||
|
import com.threerings.util.ActionScript;
|
||||||
|
|
||||||
import com.threerings.whirled.Log;
|
import com.threerings.whirled.Log;
|
||||||
|
|
||||||
@@ -142,6 +143,7 @@ public class SceneUpdate
|
|||||||
* scene id and version fields are stored in separate columns and the rest
|
* scene id and version fields are stored in separate columns and the rest
|
||||||
* if the representation is contained in an opaque blob.
|
* if the representation is contained in an opaque blob.
|
||||||
*/
|
*/
|
||||||
|
@ActionScript(omit=true)
|
||||||
public void persistTo (ObjectOutputStream out)
|
public void persistTo (ObjectOutputStream out)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
@@ -157,6 +159,7 @@ public class SceneUpdate
|
|||||||
* Unserializes this instance from the bare representation created by
|
* Unserializes this instance from the bare representation created by
|
||||||
* {@link #persistTo}.
|
* {@link #persistTo}.
|
||||||
*/
|
*/
|
||||||
|
@ActionScript(omit=true)
|
||||||
public void unpersistFrom (ObjectInputStream in)
|
public void unpersistFrom (ObjectInputStream in)
|
||||||
throws IOException, ClassNotFoundException
|
throws IOException, ClassNotFoundException
|
||||||
{
|
{
|
||||||
@@ -182,6 +185,7 @@ public class SceneUpdate
|
|||||||
* An extensible mechanism for generating a string representation of
|
* An extensible mechanism for generating a string representation of
|
||||||
* this instance.
|
* this instance.
|
||||||
*/
|
*/
|
||||||
|
@ActionScript(name="toStringBuilder")
|
||||||
protected void toString (StringBuilder buf)
|
protected void toString (StringBuilder buf)
|
||||||
{
|
{
|
||||||
buf.append("sceneId=").append(_targetId);
|
buf.append("sceneId=").append(_targetId);
|
||||||
@@ -197,5 +201,6 @@ public class SceneUpdate
|
|||||||
protected transient int _targetVersion;
|
protected transient int _targetVersion;
|
||||||
|
|
||||||
/** Used when serializing this update for storage in the database. */
|
/** Used when serializing this update for storage in the database. */
|
||||||
|
@ActionScript(omit=true)
|
||||||
protected static ThreadLocal<Boolean> _dbSer = new ThreadLocal<Boolean>();
|
protected static ThreadLocal<Boolean> _dbSer = new ThreadLocal<Boolean>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import java.awt.Rectangle;
|
|||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
import com.threerings.io.Streamable;
|
import com.threerings.io.Streamable;
|
||||||
|
import com.threerings.util.ActionScript;
|
||||||
|
|
||||||
import com.threerings.presents.dobj.DSet;
|
import com.threerings.presents.dobj.DSet;
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ public class Cluster extends Rectangle
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
|
@ActionScript(omit=true)
|
||||||
public boolean equals (Object other)
|
public boolean equals (Object other)
|
||||||
{
|
{
|
||||||
if (other instanceof Cluster) {
|
if (other instanceof Cluster) {
|
||||||
|
|||||||
Reference in New Issue
Block a user