Skip to content

Commit

Permalink
- write reference extra configuration that includes all values
Browse files Browse the repository at this point in the history
- split ACExtraConfiguration.cs into different files
- add JSON schema generation for extra_cfg.yml (WIP)
  • Loading branch information
compujuckel committed Jan 13, 2024
1 parent 457a329 commit 0d77c96
Show file tree
Hide file tree
Showing 38 changed files with 687 additions and 488 deletions.
1 change: 1 addition & 0 deletions AssettoServer/AssettoServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageReference Include="McMaster.NETCore.Plugins" Version="1.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NJsonSchema" Version="11.0.0" />
<PackageReference Include="NodaTime" Version="3.1.10" />
<PackageReference Include="Open.NAT" Version="2.1.0">
<NoWarn>NU1701</NoWarn>
Expand Down
11 changes: 2 additions & 9 deletions AssettoServer/ExceptionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static void PrintExceptionHelp(Exception ex, bool isContentManager, strin
Console.WriteLine("Press D to join the official Discord server");
Console.WriteLine("Press any other key to exit");

if (!ACServer.IsDebugBuild)
if (!Program.IsDebugBuild)
{
var key = Console.ReadKey();
if (key.Key == ConsoleKey.D)
Expand All @@ -97,14 +97,7 @@ public static void PrintExceptionHelp(Exception ex, bool isContentManager, strin
}
else if (crashReportPath != null && key.Key == ConsoleKey.C)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Process.Start("explorer.exe", $"/select, \"{crashReportPath}\"");
}
else
{
OpenURL(crashReportPath);
}
Process.Start("explorer.exe", $"/select, \"{crashReportPath}\"");
}
}

Expand Down
2 changes: 1 addition & 1 deletion AssettoServer/Logging.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using AssettoServer.Server.Configuration;
using AssettoServer.Server.Configuration.Extra;
using Serilog;
using Serilog.Events;
using Serilog.Sinks.Grafana.Loki;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ internal static OnlineEventInfo ParseClientMessage(Type messageType)
PacketType = GenerateKey(structure)
};

if (ACServer.IsDebugBuild)
if (Program.IsDebugBuild)
{
Log.Debug("Parsed client message for {Class}, Type {Type:X}, Structure {Structure}",
messageType.Name, ret.PacketType, ret.Structure);
Expand Down
1 change: 1 addition & 0 deletions AssettoServer/Network/Http/ConfigurationController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using AssettoServer.Network.Http.Authentication;
using AssettoServer.Server.Configuration;
using AssettoServer.Server.Configuration.Serialization;
using AssettoServer.Shared.Network.Http.Responses;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
Expand Down
1 change: 1 addition & 0 deletions AssettoServer/Network/Http/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using AssettoServer.Server.Blacklist;
using AssettoServer.Server.CMContentProviders;
using AssettoServer.Server.Configuration;
using AssettoServer.Server.Configuration.Serialization;
using AssettoServer.Server.GeoParams;
using AssettoServer.Server.OpenSlotFilters;
using AssettoServer.Server.Plugin;
Expand Down
1 change: 1 addition & 0 deletions AssettoServer/Network/Tcp/ACTcpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using AssettoServer.Server;
using AssettoServer.Server.Blacklist;
using AssettoServer.Server.Configuration;
using AssettoServer.Server.Configuration.Extra;
using AssettoServer.Server.OpenSlotFilters;
using AssettoServer.Server.Weather;
using AssettoServer.Shared.Model;
Expand Down
1 change: 1 addition & 0 deletions AssettoServer/Network/Udp/UdpPluginServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using AssettoServer.Network.Tcp;
using AssettoServer.Server;
using AssettoServer.Server.Configuration;
using AssettoServer.Server.Configuration.Kunos;
using AssettoServer.Server.Plugin;
using AssettoServer.Server.Weather;
using AssettoServer.Shared.Network.Packets;
Expand Down
6 changes: 6 additions & 0 deletions AssettoServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ namespace AssettoServer;

internal static class Program
{
#if DEBUG
public static readonly bool IsDebugBuild = true;
#else
public static readonly bool IsDebugBuild = false;
#endif

[UsedImplicitly(ImplicitUseKindFlags.Assign, ImplicitUseTargetFlags.WithMembers)]
private class Options
{
Expand Down
6 changes: 0 additions & 6 deletions AssettoServer/Server/ACServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ namespace AssettoServer.Server;

public class ACServer : CriticalBackgroundService
{
#if DEBUG
public const bool IsDebugBuild = true;
#else
public const bool IsDebugBuild = false;
#endif

private readonly ACServerConfiguration _configuration;
private readonly SessionManager _sessionManager;
private readonly EntryCarManager _entryCarManager;
Expand Down
1 change: 1 addition & 0 deletions AssettoServer/Server/Ai/AiState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Numerics;
using AssettoServer.Server.Ai.Splines;
using AssettoServer.Server.Configuration;
using AssettoServer.Server.Configuration.Extra;
using AssettoServer.Server.Weather;
using AssettoServer.Shared.Model;
using AssettoServer.Shared.Network.Packets.Outgoing;
Expand Down
2 changes: 1 addition & 1 deletion AssettoServer/Server/CSPServerScriptProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void AddScriptInternal(Func<IActionResult> script, string? debugFilename
var data = new IniData();
var scriptSection = data[$"SCRIPT_{10 + Scripts.Count}-{debugFilename}"];

if (ACServer.IsDebugBuild && !string.IsNullOrEmpty(debugFilename))
if (Program.IsDebugBuild && !string.IsNullOrEmpty(debugFilename))
{
Log.Warning("Loading Lua script {File} locally, don't forget to sync changes for release", debugFilename);
scriptSection["SCRIPT"] = debugFilename;
Expand Down
Loading

0 comments on commit 0d77c96

Please sign in to comment.