mirror of
https://github.com/sebastian-heinz/Arrowgene.DragonsDogmaOnline
synced 2026-08-03 11:12:41 -04:00
Some timers are running off local server time, while others are using UTC 0. Added a a new setting ServerTimeZone which uses a IANA ID. It is used by the task scheduler and and other calendar aware timing events. By default it is set to "TimeZoneId.Japan" (JST +9). A helper class named TimeZoneId.cs exists so a admin can use a named constant instead of magic numbers.
101 lines
3.6 KiB
C#
101 lines
3.6 KiB
C#
using Arrowgene.Ddon.GameServer.Scripting;
|
|
using Arrowgene.Ddon.Server.Scripting.utils;
|
|
using Arrowgene.Ddon.Server.Settings;
|
|
using Arrowgene.Ddon.Shared.Model;
|
|
using Microsoft.CodeAnalysis;
|
|
using Microsoft.CodeAnalysis.Scripting;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
|
|
namespace Arrowgene.Ddon.Server.Scripting.modules
|
|
{
|
|
public class GameServerSettingsModule : ScriptModule
|
|
{
|
|
public override string ModuleRoot => "settings";
|
|
public override string Filter => "*.csx";
|
|
public override bool ScanSubdirectories => true;
|
|
public override bool EnableHotLoad => true;
|
|
|
|
/// <summary>
|
|
/// Settings data is organized as ScriptName.FieldName
|
|
/// </summary>
|
|
private ScriptableSettings SettingsData { get; set; }
|
|
|
|
public GameSettings GameSettings { get; private set; }
|
|
|
|
private List<IGameSettings> DefaultSettings { get; set; }
|
|
|
|
public string TemplatesDirectory {get; private set;}
|
|
|
|
public GameServerSettingsModule(string scriptsRoot)
|
|
{
|
|
TemplatesDirectory = Path.Combine(scriptsRoot, "settings/templates");
|
|
|
|
SettingsData = new ScriptableSettings();
|
|
GameSettings = new GameSettings(SettingsData);
|
|
|
|
// Provide a list of all the settings objects
|
|
// that defaults need to be assigned for
|
|
DefaultSettings = new List<IGameSettings>()
|
|
{
|
|
GameSettings.DebugSettings,
|
|
GameSettings.GameServerSettings,
|
|
GameSettings.ChatCommandsSettings,
|
|
GameSettings.SeasonalEventsSettings,
|
|
GameSettings.PointModifiersSettings,
|
|
GameSettings.EmblemSettings,
|
|
};
|
|
}
|
|
|
|
private void CreateTemplate(string outputRootPath, Type type)
|
|
{
|
|
string outputPath = Path.Combine(outputRootPath, $"{type.Name}.csx");
|
|
SettingsTemplate.Generate(outputPath, type);
|
|
}
|
|
|
|
public override void Initialize()
|
|
{
|
|
if (!Directory.Exists(TemplatesDirectory))
|
|
{
|
|
Directory.CreateDirectory(TemplatesDirectory);
|
|
}
|
|
|
|
foreach (var defaultSetting in DefaultSettings)
|
|
{
|
|
defaultSetting.InitializeDefaults();
|
|
CreateTemplate(TemplatesDirectory, defaultSetting.GetType());
|
|
}
|
|
}
|
|
|
|
public override ScriptOptions Options()
|
|
{
|
|
return ScriptOptions.Default
|
|
.AddReferences(MetadataReference.CreateFromFile(typeof(GameSettings).Assembly.Location))
|
|
.AddReferences(MetadataReference.CreateFromFile(typeof(WalletType).Assembly.Location))
|
|
.AddReferences(MetadataReference.CreateFromFile(typeof(LibUtils).Assembly.Location))
|
|
.AddImports("System", "System.Collections", "System.Collections.Generic")
|
|
.AddImports("Arrowgene.Ddon.Server.Scripting")
|
|
.AddImports("Arrowgene.Ddon.Server.Settings")
|
|
.AddImports("Arrowgene.Ddon.Shared.Model")
|
|
.AddImports("Arrowgene.Ddon.Shared.Model.Quest");
|
|
}
|
|
|
|
public override bool EvaluateResult(string path, object result, IDictionary<string, object> variables)
|
|
{
|
|
if (path.Contains(TemplatesDirectory))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
var scriptName = Path.GetFileNameWithoutExtension(path);
|
|
|
|
foreach (var (name, value) in variables)
|
|
{
|
|
SettingsData.Set(scriptName, name, value);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|