Fix #63
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Numerics;
|
||||
using System.Text;
|
||||
using ChatTwo.Code;
|
||||
using ChatTwo.GameFunctions.Types;
|
||||
using ChatTwo.Resources;
|
||||
using ChatTwo.Util;
|
||||
using Dalamud.Game.ClientState.Keys;
|
||||
using Dalamud.Game.Config;
|
||||
@@ -10,6 +11,7 @@ using Dalamud.Hooking;
|
||||
using Dalamud.Memory;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Dalamud.Utility.Signatures;
|
||||
using FFXIVClientStructs.FFXIV.Client.Network;
|
||||
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
||||
using FFXIVClientStructs.FFXIV.Client.System.String;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
@@ -46,10 +48,7 @@ internal sealed unsafe class Chat : IDisposable
|
||||
private readonly delegate* unmanaged<RaptureLogModule*, ushort, Utf8String*, Utf8String*, ulong, ushort, byte, int, byte, void> PrintTellNative = null!;
|
||||
|
||||
[Signature("E8 ?? ?? ?? ?? 48 8D 4C 24 ?? E8 ?? ?? ?? ?? 48 8D 8C 24 ?? ?? ?? ?? E8 ?? ?? ?? ?? B0 01")]
|
||||
private readonly delegate* unmanaged<nint, ulong, ushort, Utf8String*, Utf8String*, byte, ulong, byte> SendTellNative = null!;
|
||||
|
||||
[Signature("E8 ?? ?? ?? ?? F6 43 0A 40")]
|
||||
private readonly delegate* unmanaged<Framework*, nint> GetNetworkModule = null!;
|
||||
private readonly delegate* unmanaged<NetworkModule*, ulong, ushort, Utf8String*, Utf8String*, byte, ulong, bool> SendTellNative = null!;
|
||||
|
||||
// TODO Replace with CS in InfoProxyCrossworldLinkshell
|
||||
[Signature("E8 ?? ?? ?? ?? 48 8B C8 E8 ?? ?? ?? ?? 45 8D 46 FB")]
|
||||
@@ -703,22 +702,39 @@ internal sealed unsafe class Chat : IDisposable
|
||||
return new TellHistoryInfo(name, world, contentId);
|
||||
}
|
||||
|
||||
internal void SendTell(TellReason reason, ulong contentId, string name, ushort homeWorld, byte[] message)
|
||||
internal void SendTell(TellReason reason, ulong contentId, string name, ushort homeWorld, byte[] message, string rawText)
|
||||
{
|
||||
var uName = Utf8String.FromString(name);
|
||||
var uMessage = Utf8String.FromSequence(message);
|
||||
|
||||
var networkModule = GetNetworkModule(Framework.Instance());
|
||||
var a1 = *(IntPtr*) (networkModule + 8);
|
||||
var encoded = Utf8String.FromUtf8String(PronounModule.Instance()->ProcessString(uMessage, true));
|
||||
var decoded = EncodeMessage(rawText);
|
||||
AutoTranslate.ReplaceWithPayload(ref decoded);
|
||||
using var decodedUtf8String = new Utf8String(decoded);
|
||||
|
||||
var networkModule = Framework.Instance()->GetNetworkModuleProxy()->NetworkModule;
|
||||
var logModule = Framework.Instance()->GetUiModule()->GetRaptureLogModule();
|
||||
|
||||
SendTellNative(a1, contentId, homeWorld, uName, uMessage, (byte) reason, homeWorld);
|
||||
PrintTellNative(logModule, 33, uName, uMessage, contentId, homeWorld, 255, 0, 0);
|
||||
var ok = SendTellNative(networkModule, contentId, homeWorld, uName, encoded, (byte) reason, homeWorld);
|
||||
if (ok)
|
||||
PrintTellNative(logModule, 33, uName, &decodedUtf8String, contentId, homeWorld, 255, 0, 0);
|
||||
else
|
||||
Plugin.ChatGui.PrintError(Language.Chat_SendTell_Error);
|
||||
|
||||
encoded->Dtor(true);
|
||||
uName->Dtor(true);
|
||||
uMessage->Dtor(true);
|
||||
}
|
||||
|
||||
internal byte[] EncodeMessage(string str) {
|
||||
using var input = new Utf8String(str);
|
||||
using var ouput = new Utf8String();
|
||||
|
||||
input.Copy(PronounModule.Instance()->ProcessString(&input, true));
|
||||
ouput.Copy(PronounModule.Instance()->ProcessString(&input, false));
|
||||
return ouput.AsSpan().ToArray();
|
||||
}
|
||||
|
||||
internal bool IsCharValid(char c)
|
||||
{
|
||||
var uC = Utf8String.FromString(c.ToString());
|
||||
|
||||
Generated
+9
@@ -77,6 +77,15 @@ namespace ChatTwo.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to An error occured while sending this tell message.
|
||||
/// </summary>
|
||||
internal static string Chat_SendTell_Error {
|
||||
get {
|
||||
return ResourceManager.GetString("Chat_SendTell_Error", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Input is disabled for this tab.
|
||||
/// </summary>
|
||||
|
||||
@@ -1198,4 +1198,7 @@
|
||||
<data name="DbViewer_DatePicker_FromTo" xml:space="preserve">
|
||||
<value>FromTo:</value>
|
||||
</data>
|
||||
<data name="Chat_SendTell_Error" xml:space="preserve">
|
||||
<value>An error occured while sending this tell message</value>
|
||||
</data>
|
||||
</root>
|
||||
|
||||
@@ -840,7 +840,7 @@ public sealed class ChatLogWindow : Window
|
||||
var tellBytes = Encoding.UTF8.GetBytes(trimmed);
|
||||
AutoTranslate.ReplaceWithPayload(ref tellBytes);
|
||||
|
||||
Plugin.Functions.Chat.SendTell(reason, target.ContentId, target.Name, (ushort) world.RowId, tellBytes);
|
||||
Plugin.Functions.Chat.SendTell(reason, target.ContentId, target.Name, (ushort) world.RowId, tellBytes, trimmed);
|
||||
}
|
||||
|
||||
if (TempChannel is InputChannel.Tell)
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Text;
|
||||
using Dalamud;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Dalamud.Utility;
|
||||
using Lumina.Excel;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
@@ -293,7 +292,7 @@ internal static class AutoTranslate
|
||||
{
|
||||
var payload = ValidEntries.Contains((group, key))
|
||||
? new AutoTranslatePayload(group, key).Encode()
|
||||
: Array.Empty<byte>();
|
||||
: [];
|
||||
|
||||
var oldBytes = bytes.ToArray();
|
||||
var lengthDiff = payload.Length - (i - start);
|
||||
|
||||
@@ -301,7 +301,7 @@ internal static class ImGuiUtil
|
||||
public static void DrawArrows(ref int selected, int min, int max, float spacing, int id = 0)
|
||||
{
|
||||
// Prevents changing values from triggering EndDisable
|
||||
var isMin = selected == 1;
|
||||
var isMin = selected == min;
|
||||
var isMax = selected == max;
|
||||
|
||||
ImGui.SameLine(0, spacing);
|
||||
|
||||
Reference in New Issue
Block a user