From c76474a640fa5ab0c91339a264c06cf59f0d5a7f Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 24 Sep 2007 20:49:01 +0000 Subject: [PATCH] Drop forced move requests if they come in while we have a move pending. We may have to do some things on the server as well which blindly ejects the user from their current place, but now the worst case is that a player ends up nowhere in the event of extreme lag and clicks the button to go somewhere again rather than having a move half-completed get aborted and the code ending up confused and not properly able to clean up after itself. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@436 c613c5cb-e716-0410-b11b-feb51c14d237 --- .../whirled/client/SceneDirector.java | 21 ++++++++++++++++--- .../whirled/zone/client/ZoneDirector.java | 13 +++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/java/com/threerings/whirled/client/SceneDirector.java b/src/java/com/threerings/whirled/client/SceneDirector.java index 1611077d..d5e42733 100644 --- a/src/java/com/threerings/whirled/client/SceneDirector.java +++ b/src/java/com/threerings/whirled/client/SceneDirector.java @@ -119,6 +119,14 @@ public class SceneDirector extends BasicDirector return _scene; } + /** + * Returns true if there is a pending move request. + */ + public boolean movePending () + { + return (_pendingSceneId > 0); + } + /** * Requests that this client move the specified scene. A request will be made and when the * response is received, the location observers will be notified of success or failure. @@ -167,7 +175,7 @@ public class SceneDirector extends BasicDirector boolean refuse = _locdir.checkRepeatMove(); // complain if we're over-writing a pending request - if (_pendingSceneId != -1) { + if (movePending()) { if (refuse) { Log.warning("Refusing moveTo; We have a request outstanding " + "[psid=" + _pendingSceneId + ", nsid=" + sceneId + "]."); @@ -367,11 +375,18 @@ public class SceneDirector extends BasicDirector // from interface SceneReceiver public void forcedMove (int sceneId) { - Log.info("Moving at request of server [sceneId=" + sceneId + "]."); + // if we're in the middle of a move, we can't abort it or we will screw everything up, so + // just finish up what we're doing and assume that the repeated move request was the + // spurious one as it would be in the case of lag causing rapid-fire repeat requests + if (movePending()) { + Log.info("Dropping forced move because we have a move pending " + + "[pendId=" + _pendingSceneId + ", reqId=" + sceneId + "]."); + return; + } + Log.info("Moving at request of server [sceneId=" + sceneId + "]."); // clear out our old scene and place data didLeaveScene(); - // move to the new scene moveTo(sceneId); } diff --git a/src/java/com/threerings/whirled/zone/client/ZoneDirector.java b/src/java/com/threerings/whirled/zone/client/ZoneDirector.java index ffdc4a20..0ba43cf5 100644 --- a/src/java/com/threerings/whirled/zone/client/ZoneDirector.java +++ b/src/java/com/threerings/whirled/zone/client/ZoneDirector.java @@ -244,12 +244,19 @@ public class ZoneDirector extends BasicDirector // documentation inherited from interface public void forcedMove (int zoneId, int sceneId) { - Log.info("Moving at request of server [zoneId=" + zoneId + - ", sceneId=" + sceneId + "]."); + // if we're in the middle of a move, we can't abort it or we will screw everything up, so + // just finish up what we're doing and assume that the repeated move request was the + // spurious one as it would be in the case of lag causing rapid-fire repeat requests + if (_scdir.movePending()) { + Log.info("Dropping forced move because we have a move pending " + + "[pend=" + _scdir.getPendingModel() + ", rzId=" + zoneId + + ", rsId=" + sceneId + "]."); + return; + } + Log.info("Moving at request of server [zoneId=" + zoneId + ", sceneId=" + sceneId + "]."); // clear out our old scene and place data _scdir.didLeaveScene(); - // move to the new zone and scene moveTo(zoneId, sceneId, null); }