Checkpoint, I've got an interactive 2d scene mostly working.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4151 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-05-26 21:54:34 +00:00
parent 9c33f1de53
commit fdfce50d01
20 changed files with 113 additions and 47 deletions
@@ -27,7 +27,7 @@ import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationService;
import com.threerings.presents.client.InvocationListener;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.data.ListenerMarshaller;
import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller;
import com.threerings.presents.dobj.InvocationResponseEvent;
import com.threerings.util.Name;
@@ -56,7 +56,7 @@ public class ChatMarshaller extends InvocationMarshaller
// documentation inherited from interface
public function broadcast (arg1 :Client, arg2 :String, arg3 :InvocationListener) :void
{
var listener3 :ListenerMarshaller = new ListenerMarshaller();
var listener3 :InvocationMarshaller_ListenerMarshaller = new InvocationMarshaller_ListenerMarshaller();
listener3.listener = arg3;
sendRequest(arg1, BROADCAST, [ arg2, listener3 ]);
}
@@ -2,11 +2,11 @@ package com.threerings.crowd.chat.data {
import com.threerings.util.Long;
import com.threerings.presents.data.ListenerMarshaller;
import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller;
import com.threerings.crowd.chat.client.TellListener;
public class TellMarshaller extends ListenerMarshaller
public class TellMarshaller extends InvocationMarshaller_ListenerMarshaller
{
/** The method id used to dispatch {@link #tellSucceeded}
* responses. */
@@ -1,10 +1,10 @@
package com.threerings.crowd.data {
import com.threerings.presents.data.ListenerMarshaller;
import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller;
import com.threerings.crowd.client.MoveListener
public class LocationMarshaller_MoveMarshaller extends ListenerMarshaller
public class LocationMarshaller_MoveMarshaller extends InvocationMarshaller_ListenerMarshaller
{
/** The method id used to dispatch {@link #moveSucceeded}
* responses. */
@@ -63,7 +63,7 @@ public class OccupantInfo
public static const X_STATUS :Array = [ "active", "idle", "discon" ];
/** The body object id of this occupant (and our entry key). */
public var bodyOid :Integer;
public var bodyOid :int;
/** The username of this occupant. */
public var username :Name;
@@ -74,7 +74,7 @@ public class OccupantInfo
/** Access to the body object id as an int. */
public function getBodyOid () :int
{
return bodyOid.value;
return bodyOid;
}
// documentation inherited from interface DSet_Entry
@@ -86,7 +86,7 @@ public class OccupantInfo
// documentation inherited from superinterface Streamable
public function writeObject (out :ObjectOutputStream) :void
{
out.writeObject(bodyOid);
out.writeObject(new Integer(bodyOid));
out.writeObject(username);
out.writeByte(status);
}
@@ -94,7 +94,7 @@ public class OccupantInfo
// documentation inherited from superinterface Streamable
public function readObject (ins :ObjectInputStream) :void
{
bodyOid = (ins.readField(Integer) as Integer);
bodyOid = (ins.readField(Integer) as Integer).value;
username = (ins.readObject() as Name);
status = ins.readByte();
}
@@ -15,6 +15,7 @@ public class ArrayStreamer extends Streamer
public function ArrayStreamer (jname :String = "[Ljava.lang.Object;")
{
super(TypedArray, jname);
trace("got new ArrayStreamer for " + jname);
var secondChar :String = jname.charAt(1);
if (secondChar === "[") {
@@ -68,6 +69,7 @@ public class ArrayStreamer extends Streamer
{
var ta :TypedArray = new TypedArray(_jname);
ta.length = ins.readInt();
trace("Read array length as: " + ta.length);
return ta;
}
@@ -5,7 +5,7 @@ import mx.collections.ArrayCollection;
import com.threerings.util.HashMap;
import com.threerings.presents.data.ListenerMarshaller;
import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller;
import com.threerings.presents.dobj.DEvent;
import com.threerings.presents.dobj.DObject;
@@ -138,8 +138,9 @@ public class InvocationDirector
{
// configure any invocation listener marshallers among the args
for each (var arg :Object in args) {
if (arg is ListenerMarshaller) {
var lm :ListenerMarshaller = (arg as ListenerMarshaller);
if (arg is InvocationMarshaller_ListenerMarshaller) {
var lm :InvocationMarshaller_ListenerMarshaller =
(arg as InvocationMarshaller_ListenerMarshaller);
lm.callerOid = _clobj.getOid();
lm.requestId = nextRequestId();
lm.mapStamp = new Date().getTime();
@@ -187,8 +188,8 @@ public class InvocationDirector
protected function handleInvocationResponse
(reqId :int, methodId :int, args :Array) :void
{
var listener :ListenerMarshaller =
(_listeners.remove(reqId) as ListenerMarshaller);
var listener :InvocationMarshaller_ListenerMarshaller =
(_listeners.remove(reqId) as InvocationMarshaller_ListenerMarshaller);
if (listener == null) {
log.warning("Received invocation response for which we have " +
"no registered listener [reqId=" + reqId +
@@ -270,8 +271,8 @@ public class InvocationDirector
{
var then :Number = now - LISTENER_MAX_AGE;
for (var skey :String in _listeners.keys()) {
var lm :ListenerMarshaller =
(_listeners.get(skey) as ListenerMarshaller);
var lm :InvocationMarshaller_ListenerMarshaller =
(_listeners.get(skey) as InvocationMarshaller_ListenerMarshaller);
if (lm.mapStamp < then) {
_listeners.remove(skey);
}
@@ -5,7 +5,8 @@ import com.threerings.presents.client.GotTimeBaseListener;
import com.threerings.presents.dobj.InvocationResponseEvent;
// TODO: this will be autogenerated
public class GotTimeBaseMarshaller extends ListenerMarshaller
public class GotTimeBaseMarshaller
extends InvocationMarshaller_ListenerMarshaller
implements GotTimeBaseListener
{
public static const GOT_TIME_OID :int = 1;
@@ -2,7 +2,8 @@ package com.threerings.presents.data {
import com.threerings.presents.client.ConfirmListener;
public class ConfirmMarshaller extends ListenerMarshaller
public class InvocationMarshaller_ConfirmMarshaller
extends InvocationMarshaller_ListenerMarshaller
implements ConfirmListener
{
public static const REQUEST_PROCESSED :int = 1;
@@ -11,7 +11,7 @@ import com.threerings.presents.client.InvocationListener;
import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.dobj.InvocationResponseEvent;
public class ListenerMarshaller
public class InvocationMarshaller_ListenerMarshaller
implements Streamable, InvocationListener
{
/** The method id used to dispatch a requestFailed response. */
@@ -40,8 +40,14 @@ public class CompoundEvent extends DEvent
/**
* Constructs a compound event and prepares it for operation.
*/
public function CompoundEvent (target :DObject, omgr :DObjectManager)
public function CompoundEvent (
target :DObject = null, omgr :DObjectManager = null)
{
if (target == null) {
super();
return;
}
super(target.getOid());
// sanity check
@@ -10,7 +10,7 @@ import com.threerings.util.StringBuilder;
public /* abstract */ class DEvent
implements Streamable
{
public function DEvent (targetOid :int)
public function DEvent (targetOid :int = 0)
{
_toid = targetOid;
}
+10 -2
View File
@@ -28,8 +28,16 @@ public class ClassUtil
public static function getClassByName (cname :String) :Class
{
// see also ApplicationDomain.currentDomain.getClass(cname)
return (getDefinitionByName(cname.replace("::", ".")) as Class);
try {
// see also ApplicationDomain.currentDomain.getClass(cname)
return (getDefinitionByName(cname.replace("::", ".")) as Class);
} catch (error :ReferenceError) {
var log :Log = Log.getLog(ClassUtil);
log.warning("Unknown class: " + cname);
log.logStackTrace(error);
}
return null; // error case
}
public static function isFinal (type :Class) :Boolean
+1
View File
@@ -268,6 +268,7 @@ public class Hashtable
*/
protected function indexFor (hash :int) :int
{
// TODO: improve?
return Math.abs(hash) % _entries.length;
}
@@ -21,6 +21,8 @@
package com.threerings.whirled.data {
import com.threerings.util.Integer;
import com.threerings.presents.client.Client;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.whirled.client.SceneService;
@@ -44,7 +46,7 @@ public class SceneMarshaller extends InvocationMarshaller
{
var listener4 :SceneMarshaller_SceneMoveMarshaller = new SceneMarshaller_SceneMoveMarshaller();
listener4.listener = arg4;
sendRequest(arg1, MOVE_TO, [ arg2, arg3, listener4 ]);
sendRequest(arg1, MOVE_TO, [ new Integer(arg2), new Integer(arg3), listener4 ]);
}
}
@@ -1,8 +1,10 @@
package com.threerings.whirled.data {
import com.threerings.util.Integer;
import com.threerings.io.TypedArray;
import com.threerings.presents.data.ListenerMarshaller;
import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller;
import com.threerings.crowd.data.PlaceConfig;
@@ -12,7 +14,7 @@ import com.threerings.whirled.client.SceneService_SceneMoveListener;
import com.threerings.whirled.data.SceneModel;
import com.threerings.whirled.data.SceneUpdate;
public class SceneMarshaller_SceneMoveMarshaller extends ListenerMarshaller
public class SceneMarshaller_SceneMoveMarshaller extends InvocationMarshaller_ListenerMarshaller
implements SceneService_SceneMoveListener
{
/** The method id used to dispatch {@link #moveSucceeded}
@@ -24,7 +26,7 @@ public class SceneMarshaller_SceneMoveMarshaller extends ListenerMarshaller
{
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, MOVE_SUCCEEDED,
[ arg1, arg2 ]));
[ new Integer(arg1), arg2 ]));
}
/** The method id used to dispatch {@link #moveSucceededWithScene}
@@ -36,7 +38,7 @@ public class SceneMarshaller_SceneMoveMarshaller extends ListenerMarshaller
{
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, MOVE_SUCCEEDED_WITH_SCENE,
[ arg1, arg2, arg3 ]));
[ new Integer(arg1), arg2, arg3 ]));
}
/** The method id used to dispatch {@link #moveSucceededWithUpdates}
@@ -48,7 +50,7 @@ public class SceneMarshaller_SceneMoveMarshaller extends ListenerMarshaller
{
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, MOVE_SUCCEEDED_WITH_UPDATES,
[ arg1, arg2, arg3 ]));
[ new Integer(arg1), arg2, arg3 ]));
}
// documentation inherited
@@ -57,17 +59,17 @@ public class SceneMarshaller_SceneMoveMarshaller extends ListenerMarshaller
switch (methodId) {
case MOVE_SUCCEEDED:
(listener as SceneService_SceneMoveListener).moveSucceeded(
args[0] as int, args[1] as PlaceConfig);
(args[0] as Integer).value, args[1] as PlaceConfig);
return;
case MOVE_SUCCEEDED_WITH_SCENE:
(listener as SceneService_SceneMoveListener).moveSucceededWithScene(
args[0] as int, args[1] as PlaceConfig, args[2] as SceneModel);
(args[0] as Integer).value, args[1] as PlaceConfig, args[2] as SceneModel);
return;
case MOVE_SUCCEEDED_WITH_UPDATES:
(listener as SceneService_SceneMoveListener).moveSucceededWithUpdates(
args[0] as int, args[1] as PlaceConfig, args[2] as TypedArray);
(args[0] as Integer).value, args[1] as PlaceConfig, args[2] as TypedArray);
return;
default:
@@ -83,17 +83,21 @@ public class SceneModel
out.writeInt(sceneId);
out.writeField(name);
out.writeInt(version);
out.writeField(auxModels);
out.writeObject(auxModels);
}
// documentation inherited from interface Streamable
public function readObject (ins :ObjectInputStream) :void
{
trace("Reading sceneId");
sceneId = ins.readInt();
trace("Reading name (sceneId=" + sceneId + ")");
name = (ins.readField(String) as String);
trace("Reading version (name=" + name + ")");
version = ins.readInt();
auxModels = (ins.readField("[Lcom.threerings.whirled.data.AuxModel;")
as TypedArray);
trace("Reading auxes (version=" + version + ")");
auxModels = (ins.readObject() as TypedArray);
trace("auxes=" + auxModels);
}
/**
@@ -23,6 +23,9 @@ package com.threerings.whirled.spot.data {
import com.threerings.util.Hashable;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.presents.dobj.DSet_Entry;
/**
@@ -65,5 +68,19 @@ public class SceneLocation
{
return loc.hashCode();
}
// documentation inherited from superinterface Streamable
public function writeObject (out :ObjectOutputStream) :void
{
out.writeInt(bodyOid);
out.writeObject(loc);
}
// documentation inherited from superinterface Streamable
public function readObject (ins :ObjectInputStream) :void
{
bodyOid = ins.readInt();
loc = (ins.readObject() as Location);
}
}
}
@@ -28,7 +28,7 @@ import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationService;
import com.threerings.presents.client.ConfirmListener;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.data.ConfirmMarshaller;
import com.threerings.presents.data.InvocationMarshaller_ConfirmMarshaller;
import com.threerings.presents.dobj.InvocationResponseEvent;
import com.threerings.whirled.client.SceneService;
import com.threerings.whirled.client.SceneService_SceneMoveListener;
@@ -52,7 +52,7 @@ public class SpotMarshaller extends InvocationMarshaller
// documentation inherited from interface
public function changeLocation (arg1 :Client, arg2 :int, arg3 :Location, arg4 :ConfirmListener) :void
{
var listener4 :ConfirmMarshaller = new ConfirmMarshaller();
var listener4 :InvocationMarshaller_ConfirmMarshaller = new InvocationMarshaller_ConfirmMarshaller();
listener4.listener = arg4;
sendRequest(arg1, CHANGE_LOCATION, [
new Integer(arg2), arg3, listener4
@@ -76,7 +76,7 @@ public class SpotMarshaller extends InvocationMarshaller
// documentation inherited from interface
public function joinCluster (arg1 :Client, arg2 :int, arg3 :ConfirmListener) :void
{
var listener3 :ConfirmMarshaller = new ConfirmMarshaller();
var listener3 :InvocationMarshaller_ConfirmMarshaller = new InvocationMarshaller_ConfirmMarshaller();
listener3.listener = arg3;
sendRequest(arg1, JOIN_CLUSTER, [
new Integer(arg2), listener3
@@ -85,14 +85,14 @@ public class SpotSceneModel
// documentation inherited from interface Streamable
public function writeObject (out :ObjectOutputStream) :void
{
out.writeField(portals);
out.writeObject(portals);
out.writeInt(defaultEntranceId);
}
// documentation inherited from interface Streamable
public function readObject (ins :ObjectInputStream) :void
{
portals = (ins.readField(TypedArray.getJavaType(Portal)) as TypedArray);
portals = (ins.readObject() as TypedArray);
defaultEntranceId = ins.readInt();
}
@@ -21,6 +21,9 @@
package com.threerings.whirled.spot.data {
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.presents.dobj.DSet;
import com.threerings.whirled.data.SceneObject;
@@ -52,7 +55,7 @@ public class SpotSceneObject extends SceneObject
*/
public function addToOccupantLocs (elem :DSet_Entry) :void
{
requestEntryAdd(OCCUPANT_LOCS, occupantLocs, elem);
requestEntryAdd(OCCUPANT_LOCS, elem);
}
/**
@@ -62,7 +65,7 @@ public class SpotSceneObject extends SceneObject
*/
public function removeFromOccupantLocs (key :Object) :void
{
requestEntryRemove(OCCUPANT_LOCS, occupantLocs, key);
requestEntryRemove(OCCUPANT_LOCS, key);
}
/**
@@ -72,7 +75,7 @@ public class SpotSceneObject extends SceneObject
*/
public function updateOccupantLocs (elem :DSet_Entry) :void
{
requestEntryUpdate(OCCUPANT_LOCS, occupantLocs, elem);
requestEntryUpdate(OCCUPANT_LOCS, elem);
}
/**
@@ -98,7 +101,7 @@ public class SpotSceneObject extends SceneObject
*/
public function addToClusters (elem :DSet_Entry) :void
{
requestEntryAdd(CLUSTERS, clusters, elem);
requestEntryAdd(CLUSTERS, elem);
}
/**
@@ -108,7 +111,7 @@ public class SpotSceneObject extends SceneObject
*/
public function removeFromClusters (key :Object) :void
{
requestEntryRemove(CLUSTERS, clusters, key);
requestEntryRemove(CLUSTERS, key);
}
/**
@@ -118,7 +121,7 @@ public class SpotSceneObject extends SceneObject
*/
public function updateClusters (elem :DSet_Entry) :void
{
requestEntryUpdate(CLUSTERS, clusters, elem);
requestEntryUpdate(CLUSTERS, elem);
}
/**
@@ -137,5 +140,23 @@ public class SpotSceneObject extends SceneObject
this.clusters = value;
}
// AUTO-GENERATED: METHODS END
// documentation inherited
public override function writeObject (out :ObjectOutputStream) :void
{
super.writeObject(out);
out.writeObject(occupantLocs);
out.writeObject(clusters);
}
// documentation inherited
public override function readObject (ins :ObjectInputStream) :void
{
super.readObject(ins);
occupantLocs = (ins.readObject() as DSet);
clusters = (ins.readObject() as DSet);
}
}
}