Rather than trying to restrict the drift adjustment into a sane range, just stop applying it if it's huge or tiny.
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@656 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -221,12 +221,12 @@ public abstract class FrameManager
|
||||
* Returns the highest drift ratio our timer has seen. 1.0 means no drift (and is what we return
|
||||
* if we're not using a CalibratingTimer)
|
||||
*/
|
||||
public double getMaxTimerDriftRatio ()
|
||||
public float getMaxTimerDriftRatio ()
|
||||
{
|
||||
if (_timer instanceof CalibratingTimer) {
|
||||
return ((CalibratingTimer)_timer).getMaxDriftRatio();
|
||||
} else {
|
||||
return 1.0;
|
||||
return 1.0F;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public abstract class CalibratingTimer
|
||||
/**
|
||||
* Returns the greatest drift ratio we've had to compensate for.
|
||||
*/
|
||||
public double getMaxDriftRatio ()
|
||||
public float getMaxDriftRatio ()
|
||||
{
|
||||
return _maxDriftRatio;
|
||||
}
|
||||
@@ -132,8 +132,13 @@ public abstract class CalibratingTimer
|
||||
|
||||
} else if (drift > MAX_ALLOWED_DRIFT_RATIO || drift < MIN_ALLOWED_DRIFT_RATIO) {
|
||||
log.warning("Calibrating", "drift", drift);
|
||||
// Keep the drift somewhat sane between .01 and 10
|
||||
_driftRatio = (float)Math.min(Math.max(.01, drift), 10);
|
||||
// Ignore the drift if it's hugely out of range. That indicates general clock insanity,
|
||||
// and we just want to stay out of the way.
|
||||
if (drift < 100 * MAX_ALLOWED_DRIFT_RATIO && drift > MIN_ALLOWED_DRIFT_RATIO / 100) {
|
||||
_driftRatio = drift;
|
||||
} else {
|
||||
_driftRatio = 1.0F;
|
||||
}
|
||||
if (Math.abs(drift - 1.0) > Math.abs(_maxDriftRatio - 1.0)) {
|
||||
_maxDriftRatio = drift;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user