add config options: ListenIP, AllowChaos, ...

and FirstEventTimer
This commit is contained in:
Robert Paciorek 2024-03-01 00:38:47 +00:00
parent 69a6761423
commit fb2596d3be
6 changed files with 42 additions and 8 deletions

View File

@ -24,8 +24,10 @@ internal static class Configuration {
} }
internal sealed class ServerConfiguration { internal sealed class ServerConfiguration {
public bool EnableChat { get; set; } = true; public string ListenIP { get; set; } = string.Empty;
public int Port { get; set; } = 9933; public int Port { get; set; } = 9933;
public int EventTimer { get; set; } = 30; public int EventTimer { get; set; } = 30;
public int FirstEventTimer { get; set; } = 10;
public bool EnableChat { get; set; } = true;
public bool AllowChaos { get; set; } = false;
} }

View File

@ -26,7 +26,7 @@ class WorldEvent {
startTimeString = startTime.ToString("MM/dd/yyyy HH:mm:ss"); startTimeString = startTime.ToString("MM/dd/yyyy HH:mm:ss");
uid = "sodoff"; uid = "sodoff";
state = State.End; state = State.End;
ScheduleEvent(10); // WE_ != WEN_ ScheduleEvent(Configuration.ServerConfiguration.FirstEventTimer); // WE_ != WEN_
} }
// controlled (init/reset) by Reset() // controlled (init/reset) by Reset()

View File

@ -84,7 +84,7 @@ public class PlayerData {
if (keyValPairs.TryGetValue("U", out string userdata)) { if (keyValPairs.TryGetValue("U", out string userdata)) {
PetMounted = (userdata == "0" || userdata == "1"); PetMounted = (userdata == "0" || userdata == "1");
} }
if (PetMounted && if (PetMounted && !Configuration.ServerConfiguration.AllowChaos &&
(GeometryType == PetGeometryType.Default && PetAge < PetAge.Teen (GeometryType == PetGeometryType.Default && PetAge < PetAge.Teen
|| GeometryType == PetGeometryType.Terror && PetAge < PetAge.Titan) || GeometryType == PetGeometryType.Terror && PetAge < PetAge.Titan)
) { ) {

View File

@ -3,5 +3,20 @@ using sodoffmmo.Core;
using System.Net; using System.Net;
Configuration.Initialize(); Configuration.Initialize();
Server server = new(IPAddress.Any, Configuration.ServerConfiguration.Port);
Server server;
if (String.IsNullOrEmpty(Configuration.ServerConfiguration.ListenIP) || Configuration.ServerConfiguration.ListenIP == "*") {
server = new(
IPAddress.IPv6Any,
Configuration.ServerConfiguration.Port,
true
);
} else {
server = new(
IPAddress.Parse(Configuration.ServerConfiguration.ListenIP),
Configuration.ServerConfiguration.Port,
false
);
}
await server.Run(); await server.Run();

View File

@ -9,11 +9,13 @@ public class Server {
readonly int port; readonly int port;
readonly IPAddress ipAddress; readonly IPAddress ipAddress;
readonly bool IPv6AndIPv4;
ModuleManager moduleManager = new(); ModuleManager moduleManager = new();
public Server(IPAddress ipAdress, int port) { public Server(IPAddress ipAdress, int port, bool IPv6AndIPv4) {
this.ipAddress = ipAdress; this.ipAddress = ipAdress;
this.port = port; this.port = port;
this.IPv6AndIPv4 = IPv6AndIPv4;
} }
public async Task Run() { public async Task Run() {
@ -21,7 +23,8 @@ public class Server {
using Socket listener = new(ipAddress.AddressFamily, using Socket listener = new(ipAddress.AddressFamily,
SocketType.Stream, SocketType.Stream,
ProtocolType.Tcp); ProtocolType.Tcp);
if (IPv6AndIPv4)
listener.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, 0);
listener.Bind(new IPEndPoint(ipAddress, port)); listener.Bind(new IPEndPoint(ipAddress, port));
await Listen(listener); await Listen(listener);
} }

View File

@ -1,7 +1,21 @@
{ {
"ServerConfiguration": { "ServerConfiguration": {
"// ListenIP": "Listening IP address for the asset server, default is '*' which represents all IPv4 and IPv6 addresses",
"ListenIP": "*",
"// Port": "Listening port number for the MMO server",
"Port": 9933, "Port": 9933,
"// EnableChat": "When true, in-game chat will be enabled",
"EnableChat": true, "EnableChat": true,
"EventTimer": 30
"// FirstEventTimer": "time to start of first world event (battle ship event) after start MMO server",
"FirstEventTimer": 10,
"// EventTimer": "time between start of world events (battle ship events)",
"EventTimer": 30,
"// AllowChaos": "disable server side exploit protection",
"AllowChaos": false
} }
} }