new config options

This commit is contained in:
AlessandroCH 2025-03-08 17:09:30 +01:00
parent 5f488b67d9
commit d7ba6dcb6b
2 changed files with 56 additions and 10 deletions

View File

@ -1,4 +1,5 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -8,61 +9,95 @@ namespace Campofinale
{
public class ConfigFile
{
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public MongoDatabaseSettings mongoDatabase = new();
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public DispatchServerSettings dispatchServer = new();
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public GameserverSettings gameServer = new();
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public ServerOptions serverOptions = new();
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public LogSettings logOptions = new();
}
public struct ServerOptions
public class ServerOptions
{
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public int defaultSceneNumId = 98;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public int maxPlayers = 20;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public CharactersOptions defaultCharacters = new();
public ServerOptions()
{
}
public class CharactersOptions
{
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public int defaultLevel = 1;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public bool giveAllCharacters = true;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public List<string> characters = new List<string>()
{
"chr_0002_endminm",
"chr_0003_endminf",
"chr_0015_lifeng"
}; //used if giveAllCharacters is false
public CharactersOptions() { }
}
/* public struct WelcomeMail
{
}*/
}
public struct LogSettings
public class LogSettings
{
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public bool packets;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public bool debugPrint=false;
public LogSettings()
{
}
}
public struct GameserverSettings
public class GameserverSettings
{
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public string bindAddress = "127.0.0.1";
public int bindPort = 30000;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public string accessAddress = "127.0.0.1";
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public int accessPort = 30000;
public GameserverSettings()
{
}
}
public struct DispatchServerSettings
public class DispatchServerSettings
{
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public string bindAddress = "127.0.0.1";
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public int bindPort = 5000;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public string accessAddress = "127.0.0.1";
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public int accessPort = 5000;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public string emailFormat = "@campofinale.ps";
public DispatchServerSettings()
{
}
}
public struct MongoDatabaseSettings
public class MongoDatabaseSettings
{
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public string uri = "mongodb://localhost:27017";
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public string collection = "Campofinale";
public MongoDatabaseSettings()
{

View File

@ -198,10 +198,21 @@ namespace Campofinale
}
public void Initialize()
{
foreach (var item in ResourceManager.characterTable)
if (Server.config.serverOptions.defaultCharacters.giveAllCharacters)
{
chars.Add(new Character(roleId,item.Key,20));
foreach (var item in ResourceManager.characterTable)
{
chars.Add(new Character(roleId, item.Key, Server.config.serverOptions.defaultCharacters.defaultLevel));
}
}
else
{
foreach (var item in Server.config.serverOptions.defaultCharacters.characters)
{
chars.Add(new Character(roleId, item.Key, Server.config.serverOptions.defaultCharacters.defaultLevel));
}
}
foreach(var item in itemTable)
{
if(item.Value.maxStackCount == -1)