diff --git a/AMNet.Server/Config.cs b/AMNet.Server/Config.cs index 0018478..cbefe91 100644 --- a/AMNet.Server/Config.cs +++ b/AMNet.Server/Config.cs @@ -8,15 +8,14 @@ namespace AMNet.Server; internal static class Config { internal const string IOSection = "aimeio"; - private const string ConfigFileName = @".\segatools.ini"; static Config() { GameId = ReadKey(IOSection, "gameId", 4); ServerName = ReadKey(IOSection, "serverName", 26, Environment.MachineName); - PhysicalCardUseIDm = PInvoke.GetPrivateProfileInt(IOSection, "useAimeDBForPhysicalCards", 0, ConfigFileName) > 0; - EnableAimeTxt = PInvoke.GetPrivateProfileInt(IOSection, "enableKeyboardMode", 1, ConfigFileName) > 0; + PhysicalCardUseIDm = PInvoke.GetPrivateProfileInt(IOSection, "useAimeDBForPhysicalCards", 0, ConfigFilePath) > 0; + EnableAimeTxt = PInvoke.GetPrivateProfileInt(IOSection, "enableKeyboardMode", 1, ConfigFilePath) > 0; AimeTxtPath = ReadKey("aime", "aimePath", PInvoke.MAX_PATH, @"DEVICE\aime.txt"); } @@ -44,13 +43,15 @@ internal static class Config public static Version ServerVersion { get; } = new(Assembly.GetExecutingAssembly().GetCustomAttribute()?.Version ?? "1.0"); + private static string ConfigFilePath { get; } = Environment.GetEnvironmentVariable("SEGATOOLS_CONFIG_PATH") ?? ".\\segatools.ini"; + internal static unsafe string ReadKey(string section, string key, uint maxLength, string @default = null) { // +1 for null terminator var buffer = stackalloc char[(int)maxLength + 1]; var bufferStr = new PWSTR(buffer); - PInvoke.GetPrivateProfileString(section, key, @default ?? string.Empty, bufferStr, maxLength + 1, ConfigFileName); + PInvoke.GetPrivateProfileString(section, key, @default ?? string.Empty, bufferStr, maxLength + 1, ConfigFilePath); return bufferStr.ToString(); } } \ No newline at end of file