Skip to content

Commit

Permalink
new parameter LEGAL_TYRES in entry_list.ini: Allow specifying legal t…
Browse files Browse the repository at this point in the history
…yre compounds for specific cars only
  • Loading branch information
compujuckel committed Jun 1, 2024
1 parent e83057f commit ca1c175
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion AssettoServer/Network/Tcp/ACTcpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ private async Task ReceiveLoopAsync()
ChecksumCount = (byte)checksums.Count,
ChecksumPaths = checksums.Select(c => c.Key),
CurrentTime = 0, // Ignored by AC
LegalTyres = cfg.LegalTyres,
LegalTyres = EntryCar.LegalTyres,
RandomSeed = _configuration.RandomSeed,
SessionCount = (byte)_configuration.Sessions.Count,
Sessions = _configuration.Sessions,
Expand Down
1 change: 1 addition & 0 deletions AssettoServer/Server/Configuration/Kunos/EntryList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class Entry
[IniField("FIXED_SETUP")] public string? FixedSetup { get; init; } = null;
[IniField("GUID")] public string Guid { get; init; } = "";
[IniField("AI")] public AiMode AiMode { get; internal set; } = AiMode.None;
[IniField("LEGAL_TYRES")] public string? LegalTyres { get; init; }
}

public static EntryList FromFile(string path)
Expand Down
1 change: 1 addition & 0 deletions AssettoServer/Server/EntryCar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public partial class EntryCar : IEntryCar<ACTcpClient>
public long LastPongTime { get; internal set; }
public ushort Ping { get; internal set; }
public DriverOptionsFlags DriverOptionsFlags { get; internal set; }
public string LegalTyres { get; set; } = "";

public bool IsSpectator { get; internal set; }
public string Model { get; }
Expand Down
27 changes: 15 additions & 12 deletions AssettoServer/Server/EntryCarManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,21 +226,24 @@ internal void Initialize()
var driverOptions = CSPDriverOptions.Parse(entry.Skin);
var aiMode = _configuration.Extra.EnableAi ? entry.AiMode : AiMode.None;

EntryCars[i] = _entryCarFactory(entry.Model, entry.Skin, (byte)i);
EntryCars[i].SpectatorMode = entry.SpectatorMode;
EntryCars[i].Ballast = entry.Ballast;
EntryCars[i].Restrictor = entry.Restrictor;
EntryCars[i].FixedSetup = entry.FixedSetup;
EntryCars[i].DriverOptionsFlags = driverOptions;
EntryCars[i].AiMode = aiMode;
EntryCars[i].AiEnableColorChanges = driverOptions.HasFlag(DriverOptionsFlags.AllowColorChange);
EntryCars[i].AiControlled = aiMode != AiMode.None;
EntryCars[i].NetworkDistanceSquared = MathF.Pow(_configuration.Extra.NetworkBubbleDistance, 2);
EntryCars[i].OutsideNetworkBubbleUpdateRateMs = 1000 / _configuration.Extra.OutsideNetworkBubbleRefreshRateHz;
var car = _entryCarFactory(entry.Model, entry.Skin, (byte)i);
car.SpectatorMode = entry.SpectatorMode;
car.Ballast = entry.Ballast;
car.Restrictor = entry.Restrictor;
car.FixedSetup = entry.FixedSetup;
car.DriverOptionsFlags = driverOptions;
car.AiMode = aiMode;
car.AiEnableColorChanges = driverOptions.HasFlag(DriverOptionsFlags.AllowColorChange);
car.AiControlled = aiMode != AiMode.None;
car.NetworkDistanceSquared = MathF.Pow(_configuration.Extra.NetworkBubbleDistance, 2);
car.OutsideNetworkBubbleUpdateRateMs = 1000 / _configuration.Extra.OutsideNetworkBubbleRefreshRateHz;
car.LegalTyres = entry.LegalTyres ?? _configuration.Server.LegalTyres;
if (!string.IsNullOrWhiteSpace(entry.Guid))
{
EntryCars[i].AllowedGuids = entry.Guid.Split(';').Select(ulong.Parse).ToList();
car.AllowedGuids = entry.Guid.Split(';').Select(ulong.Parse).ToList();
}

EntryCars[i] = car;
}
}
}

0 comments on commit ca1c175

Please sign in to comment.