fix: properly filter ExtraChat channels

This commit is contained in:
Anna
2022-08-27 15:55:47 -04:00
parent b3456f8fcd
commit 3ce0c3dc50
3 changed files with 119 additions and 23 deletions
+5 -8
View File
@@ -2,7 +2,6 @@ using ChatTwo.Code;
using ChatTwo.Resources;
using ChatTwo.Ui;
using Dalamud.Configuration;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Logging;
using ImGuiNET;
@@ -50,6 +49,8 @@ internal class Configuration : IPluginConfiguration {
public Dictionary<ChatType, uint> ChatColours = new();
public List<Tab> Tabs = new();
public uint DatabaseMigration;
internal void UpdateFrom(Configuration other) {
this.HideChat = other.HideChat;
this.HideDuringCutscenes = other.HideDuringCutscenes;
@@ -84,6 +85,7 @@ internal class Configuration : IPluginConfiguration {
this.WindowAlpha = other.WindowAlpha;
this.ChatColours = other.ChatColours.ToDictionary(entry => entry.Key, entry => entry.Value);
this.Tabs = other.Tabs.Select(t => t.Clone()).ToList();
this.DatabaseMigration = other.DatabaseMigration;
}
public void Migrate() {
@@ -183,13 +185,8 @@ internal class Tab {
}
internal bool Matches(Message message) {
if (message.ContentSource.Payloads.Count > 0 && message.ContentSource.Payloads[0] is RawPayload raw) {
// this does an encode and clone every time it's accessed, so cache
var data = raw.Data;
if (data[1] == 0x27 && data[2] == 18 && data[3] == 0x20) {
var extraChatChannel = new Guid(data[4..^1]);
return this.ExtraChatAll || this.ExtraChatChannels.Contains(extraChatChannel);
}
if (message.ExtraChatChannel != Guid.Empty) {
return this.ExtraChatAll || this.ExtraChatChannels.Contains(message.ExtraChatChannel);
}
return message.Code.Type.IsGm()