fix: censor tell target in Eureka in ScreenshotMode
This commit is contained in:
@@ -151,7 +151,11 @@ internal sealed unsafe class Chat : IDisposable {
|
|||||||
internal event ChatActivatedEventDelegate? Activated;
|
internal event ChatActivatedEventDelegate? Activated;
|
||||||
|
|
||||||
private Plugin Plugin { get; }
|
private Plugin Plugin { get; }
|
||||||
internal (InputChannel channel, List<Chunk> name) Channel { get; private set; }
|
/// <summary>
|
||||||
|
/// Holds the current game channel details. `tellplayerName` and
|
||||||
|
/// `tellWorldId` are only set when the channel is `InputChannel.Tell`.
|
||||||
|
/// </summary>
|
||||||
|
internal (InputChannel channel, List<Chunk> name, string? tellPlayerName, ushort tellWorldId) Channel { get; private set; }
|
||||||
|
|
||||||
internal bool UsesTellTempChannel { get; set; }
|
internal bool UsesTellTempChannel { get; set; }
|
||||||
internal InputChannel? PreviousChannel { get; private set; }
|
internal InputChannel? PreviousChannel { get; private set; }
|
||||||
@@ -515,9 +519,11 @@ internal sealed unsafe class Chat : IDisposable {
|
|||||||
private IntPtr ChangeChannelNameDetour(IntPtr agent)
|
private IntPtr ChangeChannelNameDetour(IntPtr agent)
|
||||||
{
|
{
|
||||||
// Last ShB patch
|
// Last ShB patch
|
||||||
// +0x40 = chat channel (byte or uint?)
|
// +0x40 = chat channel (byte or uint?)
|
||||||
// channel is 17 (maybe 18?) for tells
|
// channel is 17 (maybe 18?) for tells
|
||||||
// +0x48 = pointer to channel name string
|
// +0x48 = pointer to channel name string
|
||||||
|
// +0xDA = player name string for tells
|
||||||
|
// +0x120 = player world id for tells
|
||||||
var ret = ChangeChannelNameHook!.Original(agent);
|
var ret = ChangeChannelNameHook!.Original(agent);
|
||||||
if (agent == IntPtr.Zero)
|
if (agent == IntPtr.Zero)
|
||||||
return ret;
|
return ret;
|
||||||
@@ -528,13 +534,13 @@ internal sealed unsafe class Chat : IDisposable {
|
|||||||
if (shellModule == IntPtr.Zero)
|
if (shellModule == IntPtr.Zero)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
var channel = 0u;
|
var channel = (uint) InputChannel.Say;
|
||||||
if (ShellChannelOffset != null)
|
if (ShellChannelOffset != null)
|
||||||
channel = *(uint*) (shellModule + ShellChannelOffset.Value);
|
channel = *(uint*) (shellModule + ShellChannelOffset.Value);
|
||||||
|
|
||||||
// var channel = *(uint*) (agent + 0x40);
|
// var channel = *(uint*) (agent + 0x40);
|
||||||
if (channel is 17 or 18)
|
if (channel is 17 or 18)
|
||||||
channel = 0;
|
channel = (uint) InputChannel.Tell;
|
||||||
|
|
||||||
SeString? name = null;
|
SeString? name = null;
|
||||||
var namePtrPtr = (byte**) (agent + 0x48);
|
var namePtrPtr = (byte**) (agent + 0x48);
|
||||||
@@ -553,7 +559,16 @@ internal sealed unsafe class Chat : IDisposable {
|
|||||||
if (nameChunks.Count > 0 && nameChunks[0] is TextChunk text)
|
if (nameChunks.Count > 0 && nameChunks[0] is TextChunk text)
|
||||||
text.Content = text.Content.TrimStart('\uE01E').TrimStart();
|
text.Content = text.Content.TrimStart('\uE01E').TrimStart();
|
||||||
|
|
||||||
Channel = ((InputChannel) channel, nameChunks);
|
string? playerName = null;
|
||||||
|
ushort worldId = 0;
|
||||||
|
if (channel == (uint) InputChannel.Tell)
|
||||||
|
{
|
||||||
|
playerName = MemoryHelper.ReadStringNullTerminated(agent + 0xDA);
|
||||||
|
worldId = *(ushort*) (agent + 0x120);
|
||||||
|
Plugin.Log.Debug($"Detected tell target '{playerName}'@{worldId:X}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Channel = ((InputChannel) channel, nameChunks, playerName, worldId);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -513,6 +513,28 @@ public sealed class ChatLogWindow : Window, IUiComponent {
|
|||||||
}
|
}
|
||||||
} else if (Plugin.ExtraChat.ChannelOverride is var (overrideName, _)) {
|
} else if (Plugin.ExtraChat.ChannelOverride is var (overrideName, _)) {
|
||||||
ImGui.TextUnformatted(overrideName);
|
ImGui.TextUnformatted(overrideName);
|
||||||
|
} else if (ScreenshotMode && Plugin.Functions.Chat.Channel is (InputChannel.Tell, _, var tellPlayerName, var tellWorldId)) {
|
||||||
|
if (!string.IsNullOrWhiteSpace(tellPlayerName) && tellWorldId != 0)
|
||||||
|
{
|
||||||
|
var playerName = HashPlayer(tellPlayerName, tellWorldId);
|
||||||
|
var world = Plugin.DataManager.GetExcelSheet<World>()
|
||||||
|
?.GetRow(tellWorldId)
|
||||||
|
?.Name
|
||||||
|
?.RawString ?? "???";
|
||||||
|
|
||||||
|
DrawChunks(new Chunk[] {
|
||||||
|
new TextChunk(ChunkSource.None, null, "Tell "),
|
||||||
|
new TextChunk(ChunkSource.None, null, playerName),
|
||||||
|
new IconChunk(ChunkSource.None, null, BitmapFontIcon.CrossWorld),
|
||||||
|
new TextChunk(ChunkSource.None, null, world),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// We still need to censor the name if we couldn't read
|
||||||
|
// valid data.
|
||||||
|
ImGui.TextUnformatted("Tell");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
DrawChunks(Plugin.Functions.Chat.Channel.name);
|
DrawChunks(Plugin.Functions.Chat.Channel.name);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user