Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public ACServerConfigurationValidator()
server.RuleFor(s => s.KickQuorum).InclusiveBetween((ushort)0, (ushort)90);
server.RuleFor(s => s.VotingQuorum).InclusiveBetween((ushort)0, (ushort)100);
server.RuleFor(s => s.QualifyMaxWait).GreaterThanOrEqualTo((ushort)100);
server.RuleFor(s => s.ResultScreenTime).GreaterThanOrEqualTo(1);

server.RuleForEach(s => s.Weathers).ChildRules(weather =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ServerConfiguration
[IniField("SERVER", "RACE_PIT_WINDOW_END")] public short PitWindowEnd { get; init; }
[IniField("SERVER", "STABILITY_ALLOWED")] public bool StabilityAllowed { get; init; }
[IniField("SERVER", "RACE_OVER_TIME")] public int RaceOverTime { get; init; }
[IniField("SERVER", "RESULT_SCREEN_TIME")] public int ResultScreenTime { get; init; }
[IniField("SERVER", "RESULT_SCREEN_TIME")] public int ResultScreenTime { get; init; } = 1;
[IniField("SERVER", "TYRE_WEAR_RATE", Percent = true)] public float TyreConsumptionRate { get; init; }
[IniField("SERVER", "MAX_CONTACTS_PER_KM", IgnoreParsingErrors = true)] public byte MaxContactsPerKm { get; init; }
[IniField("SERVER", "LEGAL_TYRES")] public string LegalTyres { get; init; } = "";
Expand Down
43 changes: 17 additions & 26 deletions AssettoServer/Server/SessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,39 +266,30 @@ private bool IsSessionOver()
return CurrentSession.TimeLeftMilliseconds == 0;
}

if (ServerTimeMilliseconds <= CurrentSession.StartTimeMilliseconds)
if (CurrentSession.Configuration.Type is SessionType.Practice or SessionType.Qualifying)
{
return false;
}

var connectedCount = _entryCarManager.EntryCars.Count(e => e.Client != null);

if (CurrentSession.Configuration.Type != SessionType.Race)
{
return false;
}

if (CurrentSession.Configuration.IsOpen == IsOpenMode.Closed && connectedCount < 2)
{
Log.Information("Skipping race session: didn't reach minimum player count before cutoff ({PlayerCount}/2). Use 'IS_OPEN=1' to allow joining during the race", connectedCount);
return true;
}

if (CurrentSession.Configuration.IsOpen != IsOpenMode.CloseAtStart)
{
if (connectedCount > 0) return false;

Log.Information("Skipping race session: no player connected");
return true;
}

if (connectedCount < 2 && CurrentSession.IsCutoffReached)
var connectedCount = _entryCarManager.ConnectedCars.Count;

switch (CurrentSession.Configuration.IsOpen)
{
Log.Information("Skipping race session: didn't reach minimum player count before cutoff ({PlayerCount}/2). Use 'IS_OPEN=1' to allow joining during the race", connectedCount);
return true;
case IsOpenMode.Closed when connectedCount < 2:
Log.Information("Skipping race session: didn't reach minimum player count before cutoff ({PlayerCount}/2). Use 'IS_OPEN=1' to allow joining during the race", connectedCount);
return true;
case IsOpenMode.Closed:
return false;
case IsOpenMode.CloseAtStart when connectedCount >= 2 ||
ServerTimeMilliseconds <= CurrentSession.StartTimeMilliseconds:
return false;
case IsOpenMode.Open when connectedCount > 0 ||
ServerTimeMilliseconds <= CurrentSession.StartTimeMilliseconds:
return false;
}

return false;
Log.Information("Skipping race session: no player connected");
return true;
}

private void CalcOverTime()
Expand Down
2 changes: 1 addition & 1 deletion AssettoServer/Server/SessionState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class SessionState
public uint TargetLap { get; set; } = 0;
public uint LeaderLapCount { get; set; } = 0;
public bool LeaderHasCompletedLastLap { get; set; } = false;
public bool IsCutoffReached => _timeSource.ServerTimeMilliseconds > StartTimeMilliseconds - 20_000;
public bool IsCutoffReached => _timeSource.ServerTimeMilliseconds > StartTimeMilliseconds - Math.Max(30_000, Configuration.WaitTime * 1000);

public bool SessionOverFlag => Configuration switch
{
Expand Down