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 function DefaultSceneConfig ()
|
||||
{
|
||||
// nothing needed
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
override public function getManagerClassName () :String
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.threerings.util.Cloneable;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
import com.threerings.io.Streamable;
|
||||
import com.threerings.io.SimpleStreamableObject;
|
||||
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
|
||||
* server to the client.
|
||||
*/
|
||||
public class SceneModel
|
||||
implements Streamable, Cloneable
|
||||
public class SceneModel extends SimpleStreamableObject
|
||||
implements Cloneable
|
||||
{
|
||||
/** This scene's unique identifier. */
|
||||
public var sceneId :int;
|
||||
@@ -56,6 +56,21 @@ public class SceneModel
|
||||
/** Auxiliary scene model information. */
|
||||
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.
|
||||
*/
|
||||
@@ -81,31 +96,23 @@ public class SceneModel
|
||||
}
|
||||
|
||||
// documentation inherited from interface Streamable
|
||||
public function writeObject (out :ObjectOutputStream) :void
|
||||
{
|
||||
out.writeInt(sceneId);
|
||||
out.writeField(name);
|
||||
out.writeInt(version);
|
||||
out.writeObject(auxModels);
|
||||
}
|
||||
|
||||
// documentation inherited from interface Streamable
|
||||
public function readObject (ins :ObjectInputStream) :void
|
||||
override public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
super.readObject(ins);
|
||||
sceneId = ins.readInt();
|
||||
name = (ins.readField(String) as String);
|
||||
version = ins.readInt();
|
||||
auxModels = (ins.readObject() as TypedArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a blank scene model.
|
||||
*/
|
||||
public static function blankSceneModel () :SceneModel
|
||||
// documentation inherited from interface Streamable
|
||||
override public function writeObject (out :ObjectOutputStream) :void
|
||||
{
|
||||
var model :SceneModel = new SceneModel();
|
||||
populateBlankSceneModel(model);
|
||||
return model;
|
||||
super.writeObject(out);
|
||||
out.writeInt(sceneId);
|
||||
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.Streamable;
|
||||
|
||||
import com.threerings.util.Cloneable;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* copies of scenes.
|
||||
*/
|
||||
public class SceneUpdate
|
||||
implements Streamable /*, Cloneable */
|
||||
implements Streamable, Cloneable
|
||||
{
|
||||
/**
|
||||
* 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
|
||||
public function SceneUpdate ()
|
||||
{
|
||||
_targetId = targetId;
|
||||
_targetVersion = targetVersion;
|
||||
// nothing needed
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* to applying the update.
|
||||
@@ -90,54 +138,17 @@ public class SceneUpdate
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
// from interface Cloneable
|
||||
public function clone () :Object
|
||||
{
|
||||
// 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 + "].");
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
throw new Error("Not implemented.");
|
||||
}
|
||||
|
||||
/**
|
||||
* An extensible mechanism for generating a string representation of
|
||||
* this instance.
|
||||
*/
|
||||
protected function toStringBuf (buf :StringBuilder) :void
|
||||
protected function toStringBuilder (buf :StringBuilder) :void
|
||||
{
|
||||
buf.append("sceneId=").append(_targetId);
|
||||
buf.append(", version=").append(_targetVersion);
|
||||
|
||||
Reference in New Issue
Block a user