Further work on dynamic scene updating.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2648 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2003-06-11 02:48:07 +00:00
parent d9e38c1d35
commit 087f26b41b
4 changed files with 39 additions and 12 deletions
@@ -1,8 +1,9 @@
//
// $Id: SceneUpdate.java,v 1.1 2003/02/12 07:23:31 mdb Exp $
// $Id: SceneUpdate.java,v 1.2 2003/06/11 02:48:07 mdb Exp $
package com.threerings.whirled.data;
import com.samskivert.util.StringUtil;
import com.threerings.io.Streamable;
import com.threerings.whirled.Log;
@@ -12,18 +13,18 @@ import com.threerings.whirled.Log;
* be stored persistently and sent to clients to update their own local
* copies of scenes.
*/
public abstract class SceneUpdate
public class SceneUpdate
implements Streamable, Cloneable
{
/**
* Creates a scene update that will operate on a scene with the
* specified target scene and version number.
* 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 SceneUpdate (int targetId, int targetVersion)
public void init (int targetId, int targetVersion)
{
_targetId = targetId;
_targetVersion = targetVersion;
@@ -72,7 +73,7 @@ public abstract 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.applyToScene</code>.
* being sure to call <code>super.apply</code>.
*/
public void apply (SceneModel model)
{
@@ -104,6 +105,8 @@ public abstract class SceneUpdate
{
buf.append("sceneId=").append(_targetId);
buf.append(", version=").append(_targetVersion);
buf.append(", ");
StringUtil.fieldsToString(buf, this);
}
/** The version number of the scene on which we operate. */
@@ -1,5 +1,5 @@
//
// $Id: SceneManager.java,v 1.12 2003/02/12 07:23:31 mdb Exp $
// $Id: SceneManager.java,v 1.13 2003/06/11 02:48:07 mdb Exp $
package com.threerings.whirled.server;
@@ -32,6 +32,14 @@ public class SceneManager extends PlaceManager
return _scene;
}
/**
* Returns {@link UpdateList#getUpdates} for this scene's updates.
*/
public SceneUpdate[] getUpdates (int fromVersion)
{
return _updates.getUpdates(fromVersion);
}
/**
* Called by the scene registry once the scene manager has been
* created (and initialized), but before it is started up.
@@ -125,6 +133,8 @@ public class SceneManager extends PlaceManager
return false;
}
});
// TODO: broadcast the update to all occupants of the scene
}
// documentation inherited
@@ -1,5 +1,5 @@
//
// $Id: SceneProvider.java,v 1.16 2003/04/17 19:17:07 mdb Exp $
// $Id: SceneProvider.java,v 1.17 2003/06/11 02:48:07 mdb Exp $
package com.threerings.whirled.server;
@@ -16,6 +16,7 @@ import com.threerings.whirled.Log;
import com.threerings.whirled.client.SceneService.SceneMoveListener;
import com.threerings.whirled.data.SceneCodes;
import com.threerings.whirled.data.SceneModel;
import com.threerings.whirled.data.SceneUpdate;
import com.threerings.whirled.data.ScenedBodyObject;
/**
@@ -106,7 +107,13 @@ public class SceneProvider
// check to see if they need a newer version of the scene data
SceneModel model = scmgr.getScene().getSceneModel();
if (sceneVersion < model.version) {
listener.moveSucceededWithScene(ploid, config, model);
// try getting updates
SceneUpdate[] updates = scmgr.getUpdates(sceneVersion);
if (updates != null) {
listener.moveSucceededWithUpdates(ploid, config, updates);
} else {
listener.moveSucceededWithScene(ploid, config, model);
}
} else {
listener.moveSucceeded(ploid, config);
}
@@ -1,5 +1,5 @@
//
// $Id: ZoneProvider.java,v 1.14 2003/02/12 07:23:32 mdb Exp $
// $Id: ZoneProvider.java,v 1.15 2003/06/11 02:48:07 mdb Exp $
package com.threerings.whirled.zone.server;
@@ -13,6 +13,7 @@ import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.LocationProvider;
import com.threerings.whirled.data.SceneModel;
import com.threerings.whirled.data.SceneUpdate;
import com.threerings.whirled.data.ScenedBodyObject;
import com.threerings.whirled.server.SceneManager;
import com.threerings.whirled.server.SceneRegistry;
@@ -163,8 +164,14 @@ public class ZoneProvider
// check to see if they need a newer version of the scene data
SceneModel model = scmgr.getScene().getSceneModel();
if (sceneVersion < model.version) {
// then send the moveTo response
listener.moveSucceededWithScene(ploid, config, summary, model);
SceneUpdate[] updates = scmgr.getUpdates(sceneVersion);
if (updates != null) {
listener.moveSucceededWithUpdates(
ploid, config, summary, updates);
} else {
listener.moveSucceededWithScene(
ploid, config, summary, model);
}
} else {
// then send the moveTo response