Example #1
0
 def __updateDebug(self):
     self.__debugCallBackId = None
     player = BigWorld.player()
     if player is None or not hasattr(player, 'playerVehicleID'):
         return
     isLaggingNow = False
     ping = min(BigWorld.LatencyInfo().value[3] * 1000, 999)
     if ping < 999:
         ping = max(1, ping - 500.0 * constants.SERVER_TICK_LENGTH)
     fps = BigWorld.getFPS()[0]
     self.call('battle.debugBar.updateInfo',
               [int(fps), int(ping), isLaggingNow])
     self.__debugCallBackId = BigWorld.callback(0.01, self.__updateDebug)
 def __syncWithServerTurretYaw(self, turretYaw):
     vehicle = self._avatar.vehicle
     if vehicle is not None:
         serverTurretYaw, _ = vehicle.getServerGunAngles()
         diff = serverTurretYaw - turretYaw
         absDeviation = min(diff % (2.0 * pi), -diff % (2.0 * pi))
         allowedDeviation = self.__TURRET_YAW_ALLOWED_ERROR_CONST
         allowedDeviation += self.__TURRET_YAW_ALLOWED_ERROR_FACTOR * self.__maxTurretRotationSpeed
         if absDeviation > allowedDeviation:
             latency = BigWorld.LatencyInfo().value[3]
             errorDueLatency = latency * self.__maxTurretRotationSpeed
             if absDeviation > allowedDeviation + errorDueLatency:
                 return serverTurretYaw
     return turretYaw
Example #3
0
 def __syncWithServerTurretYaw(self, turretYaw):
     """Applies correction to given turretYaw, to keep it in sync with the server (WOTD-14553).
     :return: corrected turretYaw (unchanged in most cases)
     """
     vehicle = self.__avatar.vehicle
     if vehicle is not None:
         serverTurretYaw, _ = vehicle.getServerGunAngles()
         diff = serverTurretYaw - turretYaw
         absDeviation = min(diff % (2.0 * pi), -diff % (2.0 * pi))
         allowedDeviation = self.__TURRET_YAW_ALLOWED_ERROR_CONST
         allowedDeviation += self.__TURRET_YAW_ALLOWED_ERROR_FACTOR * self.__maxTurretRotationSpeed
         if absDeviation > allowedDeviation:
             latency = BigWorld.LatencyInfo().value[3]
             errorDueLatency = latency * self.__maxTurretRotationSpeed
             if absDeviation > allowedDeviation + errorDueLatency:
                 return serverTurretYaw
     return turretYaw
 def __calculateStats(self):
     fps = BigWorld.getFPS()
     fpsMin = fps[2]
     fpsMed = fps[1]
     self.setFpsMin(fpsMin)
     self.setFpsMed(fpsMed)
     self.updateFPSRanges(fpsMed)
     ping = BigWorld.LatencyInfo(
     ).value[3] * 1000 - SERVER_TICK_LENGTH * 0.5 * 1000
     ping = max(1, ping)
     self.setPingMin(ping)
     self.setPingMed(ping)
     player = BigWorld.player()
     if player.movementFilter():
         self.setLostRatioMed(player.filter.dataLost)
     self.__calculateStatsCallback = BigWorld.callback(
         1.0, self.__calculateStats)
Example #5
0
    def _update(self):
        replayCtrl = BattleReplay.g_replayCtrl
        if replayCtrl.isPlaying and replayCtrl.fps > 0:
            fps = BigWorld.getFPS()[1]
            fpsReplay = int(replayCtrl.fps)
            ping = replayCtrl.ping
            isLaggingNow = replayCtrl.isLaggingNow
        else:
            fpsReplay = -1
            player = BigWorld.player()
            isLaggingNow = player.filter.isLaggingNow if player is not None else False
            if not isLaggingNow:
                for vehicleID in self._visibleVehicles:
                    vehicle = BigWorld.entities[vehicleID]
                    if vehicle is not None and vehicle.isAlive():
                        try:
                            if vehicle.filter.isLagginNow:
                                isLaggingNow = True
                                break
                        except AttributeError:
                            pass

            avgLatency = BigWorld.LatencyInfo().value[3]
            if avgLatency:
                ping = min(avgLatency * 1000, 999)
                if ping < 999:
                    ping = max(1, ping - 500.0 * constants.SERVER_TICK_LENGTH)
            else:
                ping = 999
            fpsInfo = BigWorld.getFPS()
            g_statistics.update(fpsInfo, ping, isLaggingNow)
            fps = fpsInfo[1]
            if replayCtrl.isRecording:
                replayCtrl.setFpsPingLag(fps, ping, isLaggingNow)
        if self._debugPanelUI is not None:
            self._debugPanelUI.updateDebugInfo(int(ping),
                                               int(fps),
                                               isLaggingNow,
                                               fpsReplay=fpsReplay)
        return
 def updatePing(self):
     stats = self.clientStatus
     if stats is None:
         return
     stats.currTime = BigWorld.time()
     replayCtrl = BattleReplay.g_replayCtrl
     if replayCtrl.isPlaying:
         ping = replayCtrl.ping
         fps = BigWorld.getFPS()[1]
         fpsReplay = int(replayCtrl.fps)
     else:
         ping = BigWorld.statPing()
         fps = BigWorld.getFPS()[1]
         fpsReplay = -1
     try:
         stats.ping = int(ping)
         stats.fps = int(fps)
     except (ValueError, OverflowError):
         stats.ping = -1
         stats.fps = -1
     stats.fpsReplay = fpsReplay
     latency = BigWorld.LatencyInfo().value
     stats.latency = latency[3]
Example #7
0
    def __update(self):
        player = BigWorld.player()
        if player is None or not hasattr(player, 'playerVehicleID'):
            return
        fps = 0
        recordedFps = -1
        ping = 0
        isLaggingNow = False
        replayCtrl = BattleReplay.g_replayCtrl
        if replayCtrl.isPlaying and replayCtrl.fps > 0:
            fps = BigWorld.getFPS()[1]
            recordedFps = replayCtrl.fps
            ping = replayCtrl.ping
            isLaggingNow = replayCtrl.isLaggingNow
        else:
            isLaggingNow = player.filter.isLaggingNow
            if not isLaggingNow:
                for v in BigWorld.entities.values():
                    if _isVehicleEntity(v):
                        if not v.isPlayer:
                            if v.isAlive() and isinstance(v.filter, BigWorld.WGVehicleFilter) and v.filter.isLaggingNow:
                                isLaggingNow = True
                                break

            ping = min(BigWorld.LatencyInfo().value[3] * 1000, 999)
            if ping < 999:
                ping = max(1, ping - 500.0 * constants.SERVER_TICK_LENGTH)
            fpsInfo = BigWorld.getFPS()
            from helpers.statistics import g_statistics
            g_statistics.update(fpsInfo, ping, isLaggingNow)
            fps = fpsInfo[1]
            if replayCtrl.isRecording:
                replayCtrl.setFpsPingLag(fps, ping, isLaggingNow)
        try:
            self.__performanceStats.updateDebugInfo(int(fps), int(ping), isLaggingNow, int(recordedFps))
        except:
            pass
 def _calcPing(self):
     ping = BigWorld.LatencyInfo(
     ).value[3] * 1000 - SERVER_TICK_LENGTH * 0.5 * 1000
     return max(1, int(ping))