diff --git a/Application/EventParsers/BaseEventParser.cs b/Application/EventParsers/BaseEventParser.cs
index 26ad6378d..71962056c 100644
--- a/Application/EventParsers/BaseEventParser.cs
+++ b/Application/EventParsers/BaseEventParser.cs
@@ -95,7 +95,7 @@ namespace IW4MAdmin.Application.EventParsers
if (message.Length > 0)
{
- long originId = matchResult.Groups[Configuration.Say.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong();
+ long originId = matchResult.Groups[Configuration.Say.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(Configuration.GuidNumberStyle);
if (message[0] == '!' || message[0] == '@')
{
@@ -129,8 +129,8 @@ namespace IW4MAdmin.Application.EventParsers
if (match.Success)
{
- long originId = match.Groups[Configuration.Kill.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].Value.ToString().ConvertGuidToLong(1);
- long targetId = match.Groups[Configuration.Kill.GroupMapping[ParserRegex.GroupType.TargetNetworkId]].Value.ToString().ConvertGuidToLong(1);
+ long originId = match.Groups[Configuration.Kill.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].Value.ToString().ConvertGuidToLong(Configuration.GuidNumberStyle, 1);
+ long targetId = match.Groups[Configuration.Kill.GroupMapping[ParserRegex.GroupType.TargetNetworkId]].Value.ToString().ConvertGuidToLong(Configuration.GuidNumberStyle, 1);
return new GameEvent()
{
@@ -149,8 +149,8 @@ namespace IW4MAdmin.Application.EventParsers
if (regexMatch.Success)
{
- long originId = regexMatch.Groups[Configuration.Damage.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(1);
- long targetId = regexMatch.Groups[Configuration.Damage.GroupMapping[ParserRegex.GroupType.TargetNetworkId]].ToString().ConvertGuidToLong(1);
+ long originId = regexMatch.Groups[Configuration.Damage.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(Configuration.GuidNumberStyle, 1);
+ long targetId = regexMatch.Groups[Configuration.Damage.GroupMapping[ParserRegex.GroupType.TargetNetworkId]].ToString().ConvertGuidToLong(Configuration.GuidNumberStyle, 1);
return new GameEvent()
{
@@ -179,7 +179,7 @@ namespace IW4MAdmin.Application.EventParsers
{
Name = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginName]].ToString(),
},
- NetworkId = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(),
+ NetworkId = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(Configuration.GuidNumberStyle),
ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()),
State = EFClient.ClientState.Connecting,
},
@@ -204,7 +204,7 @@ namespace IW4MAdmin.Application.EventParsers
{
Name = regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginName]].ToString()
},
- NetworkId = regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(),
+ NetworkId = regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(Configuration.GuidNumberStyle),
ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()),
State = EFClient.ClientState.Disconnecting
},
@@ -248,7 +248,7 @@ namespace IW4MAdmin.Application.EventParsers
{
Type = GameEvent.EventType.JoinTeam,
Data = logLine,
- Origin = new EFClient() { NetworkId = lineSplit[1].ConvertGuidToLong() },
+ Origin = new EFClient() { NetworkId = lineSplit[1].ConvertGuidToLong(Configuration.GuidNumberStyle) },
RequiredEntity = GameEvent.EventRequiredEntity.Target
};
}
@@ -257,8 +257,8 @@ namespace IW4MAdmin.Application.EventParsers
if (eventType == "ScriptKill")
{
- long originId = lineSplit[1].ConvertGuidToLong(1);
- long targetId = lineSplit[2].ConvertGuidToLong(1);
+ long originId = lineSplit[1].ConvertGuidToLong(Configuration.GuidNumberStyle, 1);
+ long targetId = lineSplit[2].ConvertGuidToLong(Configuration.GuidNumberStyle, 1);
return new GameEvent()
{
@@ -273,8 +273,8 @@ namespace IW4MAdmin.Application.EventParsers
// this is a custom event printed out by _customcallbacks.gsc (used for anticheat)
if (eventType == "ScriptDamage")
{
- long originId = lineSplit[1].ConvertGuidToLong(1);
- long targetId = lineSplit[2].ConvertGuidToLong(1);
+ long originId = lineSplit[1].ConvertGuidToLong(Configuration.GuidNumberStyle, 1);
+ long targetId = lineSplit[2].ConvertGuidToLong(Configuration.GuidNumberStyle, 1);
return new GameEvent()
{
diff --git a/Application/EventParsers/DynamicEventParserConfiguration.cs b/Application/EventParsers/DynamicEventParserConfiguration.cs
index 479983ca7..e42239e1c 100644
--- a/Application/EventParsers/DynamicEventParserConfiguration.cs
+++ b/Application/EventParsers/DynamicEventParserConfiguration.cs
@@ -1,4 +1,5 @@
using SharedLibraryCore.Interfaces;
+using System.Globalization;
namespace IW4MAdmin.Application.EventParsers
{
@@ -15,5 +16,6 @@ namespace IW4MAdmin.Application.EventParsers
public ParserRegex Kill { get; set; } = new ParserRegex();
public ParserRegex Damage { get; set; } = new ParserRegex();
public ParserRegex Action { get; set; } = new ParserRegex();
+ public NumberStyles GuidNumberStyle { get; set; } = NumberStyles.HexNumber;
}
}
diff --git a/Application/RconParsers/BaseRConParser.cs b/Application/RconParsers/BaseRConParser.cs
index 381b0e38d..e1d57fe51 100644
--- a/Application/RconParsers/BaseRConParser.cs
+++ b/Application/RconParsers/BaseRConParser.cs
@@ -169,7 +169,7 @@ namespace IW4MAdmin.Application.RconParsers
long networkId;
try
{
- networkId = regex.Groups[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConNetworkId]].Value.ConvertGuidToLong();
+ networkId = regex.Groups[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConNetworkId]].Value.ConvertGuidToLong(Configuration.GuidNumberStyle);
}
catch (FormatException)
diff --git a/Application/RconParsers/DynamicRConParserConfiguration.cs b/Application/RconParsers/DynamicRConParserConfiguration.cs
index 3d92c2f13..c4c680e78 100644
--- a/Application/RconParsers/DynamicRConParserConfiguration.cs
+++ b/Application/RconParsers/DynamicRConParserConfiguration.cs
@@ -1,5 +1,6 @@
using SharedLibraryCore.Interfaces;
using SharedLibraryCore.RCon;
+using System.Globalization;
namespace IW4MAdmin.Application.RconParsers
{
@@ -15,5 +16,6 @@ namespace IW4MAdmin.Application.RconParsers
public ParserRegex Dvar { get; set; } = new ParserRegex();
public string ServerNotRunningResponse { get; set; }
public bool WaitForResponse { get; set; } = true;
+ public NumberStyles GuidNumberStyle { get; set; } = NumberStyles.HexNumber;
}
}
diff --git a/Plugins/ScriptPlugins/ParserPT6.js b/Plugins/ScriptPlugins/ParserPT6.js
index cfc7cb1be..f9ecf53ab 100644
--- a/Plugins/ScriptPlugins/ParserPT6.js
+++ b/Plugins/ScriptPlugins/ParserPT6.js
@@ -3,7 +3,7 @@ var eventParser;
var plugin = {
author: 'RaidMax, Xerxes',
- version: 0.4,
+ version: 0.5,
name: 'Plutonium T6 Parser',
isParser: true,
@@ -33,8 +33,9 @@ var plugin = {
rconParser.Configuration.Status.AddMapping(103, 4);
rconParser.Configuration.Status.AddMapping(104, 5);
rconParser.Configuration.Status.AddMapping(105, 6);
-
+
eventParser.Configuration.GameDirectory = 't6r\\data';
+ eventParser.Configuration.GuidNumberStyle = 7; // Integer
rconParser.Version = 'Call of Duty Multiplayer - Ship COD_T6_S MP build 1.0.44 CL(1759941) CODPCAB2 CEG Fri May 9 19:19:19 2014 win-x86 813e66d5';
rconParser.GameName = 7; // T6
diff --git a/SharedLibraryCore/BaseController.cs b/SharedLibraryCore/BaseController.cs
index e057a19e8..c175e393d 100644
--- a/SharedLibraryCore/BaseController.cs
+++ b/SharedLibraryCore/BaseController.cs
@@ -88,7 +88,7 @@ namespace SharedLibraryCore
if (clientId > 0)
{
Client.ClientId = clientId;
- Client.NetworkId = clientId == 1 ? 0 : User.Claims.First(_claim => _claim.Type == ClaimTypes.PrimarySid).Value.ConvertGuidToLong();
+ Client.NetworkId = clientId == 1 ? 0 : User.Claims.First(_claim => _claim.Type == ClaimTypes.PrimarySid).Value.ConvertGuidToLong(System.Globalization.NumberStyles.HexNumber);
Client.Level = (EFClient.Permission)Enum.Parse(typeof(EFClient.Permission), User.Claims.First(c => c.Type == ClaimTypes.Role).Value);
Client.CurrentAlias = new EFAlias() { Name = User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value };
Authorized = Client.ClientId >= 0;
diff --git a/SharedLibraryCore/Interfaces/IEventParserConfiguration.cs b/SharedLibraryCore/Interfaces/IEventParserConfiguration.cs
index e2f976030..1fc8e55c9 100644
--- a/SharedLibraryCore/Interfaces/IEventParserConfiguration.cs
+++ b/SharedLibraryCore/Interfaces/IEventParserConfiguration.cs
@@ -1,4 +1,6 @@
-namespace SharedLibraryCore.Interfaces
+using System.Globalization;
+
+namespace SharedLibraryCore.Interfaces
{
public interface IEventParserConfiguration
{
@@ -6,29 +8,40 @@
/// stores the fs_game directory (this folder may vary between different clients)
///
string GameDirectory { get; set; }
+
///
/// stores the regex information for a say event printed in the game log
///
ParserRegex Say { get; set; }
+
///
/// stores the regex information for a join event printed in the game log
///
ParserRegex Join { get; set; }
+
///
/// stores the regex information for a quit event printed in the game log
///
ParserRegex Quit { get; set; }
+
///
/// stores the regex information for a kill event printed in the game log
///
ParserRegex Kill { get; set; }
+
///
/// stores the regex information for a damage event printed in the game log
///
ParserRegex Damage { get; set; }
+
///
/// stores the regex information for an action event printed in the game log
///
ParserRegex Action { get; set; }
+
+ ///
+ /// indicates the format expected for parsed guids
+ ///
+ NumberStyles GuidNumberStyle { get; set; }
}
}
diff --git a/SharedLibraryCore/Interfaces/IRConParserConfiguration.cs b/SharedLibraryCore/Interfaces/IRConParserConfiguration.cs
index 9c15cdecf..5e1b70539 100644
--- a/SharedLibraryCore/Interfaces/IRConParserConfiguration.cs
+++ b/SharedLibraryCore/Interfaces/IRConParserConfiguration.cs
@@ -1,4 +1,5 @@
using SharedLibraryCore.RCon;
+using System.Globalization;
namespace SharedLibraryCore.Interfaces
{
@@ -34,5 +35,10 @@ namespace SharedLibraryCore.Interfaces
/// when executing a command
///
bool WaitForResponse { get; set; }
+
+ ///
+ /// indicates the format expected for parsed guids
+ ///
+ NumberStyles GuidNumberStyle { get; set; }
}
}
diff --git a/SharedLibraryCore/Services/ClientService.cs b/SharedLibraryCore/Services/ClientService.cs
index bfc1e901e..a0d37bc71 100644
--- a/SharedLibraryCore/Services/ClientService.cs
+++ b/SharedLibraryCore/Services/ClientService.cs
@@ -537,7 +537,7 @@ namespace SharedLibraryCore.Services
long? networkId = null;
try
{
- networkId = identifier.ConvertGuidToLong();
+ networkId = identifier.ConvertGuidToLong(System.Globalization.NumberStyles.HexNumber);
}
catch { }
diff --git a/SharedLibraryCore/Utilities.cs b/SharedLibraryCore/Utilities.cs
index e4b9ecaee..6892ed8b4 100644
--- a/SharedLibraryCore/Utilities.cs
+++ b/SharedLibraryCore/Utilities.cs
@@ -281,7 +281,7 @@ namespace SharedLibraryCore
}
}
- public static long ConvertGuidToLong(this string str, long? fallback = null)
+ public static long ConvertGuidToLong(this string str, NumberStyles numberStyle, long? fallback = null)
{
str = str.Substring(0, Math.Min(str.Length, 19));
var bot = Regex.Match(str, @"bot[0-9]+").Value;
@@ -291,20 +291,24 @@ namespace SharedLibraryCore
return fallback.Value;
}
- // this is a special case for Plutonium T6 and CoD4x
- if (long.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out long id))
+ long id = 0;
+
+ if (numberStyle == NumberStyles.Integer)
{
+ long.TryParse(str, numberStyle, CultureInfo.InvariantCulture, out id);
+
if (id < 0)
{
id = (uint)id;
}
}
- else if (long.TryParse(str.Length > 16 ? str.Substring(0, 16) : str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out id))
+ else
{
+ long.TryParse(str.Length > 16 ? str.Substring(0, 16) : str, numberStyle, CultureInfo.InvariantCulture, out id);
}
- else if (!string.IsNullOrEmpty(bot))
+ if (!string.IsNullOrEmpty(bot))
{
id = -1;
#if DEBUG