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:
@@ -119,6 +119,14 @@ public class SceneDirector extends BasicDirector
|
|||||||
return _scene;
|
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
|
* 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.
|
* 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();
|
boolean refuse = _locdir.checkRepeatMove();
|
||||||
|
|
||||||
// complain if we're over-writing a pending request
|
// complain if we're over-writing a pending request
|
||||||
if (_pendingSceneId != -1) {
|
if (movePending()) {
|
||||||
if (refuse) {
|
if (refuse) {
|
||||||
Log.warning("Refusing moveTo; We have a request outstanding " +
|
Log.warning("Refusing moveTo; We have a request outstanding " +
|
||||||
"[psid=" + _pendingSceneId + ", nsid=" + sceneId + "].");
|
"[psid=" + _pendingSceneId + ", nsid=" + sceneId + "].");
|
||||||
@@ -367,11 +375,18 @@ public class SceneDirector extends BasicDirector
|
|||||||
// from interface SceneReceiver
|
// from interface SceneReceiver
|
||||||
public void forcedMove (int sceneId)
|
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
|
// clear out our old scene and place data
|
||||||
didLeaveScene();
|
didLeaveScene();
|
||||||
|
|
||||||
// move to the new scene
|
// move to the new scene
|
||||||
moveTo(sceneId);
|
moveTo(sceneId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -244,12 +244,19 @@ public class ZoneDirector extends BasicDirector
|
|||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public void forcedMove (int zoneId, int sceneId)
|
public void forcedMove (int zoneId, int sceneId)
|
||||||
{
|
{
|
||||||
Log.info("Moving at request of server [zoneId=" + zoneId +
|
// if we're in the middle of a move, we can't abort it or we will screw everything up, so
|
||||||
", sceneId=" + sceneId + "].");
|
// 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
|
// clear out our old scene and place data
|
||||||
_scdir.didLeaveScene();
|
_scdir.didLeaveScene();
|
||||||
|
|
||||||
// move to the new zone and scene
|
// move to the new zone and scene
|
||||||
moveTo(zoneId, sceneId, null);
|
moveTo(zoneId, sceneId, null);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user