Skip to content

Commit

Permalink
feature(parser): Option to override special localize character
Browse files Browse the repository at this point in the history
  • Loading branch information
diamante0018 authored and RaidMax committed Nov 4, 2022
1 parent fe0929d commit c6916b3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Application/EventParsers/BaseEventParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public BaseEventParser(IParserRegexFactory parserRegexFactory, ILogger logger, A
Configuration = new DynamicEventParserConfiguration(parserRegexFactory)
{
GameDirectory = "main",
LocalizeText = "\x15",
};

Configuration.Say.Pattern = @"^(say|sayteam);(-?[A-Fa-f0-9_]{1,32}|bot[0-9]+|0);([0-9]+);([^;]*);(.*)$";
Expand Down Expand Up @@ -185,7 +186,7 @@ public virtual GameEvent GenerateGameEvent(string logLine)
if (matchResult.Success)
{
var message = matchResult.Values[Configuration.Say.GroupMapping[ParserRegex.GroupType.Message]]
.Replace("\x15", "")
.Replace(Configuration.LocalizeText, "")
.Trim();

if (message.Length > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal sealed class DynamicEventParserConfiguration : IEventParserConfiguratio
{
public string GameDirectory { get; set; }
public ParserRegex Say { get; set; }
public string LocalizeText { get; set; }
public ParserRegex Join { get; set; }
public ParserRegex JoinTeam { get; set; }
public ParserRegex Quit { get; set; }
Expand Down
1 change: 1 addition & 0 deletions Plugins/ScriptPlugins/ParserS1x.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var plugin = {
rconParser.Configuration.DefaultRConPort = 27016;

eventParser.Configuration.GameDirectory = '';
eventParser.Configuration.GameDirectory = '\x1F';

rconParser.Version = 'S1 MP 1.22 build 2195988 Wed Apr 18 11:26:14 2018 win64';
rconParser.GameName = 9; // SHG1
Expand Down
5 changes: 5 additions & 0 deletions SharedLibraryCore/Interfaces/IEventParserConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public interface IEventParserConfiguration
/// </summary>
ParserRegex Say { get; set; }

/// <summary>
/// stores the special ASCII value used by CoD games that prevents the text in the chat from being localized
/// </summary>
string LocalizeText { get; set; }

/// <summary>
/// stores the regex information for a join event printed in the game log
/// </summary>
Expand Down

0 comments on commit c6916b3

Please sign in to comment.