Fixes configurations (#130)

This commit is contained in:
Kamron Batman 2020-05-03 23:52:16 -07:00 • committed by GitHub
parent cf8620d558
commit 11227391d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 34 additions and 16 deletions

View file

@ -32,6 +32,7 @@ namespace Server
private const string m_RelPath = "Configuration/modernuo.json";
private static readonly string m_FilePath = Path.Join(Core.BaseDirectory, m_RelPath);
private static ServerSettings m_Settings;
private static bool m_Mocked;
public static List<string> DataDirectories => m_Settings.dataDirectories;
@ -119,7 +120,7 @@ namespace Server
public static void SetSetting(string key, string value)
{
m_Settings.settings[key] = value;
SaveConfiguration();
Save();
}
public static T GetMetadata<T>(string key) where T : class
@ -133,8 +134,10 @@ namespace Server
m_Settings.metadata[key] = value;
}
public static void LoadConfiguration()
// If mock is enabled we skip the console readline.
public static void Load(bool mocked = false)
{
m_Mocked = mocked;
bool updated = false;
if (File.Exists(m_FilePath))
@ -158,6 +161,9 @@ namespace Server
m_Settings = new ServerSettings();
}
if (mocked)
return;
if (m_Settings.dataDirectories.Count == 0)
{
updated = true;
@ -167,7 +173,7 @@ namespace Server
if (updated)
{
SaveConfiguration();
Save();
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"Core: Configuration saved to {m_RelPath}.");
Console.ResetColor();
@ -200,8 +206,10 @@ namespace Server
return directory;
}
public static void SaveConfiguration()
public static void Save()
{
if (m_Mocked) return;
JsonConfig.Serialize(m_FilePath, m_Settings);
}
}

View file

@ -380,7 +380,7 @@ namespace Server
Console.WriteLine("SecureRandomImpl: {0} ({1})", SecureRandomImpl.Name,
SecureRandomImpl.IsHardwareRNG ? "Hardware" : "Software");
ServerConfiguration.LoadConfiguration();
ServerConfiguration.Load();
// Load Assembly Scripts.CS.dll
AssemblyHandler.LoadScripts();

View file

@ -256,7 +256,6 @@ namespace Server
}
[Parsable]
// [CustomEnum( new string[]{ "Felucca", "Trammel", "Ilshenar", "Malas", "Internal" } )]
public sealed class Map : IComparable<Map>
{
public const int SectorSize = 16;

View file

@ -2063,7 +2063,10 @@ namespace Server
{
ns.Sequence = 0;
ns.Send(new MapChange(this));
ns.Send(new MapPatches());
if (!Core.SE && ns.ProtocolChanges < ProtocolChanges.Version6000)
ns.Send(new MapPatches());
ns.Send(SeasonChange.Instantiate(GetSeason(), true));
if (ns.StygianAbyss)
@ -2185,7 +2188,10 @@ namespace Server
{
ns.Sequence = 0;
ns.Send(new MapChange(this));
ns.Send(new MapPatches());
if (!Core.SE && ns.ProtocolChanges < ProtocolChanges.Version6000)
ns.Send(new MapPatches());
ns.Send(SeasonChange.Instantiate(GetSeason(), true));
if (ns.StygianAbyss)

View file

@ -1940,7 +1940,8 @@ namespace Server.Network
if (m.Map != null)
state.Send(new MapChange(m));
state.Send(new MapPatches());
if (!Core.SE && state.ProtocolChanges < ProtocolChanges.Version6000)
state.Send(new MapPatches());
state.Send(SeasonChange.Instantiate(m.GetSeason(), true));

View file

@ -254,7 +254,7 @@ namespace Server.Network
{
public MapPatches() : base(0xBF)
{
EnsureCapacity(9 + 3 * 8);
EnsureCapacity(9 + 4 * 8);
Stream.Write((short)0x0018);