From 58404b97285c881d7963c99ef6775b6948e179bc Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Thu, 13 Apr 2023 09:17:06 +0200 Subject: [PATCH] Fix floor change regex (for pomanders) Not sure how or why that even broke, the string doesn't seem to have changed in the LogMessage sheet. Fixes #18. --- Pal.Client/DependencyInjection/ChatService.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Pal.Client/DependencyInjection/ChatService.cs b/Pal.Client/DependencyInjection/ChatService.cs index 2623aca..39dcbd6 100644 --- a/Pal.Client/DependencyInjection/ChatService.cs +++ b/Pal.Client/DependencyInjection/ChatService.cs @@ -1,4 +1,5 @@ using System; +using System.Text; using System.Text.RegularExpressions; using Dalamud.Data; using Dalamud.Game.Gui; @@ -82,14 +83,21 @@ internal sealed class ChatService : IDisposable HoardNotOnCurrentFloor = GetLocalizedString(7273), HoardCofferOpened = GetLocalizedString(7274), FloorChanged = - new Regex("^" + GetLocalizedString(7270).Replace("\u0002 \u0003\ufffd\u0002\u0003", @"(\d+)") + + new Regex("^" + GetLocalizedString(7270, true).Replace("\u0002 \u0003\ufffd\u0002\u0003", @"(\d+)") + "$"), }; } - private string GetLocalizedString(uint id) + private string GetLocalizedString(uint id, bool asRawData = false) { - return _dataManager.GetExcelSheet()?.GetRow(id)?.Text?.ToString() ?? "Unknown"; + var text = _dataManager.GetExcelSheet()?.GetRow(id)?.Text; + if (text == null) + return "Unknown"; + + if (asRawData) + return Encoding.UTF8.GetString(text.RawData); + else + return text.ToString(); } private sealed class LocalizedChatMessages