mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-12 23:14:34 +01:00
65 lines
1.7 KiB
C#
65 lines
1.7 KiB
C#
using Newtonsoft.Json;
|
|
using Swan.Logging;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace nksrv.Utils
|
|
{
|
|
public class GameConfigRoot
|
|
{
|
|
public StaticData StaticData { get; set; } = new();
|
|
public string ResourceBaseURL { get; set; } = "";
|
|
}
|
|
|
|
public class StaticData
|
|
{
|
|
public string Url { get; set; } = "";
|
|
public string Version { get; set; } = "";
|
|
public string Salt1 { get; set; } = "";
|
|
public string Salt2 { get; set; } = "";
|
|
|
|
|
|
public byte[] GetSalt1Bytes()
|
|
{
|
|
return Convert.FromBase64String(Salt1);
|
|
}
|
|
public byte[] GetSalt2Bytes()
|
|
{
|
|
return Convert.FromBase64String(Salt2);
|
|
}
|
|
}
|
|
|
|
public static class GameConfig
|
|
{
|
|
private static GameConfigRoot? _root;
|
|
public static GameConfigRoot Root
|
|
{
|
|
get
|
|
{
|
|
if (_root == null)
|
|
{
|
|
if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "/gameconfig.json"))
|
|
{
|
|
Logger.Error("Gameconfig.json is not found, the game WILL NOT work!");
|
|
_root = new GameConfigRoot();
|
|
}
|
|
Logger.Info("Loaded game config");
|
|
|
|
|
|
_root = JsonConvert.DeserializeObject<GameConfigRoot>(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/gameconfig.json"));
|
|
|
|
if (_root == null)
|
|
{
|
|
throw new Exception("Failed to read gameconfig.json");
|
|
}
|
|
}
|
|
|
|
return _root;
|
|
}
|
|
}
|
|
}
|
|
}
|