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

@ -1,6 +1,6 @@
namespace Server.Misc
{
public class MapDefinitions
public static class MapDefinitions
{
public static void Configure()
{
@ -33,11 +33,12 @@ namespace Server.Misc
* - <season> : Season of the map. 0 = Spring, 1 = Summer, 2 = Fall, 3 = Winter, 4 = Desolation
* - <name> : Reference name for the map, used in props gump, get/set commands, region loading, etc
* - <rules> : Rules and restrictions associated with the map. See documentation for details
*/
*/
TileMatrixPatch.Enabled = false; // OSI Client Patch 6.0.0.0
// Using this requires the old mapDif files to be present. Only needed to support Clients < 6.0.0.0
TileMatrixPatch.Enabled = ServerConfiguration.GetOrUpdateSetting("maps.enableTileMatrixPatches", !Core.SE);
MultiComponentList.PostHSFormat = true; // OSI Client Patch 7.0.9.0
MultiComponentList.PostHSFormat = ServerConfiguration.GetOrUpdateSetting("maps.enablePostHSMultiComponentFormat", true); // OSI Client Patch 7.0.9.0
}
public static void RegisterMap(int mapIndex, int mapID, int fileIndex, int width, int height, int season,
@ -49,4 +50,4 @@ namespace Server.Misc
Map.AllMaps.Add(newMap);
}
}
}
}

View file

@ -50,6 +50,7 @@ namespace Server.Misc
{
Address = ServerConfiguration.GetOrUpdateSetting("serverListing.address", "(-null-)");
AutoDetect = ServerConfiguration.GetOrUpdateSetting("serverListing.autoDetect", true);
ServerName = ServerConfiguration.GetOrUpdateSetting("serverListing.serverName", "ModernUO");
if (Address == null)
{

View file

@ -1,5 +1,4 @@
using System;
using System.Buffers.Binary;
using Server.Network;
using Xunit;

View file

@ -9,6 +9,9 @@ namespace Server.Tests
public ServerFixture()
{
// Load Configurations
ServerConfiguration.Load(true);
// Configure / Initialize
MapDefinitions.Configure();

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);