fix IW4x regression error with alternative encodings
add parser selection to server config setup
This commit is contained in:
parent
ce02f5dd68
commit
29eedea093
@ -6,7 +6,7 @@
|
|||||||
<RuntimeFrameworkVersion>2.1.5</RuntimeFrameworkVersion>
|
<RuntimeFrameworkVersion>2.1.5</RuntimeFrameworkVersion>
|
||||||
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
|
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
|
||||||
<PackageId>RaidMax.IW4MAdmin.Application</PackageId>
|
<PackageId>RaidMax.IW4MAdmin.Application</PackageId>
|
||||||
<Version>2.2.4.3</Version>
|
<Version>2.2.4.4</Version>
|
||||||
<Authors>RaidMax</Authors>
|
<Authors>RaidMax</Authors>
|
||||||
<Company>Forever None</Company>
|
<Company>Forever None</Company>
|
||||||
<Product>IW4MAdmin</Product>
|
<Product>IW4MAdmin</Product>
|
||||||
@ -31,8 +31,8 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ServerGarbageCollection>true</ServerGarbageCollection>
|
<ServerGarbageCollection>true</ServerGarbageCollection>
|
||||||
<TieredCompilation>true</TieredCompilation>
|
<TieredCompilation>true</TieredCompilation>
|
||||||
<AssemblyVersion>2.2.4.3</AssemblyVersion>
|
<AssemblyVersion>2.2.4.4</AssemblyVersion>
|
||||||
<FileVersion>2.2.4.3</FileVersion>
|
<FileVersion>2.2.4.4</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -210,6 +210,25 @@ namespace IW4MAdmin.Application
|
|||||||
{
|
{
|
||||||
Running = true;
|
Running = true;
|
||||||
|
|
||||||
|
|
||||||
|
#region PLUGINS
|
||||||
|
SharedLibraryCore.Plugins.PluginImporter.Load(this);
|
||||||
|
|
||||||
|
foreach (var Plugin in SharedLibraryCore.Plugins.PluginImporter.ActivePlugins)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await Plugin.OnLoadAsync(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.WriteError($"{Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_PLUGIN"]} {Plugin.Name}");
|
||||||
|
Logger.WriteDebug(ex.GetExceptionInfo());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region CONFIG
|
#region CONFIG
|
||||||
var config = ConfigHandler.Configuration();
|
var config = ConfigHandler.Configuration();
|
||||||
|
|
||||||
@ -232,7 +251,18 @@ namespace IW4MAdmin.Application
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
newConfig.Servers.Add((ServerConfiguration)new ServerConfiguration().Generate());
|
var serverConfig = new ServerConfiguration();
|
||||||
|
foreach (var parser in AdditionalRConParsers)
|
||||||
|
{
|
||||||
|
serverConfig.AddRConParser(parser);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var parser in AdditionalEventParsers)
|
||||||
|
{
|
||||||
|
serverConfig.AddEventParser(parser);
|
||||||
|
}
|
||||||
|
|
||||||
|
newConfig.Servers.Add((ServerConfiguration)serverConfig.Generate());
|
||||||
} while (Utilities.PromptBool(Utilities.CurrentLocalization.LocalizationIndex["SETUP_SERVER_SAVE"]));
|
} while (Utilities.PromptBool(Utilities.CurrentLocalization.LocalizationIndex["SETUP_SERVER_SAVE"]));
|
||||||
|
|
||||||
config = newConfig;
|
config = newConfig;
|
||||||
@ -275,24 +305,6 @@ namespace IW4MAdmin.Application
|
|||||||
PrivilegedClients = (await ClientSvc.GetPrivilegedClients()).ToDictionary(_client => _client.ClientId);
|
PrivilegedClients = (await ClientSvc.GetPrivilegedClients()).ToDictionary(_client => _client.ClientId);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region PLUGINS
|
|
||||||
SharedLibraryCore.Plugins.PluginImporter.Load(this);
|
|
||||||
|
|
||||||
foreach (var Plugin in SharedLibraryCore.Plugins.PluginImporter.ActivePlugins)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await Plugin.OnLoadAsync(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.WriteError($"{Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_PLUGIN"]} {Plugin.Name}");
|
|
||||||
Logger.WriteDebug(ex.GetExceptionInfo());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region COMMANDS
|
#region COMMANDS
|
||||||
if (ClientSvc.GetOwners().Result.Count == 0)
|
if (ClientSvc.GetOwners().Result.Count == 0)
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,7 @@ namespace IW4MAdmin.Application.RconParsers
|
|||||||
Configuration.Status.AddMapping(ParserRegex.GroupType.RConName, 5);
|
Configuration.Status.AddMapping(ParserRegex.GroupType.RConName, 5);
|
||||||
Configuration.Status.AddMapping(ParserRegex.GroupType.RConIpAddress, 7);
|
Configuration.Status.AddMapping(ParserRegex.GroupType.RConIpAddress, 7);
|
||||||
|
|
||||||
Configuration.Dvar.Pattern = "^\"(.+)\" is: \"(.+)\" default: \"(.+)\"\n(?:latched: \"(.+)\"\n)? *(.+)$";
|
Configuration.Dvar.Pattern = "^\"(.+)\" is: \"(.+)\" default: \"(.+)?\"\n(?:latched: \"(.+)?\"\n)? *(.+)$";
|
||||||
Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarName, 1);
|
Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarName, 1);
|
||||||
Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarValue, 2);
|
Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarValue, 2);
|
||||||
Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarDefaultValue, 3);
|
Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarDefaultValue, 3);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using SharedLibraryCore.Interfaces;
|
using SharedLibraryCore.Interfaces;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace SharedLibraryCore.Configuration
|
namespace SharedLibraryCore.Configuration
|
||||||
{
|
{
|
||||||
@ -11,11 +12,22 @@ namespace SharedLibraryCore.Configuration
|
|||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
public IList<string> Rules { get; set; }
|
public IList<string> Rules { get; set; }
|
||||||
public IList<string> AutoMessages { get; set; }
|
public IList<string> AutoMessages { get; set; }
|
||||||
public bool UseT6MParser { get; set; }
|
|
||||||
public string ManualLogPath { get; set; }
|
public string ManualLogPath { get; set; }
|
||||||
public string CustomParserVersion { get; set; }
|
public string CustomParserVersion { get; set; }
|
||||||
public int ReservedSlotNumber { get; set; }
|
public int ReservedSlotNumber { get; set; }
|
||||||
|
|
||||||
|
private readonly IList<IRConParser> rconParsers;
|
||||||
|
private readonly IList<IEventParser> eventParsers;
|
||||||
|
|
||||||
|
public ServerConfiguration()
|
||||||
|
{
|
||||||
|
rconParsers = new List<IRConParser>();
|
||||||
|
eventParsers = new List<IEventParser>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddRConParser(IRConParser parser) => rconParsers.Add(parser);
|
||||||
|
public void AddEventParser(IEventParser parser) => eventParsers.Add(parser);
|
||||||
|
|
||||||
public IBaseConfiguration Generate()
|
public IBaseConfiguration Generate()
|
||||||
{
|
{
|
||||||
var loc = Utilities.CurrentLocalization.LocalizationIndex;
|
var loc = Utilities.CurrentLocalization.LocalizationIndex;
|
||||||
@ -38,9 +50,24 @@ namespace SharedLibraryCore.Configuration
|
|||||||
Password = Utilities.PromptString(loc["SETUP_SERVER_RCON"]);
|
Password = Utilities.PromptString(loc["SETUP_SERVER_RCON"]);
|
||||||
AutoMessages = new List<string>();
|
AutoMessages = new List<string>();
|
||||||
Rules = new List<string>();
|
Rules = new List<string>();
|
||||||
UseT6MParser = Utilities.PromptBool(loc["SETUP_SERVER_USET6M"]);
|
|
||||||
ReservedSlotNumber = loc["SETUP_SERVER_RESERVEDSLOT"].PromptInt(null, 0, 32);
|
ReservedSlotNumber = loc["SETUP_SERVER_RESERVEDSLOT"].PromptInt(null, 0, 32);
|
||||||
|
|
||||||
|
var parserVersions = rconParsers.Select(_parser => _parser.Version).ToArray();
|
||||||
|
var selection = Utilities.PromptSelection(loc["SETUP_SERVER_RCON_PARSER_VERSION"], $"{loc["SETUP_PROMPT_DEFAULT"]} (IW4x)", null, parserVersions);
|
||||||
|
|
||||||
|
if (selection.Item1 > 0)
|
||||||
|
{
|
||||||
|
CustomParserVersion = selection.Item2;
|
||||||
|
}
|
||||||
|
|
||||||
|
parserVersions = eventParsers.Select(_parser => _parser.Version).ToArray();
|
||||||
|
selection = Utilities.PromptSelection(loc["SETUP_SERVER_EVENT_PARSER_VERSION"], $"{loc["SETUP_PROMPT_DEFAULT"]} (IW4x)", null, parserVersions);
|
||||||
|
|
||||||
|
if (selection.Item1 > 0)
|
||||||
|
{
|
||||||
|
CustomParserVersion = selection.Item2;
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ namespace SharedLibraryCore.Helpers
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3(float x, float y, float z)
|
public Vector3(float x, float y, float z)
|
||||||
{
|
{
|
||||||
X = x;
|
X = x;
|
||||||
|
@ -81,13 +81,13 @@ namespace SharedLibraryCore.RCon
|
|||||||
{
|
{
|
||||||
case StaticHelpers.QueryType.GET_DVAR:
|
case StaticHelpers.QueryType.GET_DVAR:
|
||||||
waitForResponse |= true;
|
waitForResponse |= true;
|
||||||
payload = (string.Format(Config.CommandPrefixes.RConGetDvar, RConPassword, parameters + '\0')).Select(Convert.ToByte).ToArray();
|
payload = Utilities.EncodingType.GetBytes(string.Format(Config.CommandPrefixes.RConGetDvar, RConPassword, parameters + '\0'));
|
||||||
break;
|
break;
|
||||||
case StaticHelpers.QueryType.SET_DVAR:
|
case StaticHelpers.QueryType.SET_DVAR:
|
||||||
payload = (string.Format(Config.CommandPrefixes.RConSetDvar, RConPassword, parameters + '\0')).Select(Convert.ToByte).ToArray();
|
payload = Utilities.EncodingType.GetBytes(string.Format(Config.CommandPrefixes.RConSetDvar, RConPassword, parameters + '\0'));
|
||||||
break;
|
break;
|
||||||
case StaticHelpers.QueryType.COMMAND:
|
case StaticHelpers.QueryType.COMMAND:
|
||||||
payload = (string.Format(Config.CommandPrefixes.RConCommand, RConPassword, parameters + '\0')).Select(Convert.ToByte).ToArray();
|
payload = Utilities.EncodingType.GetBytes(string.Format(Config.CommandPrefixes.RConCommand, RConPassword, parameters + '\0'));
|
||||||
break;
|
break;
|
||||||
case StaticHelpers.QueryType.GET_STATUS:
|
case StaticHelpers.QueryType.GET_STATUS:
|
||||||
waitForResponse |= true;
|
waitForResponse |= true;
|
||||||
|
@ -492,6 +492,45 @@ namespace SharedLibraryCore
|
|||||||
return response != 0 ? response == 'y' : defaultValue;
|
return response != 0 ? response == 'y' : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// prompt user to make a selection
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">type of selection</typeparam>
|
||||||
|
/// <param name="question">question to prompt the user with</param>
|
||||||
|
/// <param name="defaultValue">default value to set if no input is entered</param>
|
||||||
|
/// <param name="description">description of the question's value</param>
|
||||||
|
/// <param name="selections">array of possible selections (should be able to convert to string)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Tuple<int, T> PromptSelection<T>(string question, T defaultValue, string description = null, params T[] selections)
|
||||||
|
{
|
||||||
|
bool hasDefault = false;
|
||||||
|
|
||||||
|
if (defaultValue != null)
|
||||||
|
{
|
||||||
|
hasDefault = true;
|
||||||
|
selections = (new T[] { defaultValue }).Union(selections).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"{question}{(string.IsNullOrEmpty(description) ? "" : $" [{ description}:]")}");
|
||||||
|
Console.WriteLine(new string('=', 52));
|
||||||
|
for (int index = 0; index < selections.Length; index++)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{(hasDefault ? index : index + 1)}] {selections[index]}");
|
||||||
|
}
|
||||||
|
Console.WriteLine(new string('=', 52));
|
||||||
|
|
||||||
|
int selectionIndex = PromptInt(CurrentLocalization.LocalizationIndex["SETUP_PROMPT_MAKE_SELECTION"], null, hasDefault ? 0 : 1, selections.Length, hasDefault ? 0 : (int?)null);
|
||||||
|
|
||||||
|
if (!hasDefault)
|
||||||
|
{
|
||||||
|
selectionIndex--;
|
||||||
|
}
|
||||||
|
|
||||||
|
T selection = selections[selectionIndex ];
|
||||||
|
|
||||||
|
return Tuple.Create(selectionIndex, selection);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// prompt user to enter a number
|
/// prompt user to enter a number
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -503,7 +542,7 @@ namespace SharedLibraryCore
|
|||||||
/// <returns>integer from user's input</returns>
|
/// <returns>integer from user's input</returns>
|
||||||
public static int PromptInt(this string question, string description = null, int minValue = 0, int maxValue = int.MaxValue, int? defaultValue = null)
|
public static int PromptInt(this string question, string description = null, int minValue = 0, int maxValue = int.MaxValue, int? defaultValue = null)
|
||||||
{
|
{
|
||||||
Console.Write($"{question}{(string.IsNullOrEmpty(description) ? "" : $" ({description})")}{(defaultValue == null ? "" : $" [{CurrentLocalization.LocalizationIndex["SETUP_PROMPT_DEFAULT"]} {defaultValue.Value.ToString()}")}]: ");
|
Console.Write($"{question}{(string.IsNullOrEmpty(description) ? "" : $" ({description})")}{(defaultValue == null ? "" : $" [{CurrentLocalization.LocalizationIndex["SETUP_PROMPT_DEFAULT"]} {defaultValue.Value.ToString()}]")}: ");
|
||||||
int response;
|
int response;
|
||||||
|
|
||||||
string inputOrDefault()
|
string inputOrDefault()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user