Skip to content

Commit

Permalink
actually fix the encoding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
RaidMax committed Feb 11, 2019
1 parent 064161c commit e91927e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
6 changes: 3 additions & 3 deletions Application/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RuntimeFrameworkVersion>2.1.5</RuntimeFrameworkVersion>
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
<PackageId>RaidMax.IW4MAdmin.Application</PackageId>
<Version>2.2.4.8</Version>
<Version>2.2.4.9</Version>
<Authors>RaidMax</Authors>
<Company>Forever None</Company>
<Product>IW4MAdmin</Product>
Expand All @@ -31,8 +31,8 @@
<PropertyGroup>
<ServerGarbageCollection>true</ServerGarbageCollection>
<TieredCompilation>true</TieredCompilation>
<AssemblyVersion>2.2.4.8</AssemblyVersion>
<FileVersion>2.2.4.8</FileVersion>
<AssemblyVersion>2.2.4.9</AssemblyVersion>
<FileVersion>2.2.4.9</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion SharedLibraryCore/RCon/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ public class Connection

private readonly ILogger Log;
private IRConParserConfiguration Config;
private readonly Encoding defaultEncoding;

public Connection(string ipAddress, int port, string password, ILogger log, IRConParserConfiguration config)
{
Endpoint = new IPEndPoint(IPAddress.Parse(ipAddress), port);
defaultEncoding = Encoding.GetEncoding("windows-1252");
RConPassword = password;
Log = log;
Config = config;
Expand Down Expand Up @@ -81,7 +83,7 @@ public async Task<string[]> SendQueryAsync(StaticHelpers.QueryType type, string
string convertEncoding(string text)
{
byte[] convertedBytes = Utilities.EncodingType.GetBytes(text);
return Utilities.EncodingType.GetString(convertedBytes);
return defaultEncoding.GetString(convertedBytes);
}

string convertedRConPassword = convertEncoding(RConPassword);
Expand Down
20 changes: 14 additions & 6 deletions SharedLibraryCore/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,19 @@ public static string GetLocalizedGametype(String input)
public static long ConvertLong(this string str)
{
str = str.Substring(0, Math.Min(str.Length, 16));
if (long.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out long id))
long id;

if (str.Length <= 10)
{
return id;
if (long.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out id))
{
return (uint)id;
}
}

if (long.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out id))
if (long.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out id))
{
return (uint)id;
return id;
}

var bot = Regex.Match(str, @"bot[0-9]+").Value;
Expand Down Expand Up @@ -526,7 +531,7 @@ public static Tuple<int, T> PromptSelection<T>(string question, T defaultValue,
selectionIndex--;
}

T selection = selections[selectionIndex ];
T selection = selections[selectionIndex];

return Tuple.Create(selectionIndex, selection);
}
Expand Down Expand Up @@ -650,7 +655,10 @@ public static string GetCommandLine(int pId)
/// </summary>
/// <param name="log"></param>
/// <returns></returns>
public static bool IsRemoteLog(this string log) => (log ?? "").StartsWith("http");
public static bool IsRemoteLog(this string log)
{
return (log ?? "").StartsWith("http");
}

public static string ToBase64UrlSafeString(this string src)
{
Expand Down

0 comments on commit e91927e

Please sign in to comment.