Skip to content

Commit

Permalink
potentially fix session getting stuck after ~25 days
Browse files Browse the repository at this point in the history
  • Loading branch information
compujuckel committed Sep 18, 2023
1 parent 159ea2e commit f9d6422
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class HandshakeResponse : IOutgoingNetworkPacket, IIncomingNetworkPacket
public IEnumerable<string>? ChecksumPaths;
public string LegalTyres = "";
public int RandomSeed;
public long CurrentTime;
public int CurrentTime;

public void ToWriter(ref PacketWriter writer)
{
Expand Down Expand Up @@ -93,7 +93,7 @@ public void ToWriter(ref PacketWriter writer)

writer.Write(TrackGrip);
writer.Write(SessionId);
writer.Write<long>(SessionTime);
writer.Write(SessionTime);

writer.Write(ChecksumCount);
if (ChecksumPaths != null)
Expand All @@ -102,7 +102,7 @@ public void ToWriter(ref PacketWriter writer)

writer.WriteUTF8String(LegalTyres);
writer.Write(RandomSeed);
writer.Write<uint>((uint)CurrentTime);
writer.Write(CurrentTime);
}

public void FromReader(PacketReader reader)
Expand Down Expand Up @@ -177,6 +177,6 @@ public void FromReader(PacketReader reader)

LegalTyres = reader.ReadUTF8String();
RandomSeed = reader.Read<int>();
CurrentTime = reader.Read<uint>();
CurrentTime = reader.Read<int>();
}
}
2 changes: 1 addition & 1 deletion AssettoServer/Network/Tcp/ACTcpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ private async Task ReceiveLoopAsync()
SessionTime = _sessionManager.CurrentSession.SessionTimeMilliseconds,
ChecksumCount = (byte)_checksumManager.TrackChecksums.Count,
ChecksumPaths = _checksumManager.TrackChecksums.Keys,
CurrentTime = _sessionManager.ServerTimeMilliseconds,
CurrentTime = 0, // Ignored by AC
LegalTyres = cfg.LegalTyres,
RandomSeed = 123,
SessionCount = (byte)_configuration.Sessions.Count,
Expand Down
1 change: 1 addition & 0 deletions AssettoServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ internal static async Task Main(string[] args)
&& inst.Name != "http.server.request.duration"
&& inst.Name != "kestrel.connection.duration"
&& inst.Name != "aspnetcore.routing.match_attempts"
&& inst.Name != "dns.lookups.duration"
&& !inst.Name.StartsWith("http.client.");
});

Expand Down
2 changes: 1 addition & 1 deletion AssettoServer/Server/SessionState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class SessionState
public int EndTime { get; set; } // TODO
public long StartTimeMilliseconds { get; set; }
public int TimeLeftMilliseconds => Configuration.Infinite ? Configuration.Time * 60_000 : (int)(StartTimeMilliseconds + Configuration.Time * 60_000 - _timeSource.ServerTimeMilliseconds);
public int SessionTimeMilliseconds => (int)(_timeSource.ServerTimeMilliseconds - StartTimeMilliseconds);
public long SessionTimeMilliseconds => _timeSource.ServerTimeMilliseconds - StartTimeMilliseconds;
public uint TargetLap { get; set; } = 0;
public uint LeaderLapCount { get; set; } = 0;
public bool LeaderHasCompletedLastLap { get; set; } = false;
Expand Down

0 comments on commit f9d6422

Please sign in to comment.