forked from SoDOff-Project/sodoff-mmo
add config options: ListenIP, AllowChaos, ...
and FirstEventTimer
This commit is contained in:
parent
69a6761423
commit
fb2596d3be
@ -24,8 +24,10 @@ internal static class Configuration {
|
||||
}
|
||||
|
||||
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 EventTimer { get; set; } = 30;
|
||||
|
||||
public int FirstEventTimer { get; set; } = 10;
|
||||
public bool EnableChat { get; set; } = true;
|
||||
public bool AllowChaos { get; set; } = false;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ class WorldEvent {
|
||||
startTimeString = startTime.ToString("MM/dd/yyyy HH:mm:ss");
|
||||
uid = "sodoff";
|
||||
state = State.End;
|
||||
ScheduleEvent(10); // WE_ != WEN_
|
||||
ScheduleEvent(Configuration.ServerConfiguration.FirstEventTimer); // WE_ != WEN_
|
||||
}
|
||||
|
||||
// controlled (init/reset) by Reset()
|
||||
|
@ -84,7 +84,7 @@ public class PlayerData {
|
||||
if (keyValPairs.TryGetValue("U", out string userdata)) {
|
||||
PetMounted = (userdata == "0" || userdata == "1");
|
||||
}
|
||||
if (PetMounted &&
|
||||
if (PetMounted && !Configuration.ServerConfiguration.AllowChaos &&
|
||||
(GeometryType == PetGeometryType.Default && PetAge < PetAge.Teen
|
||||
|| GeometryType == PetGeometryType.Terror && PetAge < PetAge.Titan)
|
||||
) {
|
||||
|
@ -3,5 +3,20 @@ using sodoffmmo.Core;
|
||||
using System.Net;
|
||||
|
||||
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();
|
||||
|
@ -9,11 +9,13 @@ public class Server {
|
||||
|
||||
readonly int port;
|
||||
readonly IPAddress ipAddress;
|
||||
readonly bool IPv6AndIPv4;
|
||||
ModuleManager moduleManager = new();
|
||||
|
||||
public Server(IPAddress ipAdress, int port) {
|
||||
public Server(IPAddress ipAdress, int port, bool IPv6AndIPv4) {
|
||||
this.ipAddress = ipAdress;
|
||||
this.port = port;
|
||||
this.IPv6AndIPv4 = IPv6AndIPv4;
|
||||
}
|
||||
|
||||
public async Task Run() {
|
||||
@ -21,7 +23,8 @@ public class Server {
|
||||
using Socket listener = new(ipAddress.AddressFamily,
|
||||
SocketType.Stream,
|
||||
ProtocolType.Tcp);
|
||||
|
||||
if (IPv6AndIPv4)
|
||||
listener.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, 0);
|
||||
listener.Bind(new IPEndPoint(ipAddress, port));
|
||||
await Listen(listener);
|
||||
}
|
||||
|
@ -1,7 +1,21 @@
|
||||
{
|
||||
"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,
|
||||
|
||||
"// EnableChat": "When true, in-game chat will be enabled",
|
||||
"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
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user