mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-16 08:25:28 +00:00
Optimize SteamTimeDifference
In very unlikely case of actually having exactly the same time difference, notice the difference between no value and value of 0
This commit is contained in:
@@ -64,7 +64,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static readonly SemaphoreSlim TimeSemaphore = new SemaphoreSlim(1);
|
private static readonly SemaphoreSlim TimeSemaphore = new SemaphoreSlim(1);
|
||||||
|
|
||||||
private static short SteamTimeDifference;
|
private static short? SteamTimeDifference;
|
||||||
|
|
||||||
private readonly SemaphoreSlim ConfirmationsSemaphore = new SemaphoreSlim(1);
|
private readonly SemaphoreSlim ConfirmationsSemaphore = new SemaphoreSlim(1);
|
||||||
|
|
||||||
@@ -270,13 +270,13 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<uint> GetSteamTime() {
|
internal async Task<uint> GetSteamTime() {
|
||||||
if (SteamTimeDifference != 0) {
|
if (SteamTimeDifference.HasValue) {
|
||||||
return (uint) (Utilities.GetUnixTime() + SteamTimeDifference);
|
return (uint) (Utilities.GetUnixTime() + SteamTimeDifference.GetValueOrDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
await TimeSemaphore.WaitAsync().ConfigureAwait(false);
|
await TimeSemaphore.WaitAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
if (SteamTimeDifference == 0) {
|
if (!SteamTimeDifference.HasValue) {
|
||||||
uint serverTime = Bot.ArchiWebHandler.GetServerTime();
|
uint serverTime = Bot.ArchiWebHandler.GetServerTime();
|
||||||
if (serverTime != 0) {
|
if (serverTime != 0) {
|
||||||
SteamTimeDifference = (short) (serverTime - Utilities.GetUnixTime());
|
SteamTimeDifference = (short) (serverTime - Utilities.GetUnixTime());
|
||||||
@@ -284,7 +284,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TimeSemaphore.Release();
|
TimeSemaphore.Release();
|
||||||
return (uint) (Utilities.GetUnixTime() + SteamTimeDifference);
|
return (uint) (Utilities.GetUnixTime() + SteamTimeDifference.GetValueOrDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GenerateTokenForTime(uint time) {
|
private string GenerateTokenForTime(uint time) {
|
||||||
|
|||||||
Reference in New Issue
Block a user