Fix serverTime diff: ignore serverTime when it is zero

This commit is contained in:
Him188 2021-09-05 13:57:58 +08:00
parent 103dad3f69
commit 2247543f65

View File

@ -158,9 +158,10 @@ internal class StatSvc {
bot.configuration.statHeartbeatPeriodMillis = it.times(1000).toLong()
}
val diffMillis = packet.origin.serverTime - currentTimeMillis()
val serverTime = packet.origin.serverTime
val diffMillis = if (serverTime == 0L) 0 else serverTime - currentTimeMillis()
bot.components[ClockHolder].server = Clock.SystemDefault.adjusted(diffMillis)
bot.network.logger.info { "Server time updated, diff: ${diffMillis}ms=${diffMillis.millisToHumanReadableString()}" }
bot.network.logger.info { "Server time updated, serverTime: $serverTime, diff: ${diffMillis}ms=${diffMillis.millisToHumanReadableString()}" }
}
fun online(