diff --git a/src/as/com/threerings/whirled/client/SceneController.as b/src/as/com/threerings/whirled/client/SceneController.as index b3276742..2dc0e39f 100644 --- a/src/as/com/threerings/whirled/client/SceneController.as +++ b/src/as/com/threerings/whirled/client/SceneController.as @@ -71,12 +71,7 @@ public /*abstract*/ class SceneController extends PlaceController protected function sceneUpdated (update :SceneUpdate) :void { // apply the update to the scene - _wctx.getSceneDirector().getScene().updateReceived(update); - - // we don't persistify these updates in this circumstance, but - // next time we come to this scene we'll redownload the update and - // apply it to the repository; as the updates are meant to be very - // small, this shouldn't be horribly less efficient + _wctx.getSceneDirector().updateReceived(update); } /** Used to listen for scene updates. */ diff --git a/src/as/com/threerings/whirled/client/SceneDirector.as b/src/as/com/threerings/whirled/client/SceneDirector.as index 155e7d7e..aaefa228 100644 --- a/src/as/com/threerings/whirled/client/SceneDirector.as +++ b/src/as/com/threerings/whirled/client/SceneDirector.as @@ -305,13 +305,7 @@ public class SceneDirector extends BasicDirector } // store the updated scene in the repository - try { - _screp.storeSceneModel(model); - } catch (ioe :IOError) { - log.warning("Failed to update repository with updated scene " + - "[sceneId=" + model.sceneId + "]."); - log.logStackTrace(ioe); - } + persistSceneModel(model); // finally pass through to the normal success handler moveSucceeded(placeId, config); @@ -326,14 +320,7 @@ public class SceneDirector extends BasicDirector model.name + "/" + model.version + "]."); // update the model in the repository - try { - _screp.storeSceneModel(model); - } catch (ioe :IOError) { - log.warning("Failed to update repository with new version " + - "[sceneId=" + model.sceneId + - ", nvers=" + model.version + "]."); - log.logStackTrace(ioe); - } + persistSceneModel(model); // update our scene cache _scache.put(model.sceneId, model); @@ -353,6 +340,16 @@ public class SceneDirector extends BasicDirector _locdir.failedToMoveTo(sceneId, reason); } + /** + * Called by SceneController instances to tell us about an update + * to the current scene. + */ + public function updateReceived (update :SceneUpdate) :void + { + _scene.updateReceived(update); + persistSceneModel(_scene.getSceneModel()); + } + /** * Called to clean up our place and scene state information when we * leave a scene. @@ -462,6 +459,20 @@ public class SceneDirector extends BasicDirector return model; } + /** + * Persist the scene model to the clientside persistant cache. + */ + protected function persistSceneModel (model :SceneModel) :void + { + try { + _screp.storeSceneModel(model); + } catch (ioe :IOError) { + log.warning("Failed to update repository with updated scene " + + "[sceneId=" + model.sceneId + "]."); + log.logStackTrace(ioe); + } + } + // documentation inherited override public function clientDidLogoff (event :ClientEvent) :void { diff --git a/src/java/com/threerings/whirled/client/SceneController.java b/src/java/com/threerings/whirled/client/SceneController.java index 661d82c6..80109259 100644 --- a/src/java/com/threerings/whirled/client/SceneController.java +++ b/src/java/com/threerings/whirled/client/SceneController.java @@ -70,12 +70,7 @@ public abstract class SceneController extends PlaceController protected void sceneUpdated (SceneUpdate update) { // apply the update to the scene - _wctx.getSceneDirector().getScene().updateReceived(update); - - // we don't persistify these updates in this circumstance, but - // next time we come to this scene we'll redownload the update and - // apply it to the repository; as the updates are meant to be very - // small, this shouldn't be horribly less efficient + _wctx.getSceneDirector().updateReceived(update); } /** Used to listen for scene updates. */ diff --git a/src/java/com/threerings/whirled/client/SceneDirector.java b/src/java/com/threerings/whirled/client/SceneDirector.java index 4e00fed1..289d0668 100644 --- a/src/java/com/threerings/whirled/client/SceneDirector.java +++ b/src/java/com/threerings/whirled/client/SceneDirector.java @@ -309,14 +309,8 @@ public class SceneDirector extends BasicDirector return; } - // store the updated scene in the repository - try { - _screp.storeSceneModel(model); - } catch (IOException ioe) { - Log.warning("Failed to update repository with updated scene " + - "[sceneId=" + model.sceneId + "]."); - Log.logStackTrace(ioe); - } + // store the updated version + persistSceneModel(model); // finally pass through to the normal success handler moveSucceeded(placeId, config); @@ -331,14 +325,7 @@ public class SceneDirector extends BasicDirector model.name + "/" + model.version + "]."); // update the model in the repository - try { - _screp.storeSceneModel(model); - } catch (IOException ioe) { - Log.warning("Failed to update repository with new version " + - "[sceneId=" + model.sceneId + - ", nvers=" + model.version + "]."); - Log.logStackTrace(ioe); - } + persistSceneModel(model); // update our scene cache _scache.put(Integer.valueOf(model.sceneId), model); @@ -358,6 +345,16 @@ public class SceneDirector extends BasicDirector _locdir.failedToMoveTo(sceneId, reason); } + /** + * Called by SceneController instances to tell us about an update + * to the current scene. + */ + public void updateReceived (SceneUpdate update) + { + _scene.updateReceived(update); + persistSceneModel(_scene.getSceneModel()); + } + /** * Called to clean up our place and scene state information when we * leave a scene. @@ -468,6 +465,21 @@ public class SceneDirector extends BasicDirector return model; } + /** + * Persist the scene model to the clientside persistant cache. + */ + protected void persistSceneModel (SceneModel model) + { + // store the updated scene in the repository + try { + _screp.storeSceneModel(model); + } catch (IOException ioe) { + Log.warning("Failed to update repository with updated scene " + + "[sceneId=" + model.sceneId + "]."); + Log.logStackTrace(ioe); + } + } + // documentation inherited from interface public void clientDidLogoff (Client client) {