Skip to content

Commit

Permalink
add "headless" mode in which the server does not write back to Config…
Browse files Browse the repository at this point in the history
…uration
  • Loading branch information
IcculusC committed Nov 29, 2024
1 parent 1d08572 commit e5753ac
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Projects/Server/Configuration/ServerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static class ServerConfiguration
private static ServerSettings _settings;
private static bool m_Mocked;

public static bool Headless => _settings.Headless;
public static List<string> AssemblyDirectories => _settings.AssemblyDirectories;

public static HashSet<string> DataDirectories => _settings.DataDirectories;
Expand Down Expand Up @@ -287,7 +288,7 @@ public static void Load(bool mocked = false)

Core.Expansion = currentExpansion;

if (updated)
if (updated && !Headless)
{
Save();
Console.Write("Server configuration saved to ");
Expand Down
3 changes: 3 additions & 0 deletions Projects/Server/Configuration/ServerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ namespace Server;

public class ServerSettings
{
[JsonPropertyName("headless")]
public bool Headless { get; set; } = false;

[JsonPropertyName("assemblyDirectories")]
public List<string> AssemblyDirectories { get; set; } = new();

Expand Down
2 changes: 1 addition & 1 deletion Projects/Server/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public static void RunEventLoop()
#if DEBUG
const bool idleCPU = true;
#else
var idleCPU = ServerConfiguration.GetOrUpdateSetting("core.enableIdleCPU", false);
var idleCPU = ServerConfiguration.Headless ? ServerConfiguration.GetSetting("core.enableIdleCPU", false) : ServerConfiguration.GetOrUpdateSetting("core.enableIdleCPU", false);
#endif

var cycleCount = _cyclesPerSecond.Length;
Expand Down
3 changes: 2 additions & 1 deletion Projects/Server/Network/PacketHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public PacketHandler(int packetID, int length, bool inGameOnly, bool outGameOnly

public int PacketID { get; }

public virtual int GetLength(NetState ns) => _length;
public virtual int GetLength() => _length;
public virtual int GetLength(NetState ns) => GetLength();

public delegate*<NetState, SpanReader, void> OnReceive { get; }

Expand Down

0 comments on commit e5753ac

Please sign in to comment.