From fd83590526e1abf560da19b77b4d6ba98d82b246 Mon Sep 17 00:00:00 2001 From: Robert Baker Date: Thu, 30 Sep 2021 00:10:43 -0700 Subject: [PATCH] Fixes Chinese regex This worked on local testing, but if someone could verify my changes, that'd be ideal! --- Dalamud/Game/Command/CommandManager.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Dalamud/Game/Command/CommandManager.cs b/Dalamud/Game/Command/CommandManager.cs index 23a8dc2ab..a0c0c6243 100644 --- a/Dalamud/Game/Command/CommandManager.cs +++ b/Dalamud/Game/Command/CommandManager.cs @@ -24,7 +24,7 @@ namespace Dalamud.Game.Command private readonly Regex commandRegexJp = new(@"^そのコマンドはありません。: (?.+)$", RegexOptions.Compiled); private readonly Regex commandRegexDe = new(@"^„(?.+)“ existiert nicht als Textkommando\.$", RegexOptions.Compiled); private readonly Regex commandRegexFr = new(@"^La commande texte “(?.+)” n'existe pas\.$", RegexOptions.Compiled); - private readonly Regex commandRegexCn = new(@"^“(?.+)”出现问题:该命令不存在。$", RegexOptions.Compiled); + private readonly Regex commandRegexCn = new(@"^“(?.+)”出現問題:該命令不存在。$", RegexOptions.Compiled); private readonly Regex currentLangCommandRegex; /// @@ -40,7 +40,6 @@ namespace Dalamud.Game.Command ClientLanguage.English => this.commandRegexEn, ClientLanguage.German => this.commandRegexDe, ClientLanguage.French => this.commandRegexFr, - ClientLanguage.ChineseSimplified => this.commandRegexCn, _ => this.currentLangCommandRegex, }; @@ -161,6 +160,21 @@ namespace Dalamud.Game.Command var command = cmdMatch.Value; if (this.ProcessCommand(command)) isHandled = true; } + else + { + // I tried to get the start info to determine language with an else if and it failed, so this always checks instead + // Log.Debug("Trying Chinese mod pack command parse as fallback"); + // Log.Information($"Message: {message.ToString()}"); + // Japanese failed. Try Chinese as a fallback. + cmdMatch = this.commandRegexCn.Match(message.TextValue).Groups["command"]; + // Log.Information($"Success:{cmdMatch2.Success} Groups: {this.commandRegexCn.Match(message.TextValue).Groups.Keys.GetEnumerator().Current}\nValues:{cmdMatch2.Value}"); + if (cmdMatch.Success) + { + // Yes, it's a Chinese fallback chat command. + var command = cmdMatch.Value; + if (this.ProcessCommand(command)) isHandled = true; + } + } } } }