Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add "headless" mode where server does not write back to Configuration #2002

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
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
5 changes: 4 additions & 1 deletion Projects/UOContent/Misc/PacketThrottles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ public static unsafe void Initialize()
}
}

SaveDelays();
if (!ServerConfiguration.Headless)
{
SaveDelays();
}
}

[Usage("GetThrottle <packetID>")]
Expand Down
2 changes: 1 addition & 1 deletion Projects/UOContent/Misc/ServerAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void Configure()
{
var path = Path.Join(Core.BaseDirectory, _serverAccessConfigurationPath);

if (!File.Exists(path))
if (!File.Exists(path) && !ServerConfiguration.Headless)
{
SaveConfiguration();
return;
Expand Down
1 change: 1 addition & 0 deletions Projects/UOContent/Misc/ServerList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static class ServerList
private static readonly ILogger logger = LogFactory.GetLogger(typeof(ServerList));

private static IPAddress _publicAddress;
public static IPAddress PublicAddress => _publicAddress;
public static string Address { get; private set; }
public static string ServerName { get; private set; }

Expand Down
7 changes: 6 additions & 1 deletion Projects/UOContent/Network/Packets/IncomingAccountPackets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ public static void DoLogin(this NetState state, Mobile m)
}

private static int GenerateAuthID(this NetState state)
{
return GenerateAuthID(state.Version);
}

public static int GenerateAuthID(ClientVersion version)
{
if (_authIDWindow.Count == _authIDWindowSize)
{
Expand Down Expand Up @@ -375,7 +380,7 @@ private static int GenerateAuthID(this NetState state)
}
} while (_authIDWindow.ContainsKey(authID));

_authIDWindow[authID] = new AuthIDPersistence(state.Version);
_authIDWindow[authID] = new AuthIDPersistence(version);

return authID;
}
Expand Down
Loading