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
This commit is contained in:
Michael Bayne
2007-09-24 20:49:01 +00:00
parent e21c14c4c1
commit c76474a640
2 changed files with 28 additions and 6 deletions
@@ -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);
}
@@ -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);
}