fix: process pf strings as sestrings

This commit is contained in:
Anna 2021-03-03 20:29:24 -05:00
parent 30d44bd01b
commit 6b9b17971b
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
2 changed files with 23 additions and 14 deletions

View File

@ -217,7 +217,11 @@ namespace NoSoliciting {
continue; continue;
} }
var desc = listing.Description(); var rawName = listing.Name(this.Plugin.Interface.SeStringManager);
var rawDesc = listing.Description(this.Plugin.Interface.SeStringManager);
var name = rawName.TextValue;
var desc = rawDesc.TextValue;
string? reason = null; string? reason = null;
@ -245,8 +249,8 @@ namespace NoSoliciting {
this.Plugin.AddPartyFinderHistory(new Message( this.Plugin.AddPartyFinderHistory(new Message(
this.Plugin.MlFilter.Version, this.Plugin.MlFilter.Version,
ChatType.None, ChatType.None,
listing.Name(), rawName,
listing.Description(), rawDesc,
true, true,
reason reason
)); ));
@ -259,7 +263,7 @@ namespace NoSoliciting {
packet.listings[i] = new PfListing(); packet.listings[i] = new PfListing();
if (this.Plugin.Config.LogFilteredPfs) { if (this.Plugin.Config.LogFilteredPfs) {
PluginLog.Log($"Filtered PF listing from {listing.Name()} ({reason}): {listing.Description()}"); PluginLog.Log($"Filtered PF listing from {name} ({reason}): {desc}");
} }
} }
@ -301,7 +305,11 @@ namespace NoSoliciting {
continue; continue;
} }
var desc = listing.Description(); var rawName = listing.Name(this.Plugin.Interface.SeStringManager);
var rawDesc = listing.Description(this.Plugin.Interface.SeStringManager);
var name = rawName.TextValue;
var desc = rawDesc.TextValue;
string? reason = null; string? reason = null;
var filter = false; var filter = false;
@ -325,8 +333,8 @@ namespace NoSoliciting {
this.Plugin.AddPartyFinderHistory(new Message( this.Plugin.AddPartyFinderHistory(new Message(
this.Plugin.Definitions.Version, this.Plugin.Definitions.Version,
ChatType.None, ChatType.None,
listing.Name(), rawName,
listing.Description(), rawDesc,
false, false,
reason reason
)); ));
@ -339,7 +347,7 @@ namespace NoSoliciting {
packet.listings[i] = new PfListing(); packet.listings[i] = new PfListing();
if (this.Plugin.Config.LogFilteredPfs) { if (this.Plugin.Config.LogFilteredPfs) {
PluginLog.Log($"Filtered PF listing from {listing.Name()} ({reason}): {listing.Description()}"); PluginLog.Log($"Filtered PF listing from {name} ({reason}): {desc}");
} }
} }

View File

@ -2,6 +2,7 @@
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using Dalamud.Game.Chat.SeStringHandling;
namespace NoSoliciting { namespace NoSoliciting {
public static class PacketInfo { public static class PacketInfo {
@ -95,17 +96,17 @@ namespace NoSoliciting {
// 160 (0xA0) with name (32 bytes/0x20) // 160 (0xA0) with name (32 bytes/0x20)
// 352 (0x160) with both (192 bytes/0xC0) // 352 (0x160) with both (192 bytes/0xC0)
private static string HandleString(IEnumerable<byte> bytes) { private static SeString HandleString(SeStringManager manager, IEnumerable<byte> bytes) {
var nonNull = bytes.TakeWhile(b => b != 0).ToArray(); var nonNull = bytes.TakeWhile(b => b != 0).ToArray();
return Encoding.UTF8.GetString(nonNull); return manager.Parse(nonNull);
} }
internal string Name() { internal SeString Name(SeStringManager manager) {
return HandleString(this.name); return HandleString(manager, this.name);
} }
internal string Description() { internal SeString Description(SeStringManager manager) {
return HandleString(this.description); return HandleString(manager, this.description);
} }
internal bool IsNull() { internal bool IsNull() {