Prevent fastForward from happening too soon / too often

This commit is contained in:
Et0h 2014-12-03 00:40:57 +00:00
parent 85bd6266f8
commit 18784bfccc
2 changed files with 16 additions and 3 deletions

View File

@ -103,6 +103,7 @@ class SyncplayClient(object):
self._globalPaused = 0.0
self._userOffset = 0.0
self._speedChanged = False
self.behindFirstDetected = None
self._warnings = self._WarningManager(self._player, self.userlist, self.ui)
if constants.LIST_RELATIVE_CONFIGS and self._config.has_key('loadedRelativePaths') and self._config['loadedRelativePaths']:
@ -254,9 +255,17 @@ class SyncplayClient(object):
madeChangeOnPlayer = self._serverSeeked(position, setBy)
if diff > self._config['rewindThreshold'] and not doSeek and not self._config['rewindOnDesync'] == False:
madeChangeOnPlayer = self._rewindPlayerDueToTimeDifference(position, setBy)
if diff < (self._config['fastforwardThreshold'] * -1) and not doSeek and not self._config['fastforwardOnDesync'] == False:
if self.userlist.currentUser.canControl() == False or self._config['dontSlowDownWithMe'] == True:
madeChangeOnPlayer = self._fastforwardPlayerDueToTimeDifference(position, setBy)
if self._config['fastforwardOnDesync'] and (self.userlist.currentUser.canControl() == False or self._config['dontSlowDownWithMe'] == True):
if diff < constants.FASTFORWARD_BEHIND_THRESHOLD and not doSeek:
if self.behindFirstDetected is None:
self.behindFirstDetected = time.time()
else:
durationBehind = time.time() - self.behindFirstDetected
if (durationBehind > self._config['fastforwardThreshold']) and (diff < (self._config['fastforwardThreshold'] * -1)):
madeChangeOnPlayer = self._fastforwardPlayerDueToTimeDifference(position, setBy)
self.behindFirstDetected = time.time() + constants.FASTFORWARD_RESET_THRESHOLD
else:
self.behindFirstDetected = None
if self._player.speedSupported and not doSeek and not paused and not self._config['slowOnDesync'] == False:
madeChangeOnPlayer = self._slowDownToCoverTimeDifference(diff, setBy)
if paused == False and pauseChanged:
@ -599,6 +608,8 @@ class SyncplayUser(object):
def canControl(self):
if self.isController() or not utils.RoomPasswordProvider.isControlledRoom(self.room):
return True
else:
return False
class SyncplayUserlist(object):
def __init__(self, ui, client):

View File

@ -33,6 +33,8 @@ MINIMUM_REWIND_THRESHOLD = 3
DEFAULT_FASTFORWARD_THRESHOLD = 5
MINIMUM_FASTFORWARD_THRESHOLD = 2
FASTFORWARD_EXTRA_TIME = 0.25
FASTFORWARD_RESET_THRESHOLD = 3
FASTFORWARD_BEHIND_THRESHOLD = 1
SEEK_THRESHOLD = 1
SLOWDOWN_RATE = 0.95
DEFAULT_SLOWDOWN_KICKIN_THRESHOLD = 1.5