forked from aly/qstbak
muffin v7.5.6
This commit is contained in:
parent
6266f9e6b7
commit
addf2d530f
619 changed files with 264792 additions and 446022 deletions
|
|
@ -2,52 +2,93 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
||||
using FFXIVClientStructs.FFXIV.Client.System.Memory;
|
||||
using FFXIVClientStructs.FFXIV.Client.System.String;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
using LLib;
|
||||
using Lumina.Excel.Sheets;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Questionable.Model.Questing;
|
||||
|
||||
namespace Questionable.Functions;
|
||||
|
||||
internal sealed class ChatFunctions
|
||||
{
|
||||
private delegate void ProcessChatBoxDelegate(nint uiModule, nint message, nint unused, byte a4);
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
private readonly struct ChatPayload : IDisposable
|
||||
[Serializable]
|
||||
[CompilerGenerated]
|
||||
private sealed class _003C_003Ec
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
private readonly nint textPtr;
|
||||
public static readonly _003C_003Ec _003C_003E9 = new _003C_003Ec();
|
||||
|
||||
[FieldOffset(16)]
|
||||
private readonly ulong textLen;
|
||||
public static Func<Emote, bool> _003C_003E9__3_0;
|
||||
|
||||
[FieldOffset(8)]
|
||||
private readonly ulong unk1;
|
||||
public static Func<Emote, bool> _003C_003E9__3_1;
|
||||
|
||||
[FieldOffset(24)]
|
||||
private readonly ulong unk2;
|
||||
public static Func<Emote, (uint RowId, string Command)> _003C_003E9__3_2;
|
||||
|
||||
internal ChatPayload(byte[] stringBytes)
|
||||
public static Func<(uint RowId, string Command), bool> _003C_003E9__3_3;
|
||||
|
||||
public static Func<(uint RowId, string Command), EEmote> _003C_003E9__3_4;
|
||||
|
||||
public static Func<(uint RowId, string Command), string> _003C_003E9__3_5;
|
||||
|
||||
internal bool _003C_002Ector_003Eb__3_0(Emote x)
|
||||
{
|
||||
textPtr = Marshal.AllocHGlobal(stringBytes.Length + 30);
|
||||
Marshal.Copy(stringBytes, 0, textPtr, stringBytes.Length);
|
||||
Marshal.WriteByte(textPtr + stringBytes.Length, 0);
|
||||
textLen = (ulong)(stringBytes.Length + 1);
|
||||
unk1 = 64uL;
|
||||
unk2 = 0uL;
|
||||
return x.RowId != 0;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
internal bool _003C_002Ector_003Eb__3_1(Emote x)
|
||||
{
|
||||
Marshal.FreeHGlobal(textPtr);
|
||||
return x.TextCommand.IsValid;
|
||||
}
|
||||
|
||||
internal (uint RowId, string Command) _003C_002Ector_003Eb__3_2(Emote x)
|
||||
{
|
||||
return (RowId: x.RowId, Command: x.TextCommand.Value.Command.ToString());
|
||||
}
|
||||
|
||||
internal bool _003C_002Ector_003Eb__3_3((uint RowId, string Command) x)
|
||||
{
|
||||
int num = (_200E_206A_206F_202E_206D_206E_206F_202B_202B_206A_200D_206B_202B_200D_206D_200C_202B_200E_202B_200C_200C_206F_202D_206C_200D_206D_202C_206B_202E_206D_200C_202D_202B_206B_200C_206F_202B_202D_206B_202D_202E(x.Command) ? 1902035638 : 1902035637);
|
||||
while (true)
|
||||
{
|
||||
int num2 = num;
|
||||
int num3 = 1902035639;
|
||||
int num4 = num2;
|
||||
int num5 = num4 + num3;
|
||||
int num6 = num4 & num3;
|
||||
switch (num5 - (num6 + num6))
|
||||
{
|
||||
case 1:
|
||||
return false;
|
||||
case 2:
|
||||
return _206E_202D_200C_202C_202E_200D_206C_202A_202D_206C_206A_202B_206D_202E_202B_200F_206F_206D_206F_206F_200D_206A_202E_202A_206A_206A_202D_200E_206B_206E_206B_202B_206C_202B_206B_200E_206B_202A_206F_206C_202E(x.Command, '/');
|
||||
case 0:
|
||||
goto IL_005d;
|
||||
}
|
||||
continue;
|
||||
IL_005d:
|
||||
num = 1902035637;
|
||||
}
|
||||
}
|
||||
|
||||
internal EEmote _003C_002Ector_003Eb__3_4((uint RowId, string Command) x)
|
||||
{
|
||||
return (EEmote)x.RowId;
|
||||
}
|
||||
|
||||
internal string _003C_002Ector_003Eb__3_5((uint RowId, string Command) x)
|
||||
{
|
||||
return x.Command;
|
||||
}
|
||||
|
||||
static bool _200E_206A_206F_202E_206D_206E_206F_202B_202B_206A_200D_206B_202B_200D_206D_200C_202B_200E_202B_200C_200C_206F_202D_206C_200D_206D_202C_206B_202E_206D_200C_202D_202B_206B_200C_206F_202B_202D_206B_202D_202E(string P_0)
|
||||
{
|
||||
return string.IsNullOrEmpty(P_0);
|
||||
}
|
||||
|
||||
static bool _206E_202D_200C_202C_202E_200D_206C_202A_202D_206C_206A_202B_206D_202E_202B_200F_206F_206D_206F_206F_200D_206A_202E_202A_206A_206A_202D_200E_206B_206E_206B_202B_206C_202B_206B_200E_206B_202A_206F_206C_202E(string P_0, char P_1)
|
||||
{
|
||||
return P_0.StartsWith(P_1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -57,83 +98,115 @@ internal sealed class ChatFunctions
|
|||
|
||||
private readonly ITargetManager _targetManager;
|
||||
|
||||
private readonly ILogger<ChatFunctions> _logger;
|
||||
|
||||
private readonly ProcessChatBoxDelegate _processChatBox;
|
||||
|
||||
public ChatFunctions(ISigScanner sigScanner, IDataManager dataManager, GameFunctions gameFunctions, ITargetManager targetManager, ILogger<ChatFunctions> logger)
|
||||
public ChatFunctions(IDataManager dataManager, GameFunctions gameFunctions, ITargetManager targetManager)
|
||||
{
|
||||
_gameFunctions = gameFunctions;
|
||||
_targetManager = targetManager;
|
||||
_logger = logger;
|
||||
_processChatBox = Marshal.GetDelegateForFunctionPointer<ProcessChatBoxDelegate>(UIModule.Addresses.ProcessChatBoxEntry.Value);
|
||||
_emoteCommands = (from x in dataManager.GetExcelSheet<Emote>()
|
||||
where x.RowId != 0
|
||||
where x.TextCommand.IsValid
|
||||
select (RowId: x.RowId, Command: x.TextCommand.Value.Command.ToString()) into x
|
||||
where !string.IsNullOrEmpty(x.Command) && x.Command.StartsWith('/')
|
||||
select x).ToDictionary<(uint, string), EEmote, string>(((uint RowId, string Command) x) => (EEmote)x.RowId, ((uint RowId, string Command) x) => x.Command).AsReadOnly();
|
||||
select (RowId: x.RowId, Command: x.TextCommand.Value.Command.ToString())).Where<(uint, string)>(delegate((uint RowId, string Command) x)
|
||||
{
|
||||
int num = (_003C_003Ec._200E_206A_206F_202E_206D_206E_206F_202B_202B_206A_200D_206B_202B_200D_206D_200C_202B_200E_202B_200C_200C_206F_202D_206C_200D_206D_202C_206B_202E_206D_200C_202D_202B_206B_200C_206F_202B_202D_206B_202D_202E(x.Command) ? 1902035638 : 1902035637);
|
||||
while (true)
|
||||
{
|
||||
int num2 = num;
|
||||
int num3 = 1902035639;
|
||||
int num4 = num2;
|
||||
int num5 = num4 + num3;
|
||||
int num6 = num4 & num3;
|
||||
switch (num5 - (num6 + num6))
|
||||
{
|
||||
case 1:
|
||||
return false;
|
||||
case 2:
|
||||
return _003C_003Ec._206E_202D_200C_202C_202E_200D_206C_202A_202D_206C_206A_202B_206D_202E_202B_200F_206F_206D_206F_206F_200D_206A_202E_202A_206A_206A_202D_200E_206B_206E_206B_202B_206C_202B_206B_200E_206B_202A_206F_206C_202E(x.Command, '/');
|
||||
case 0:
|
||||
goto IL_005d;
|
||||
}
|
||||
continue;
|
||||
IL_005d:
|
||||
num = 1902035637;
|
||||
}
|
||||
}).ToDictionary<(uint, string), EEmote, string>(((uint RowId, string Command) x) => (EEmote)x.RowId, ((uint RowId, string Command) x) => x.Command).AsReadOnly();
|
||||
}
|
||||
|
||||
private unsafe void SendMessageUnsafe(byte[] message)
|
||||
public static void ExecuteCommand(string command)
|
||||
{
|
||||
nint uIModule = (nint)Framework.Instance()->GetUIModule();
|
||||
using ChatPayload structure = new ChatPayload(message);
|
||||
nint num = Marshal.AllocHGlobal(400);
|
||||
Marshal.StructureToPtr(structure, num, fDeleteOld: false);
|
||||
_processChatBox(uIModule, num, IntPtr.Zero, 0);
|
||||
Marshal.FreeHGlobal(num);
|
||||
}
|
||||
|
||||
private void SendMessage(string message)
|
||||
{
|
||||
_logger.LogDebug("Attempting to send chat message '{Message}'", message);
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(message);
|
||||
if (bytes.Length == 0)
|
||||
int num = (_202D_202B_202A_202C_200E_206F_200C_206F_200B_202E_202C_200F_202A_200D_206C_202B_200B_206A_206B_200D_202A_206E_202A_202C_202B_206D_202B_202B_200D_206A_206D_202D_202D_206D_200F_200B_202D_202D_200B_202D_202E(command, '/') ? 1153841809 : 1153841810);
|
||||
while (true)
|
||||
{
|
||||
throw new ArgumentException("message is empty", "message");
|
||||
}
|
||||
if (bytes.Length > 500)
|
||||
{
|
||||
throw new ArgumentException("message is longer than 500 bytes", "message");
|
||||
}
|
||||
if (message.Length != SanitiseText(message).Length)
|
||||
{
|
||||
throw new ArgumentException("message contained invalid characters", "message");
|
||||
}
|
||||
SendMessageUnsafe(bytes);
|
||||
}
|
||||
|
||||
private unsafe string SanitiseText(string text)
|
||||
{
|
||||
Utf8String* intPtr = Utf8String.FromString(text);
|
||||
intPtr->SanitizeString(AllowedEntities.UppercaseLetters | AllowedEntities.LowercaseLetters | AllowedEntities.Numbers | AllowedEntities.SpecialCharacters | AllowedEntities.CharacterList | AllowedEntities.OtherCharacters | AllowedEntities.Payloads | AllowedEntities.Unknown9, null);
|
||||
string result = intPtr->ToString();
|
||||
intPtr->Dtor();
|
||||
IMemorySpace.Free(intPtr);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void ExecuteCommand(string command)
|
||||
{
|
||||
if (command.StartsWith('/'))
|
||||
{
|
||||
SendMessage(command);
|
||||
int num2 = num;
|
||||
int num3 = 1153841811;
|
||||
int num4 = num2;
|
||||
int num5 = num4 + num3;
|
||||
int num6 = num4 & num3;
|
||||
switch (num5 - (num6 + num6))
|
||||
{
|
||||
case 2:
|
||||
_200F_202B_200B_202A_202E_206A_202C_202B_206A_200E_202B_200C_200F_200D_206C_202B_206C_202B_206A_200B_202E_206C_200C_202E_206D_200B_200E_206C_206E_202A_206B_206F_200E_206A_202E_206C_206C_206C_202D_200C_202E(command);
|
||||
return;
|
||||
case 1:
|
||||
return;
|
||||
case 0:
|
||||
goto IL_0052;
|
||||
}
|
||||
continue;
|
||||
IL_0052:
|
||||
num = 1153841810;
|
||||
}
|
||||
}
|
||||
|
||||
public void UseEmote(uint dataId, EEmote emote)
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public bool UseEmote(uint dataId, EEmote emote)
|
||||
{
|
||||
IGameObject gameObject = _gameFunctions.FindObjectByDataId(dataId);
|
||||
if (gameObject != null)
|
||||
int num = ((gameObject == null) ? (-888767094) : (-888767093));
|
||||
while (true)
|
||||
{
|
||||
_targetManager.Target = gameObject;
|
||||
ExecuteCommand(_emoteCommands[emote] + " motion");
|
||||
int num2 = num;
|
||||
int num3 = -888767094;
|
||||
int num4 = num2;
|
||||
switch ((num4 | num3) - (num4 & num3))
|
||||
{
|
||||
case 2:
|
||||
goto IL_005b;
|
||||
case 1:
|
||||
_202A_200D_202E_206A_202D_200E_202D_202B_206F_200F_202C_200B_200D_200E_202A_200B_206A_206F_200E_202C_206C_206E_206F_202A_202A_206E_200F_202A_200D_200F_206C_202A_206D_206F_200F_200B_202B_206B_200E_200F_202E(_targetManager, gameObject);
|
||||
ExecuteCommand(_206D_206D_200D_206B_202D_200F_202C_206F_206B_206B_200D_206B_206E_202D_202A_206E_206E_206B_200D_206F_202C_206B_202B_200F_202C_206C_202A_206C_202B_200F_206B_202A_202D_200F_206F_202C_206C_200F_206A_206A_202E(_emoteCommands[emote], global::_003CModule_003E._202A_206B_206D_200C_206B_200E_200E_202A_200B_202E_206A_206F_206A_206B_200E_200D_200F_206D_206E_206A_206F_200C_206C_202C_202A_206E_202C_200B_206E_202A_206E_202B_206B_202E_202E_206A_206D_206D_202C_200F_202E<string>(-1428224074)));
|
||||
return true;
|
||||
case 0:
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
IL_005b:
|
||||
num = -888767093;
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public void UseEmote(EEmote emote)
|
||||
{
|
||||
ExecuteCommand(_emoteCommands[emote] + " motion");
|
||||
ExecuteCommand(_206D_206D_200D_206B_202D_200F_202C_206F_206B_206B_200D_206B_206E_202D_202A_206E_206E_206B_200D_206F_202C_206B_202B_200F_202C_206C_202A_206C_202B_200F_206B_202A_202D_200F_206F_202C_206C_200F_206A_206A_202E(_emoteCommands[emote], global::_003CModule_003E._202A_206B_206D_200C_206B_200E_200E_202A_200B_202E_206A_206F_206A_206B_200E_200D_200F_206D_206E_206A_206F_200C_206C_202C_202A_206E_202C_200B_206E_202A_206E_202B_206B_202E_202E_206A_206D_206D_202C_200F_202E<string>(-1428224074)));
|
||||
}
|
||||
|
||||
static bool _202D_202B_202A_202C_200E_206F_200C_206F_200B_202E_202C_200F_202A_200D_206C_202B_200B_206A_206B_200D_202A_206E_202A_202C_202B_206D_202B_202B_200D_206A_206D_202D_202D_206D_200F_200B_202D_202D_200B_202D_202E(string P_0, char P_1)
|
||||
{
|
||||
return P_0.StartsWith(P_1);
|
||||
}
|
||||
|
||||
static void _200F_202B_200B_202A_202E_206A_202C_202B_206A_200E_202B_200C_200F_200D_206C_202B_206C_202B_206A_200B_202E_206C_200C_202E_206D_200B_200E_206C_206E_202A_206B_206F_200E_206A_202E_206C_206C_206C_202D_200C_202E(string P_0)
|
||||
{
|
||||
ChatHelper.SendCommand(P_0);
|
||||
}
|
||||
|
||||
static void _202A_200D_202E_206A_202D_200E_202D_202B_206F_200F_202C_200B_200D_200E_202A_200B_206A_206F_200E_202C_206C_206E_206F_202A_202A_206E_200F_202A_200D_200F_206C_202A_206D_206F_200F_200B_202B_206B_200E_200F_202E(ITargetManager P_0, IGameObject P_1)
|
||||
{
|
||||
P_0.Target = P_1;
|
||||
}
|
||||
|
||||
static string _206D_206D_200D_206B_202D_200F_202C_206F_206B_206B_200D_206B_206E_202D_202A_206E_206E_206B_200D_206F_202C_206B_202B_200F_202C_206C_202A_206C_202B_200F_206B_202A_202D_200F_206F_202C_206C_200F_206A_206A_202E(string P_0, string P_1)
|
||||
{
|
||||
return P_0 + P_1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue