Snapshot for release 2026.10.8.1 (internal e654aa5)

This commit is contained in:
Tom Bohar 2026-10-08 17:29:52 -04:00
commit 650915dadc
26 changed files with 1154 additions and 30 deletions

View file

@ -0,0 +1,215 @@
// ============================================================================
// RynthCore.Engine - Compatibility/AcMouseOver.cs
//
// "Is the cursor on the 3D world, or on one of AC's own windows?" - AC's own
// answer, read out of its UI manager. The world overlays (RynthVision's
// nameplates) draw under AC's windows (ImGui/UnderUiLayer); a plate behind
// the inventory must not take the click meant for the inventory (2026-10-08
// report: "it's behind the UI, but I can't select anything that has the hud
// behind it"). MonsterHud asks here before a plate keeps a click from AC.
//
// Evidence (AC client decompile, C:\Projects\GhidraTools\decompiled):
// UIElementManager::MouseMoveHandler (0x0045E7F0), ::MouseDownEvent
// (0x0045DC40), ::UpdateMouseOver (0x0045C390) and ::DoMouseUpdate
// (0x0045CDE0, run from UseTime when +0x240 is set) all do the same:
// unless +0x2D4 is set (the cursor left the client: MouseLeaveEvent
// 0x0045C380 sets it), MouseOverCriteria::Recurse (0x00459490) walks the
// tree from the root (+0x9C), topmost child first, and returns the deepest
// visible element under the point that takes the mouse (its +0x545 byte or
// +0xA4 bit 6); SwitchMouseOver (0x0045B640) stores it at +0x244.
// MouseDownEvent then routes the press by it (+0x248, the hover element,
// gets the capture), so +0x244 is exactly what AC will send a click to.
// DeletingElement (0x0045E600) clears +0x244 (and sets +0x240) when that
// element goes, so on AC's main thread the pointer is live or zero.
// The 3D view is UIElement_SmartBoxWrapper: GetUIElementType (0x004E5E80)
// returns 0x10000030, Register (0x004E60A0) registers that type. Its
// MouseDown (0x004E6390) is AC's click-in-the-world (FindObject); for a
// world click to select anything it must be the element under the mouse.
// UIElement vtable +0x98 = GetUIElementType, +0xA0 = GetParent, +0x2E4 the
// element id: as verified for UiElementHooks (tools/ui_hooks_check.py).
// The manager pointer is `this` of UiElementHooks' detours (CheckTooltip runs
// every frame from UIElementManager::UseTime 0x0045D0B0); the singleton global
// (0x0083E03C, CreateUIElementManager 0x0045F900) is not used, to ship no fixed
// address. No manager (tooltip hooks off or not found) = Unknown = fail open.
//
// Not confirmed in game yet: that the element under the mouse over open
// ground is the SmartBox wrapper itself rather than a child. `/rc acmouse`
// (or `/rc acmouse watch` for 20 s of changes in chat) names what AC has
// under the cursor; Identify is the one place that decides.
//
// Threads: AC's main thread only (EndScene and the UI detours run there);
// anything else gets Unknown. Every read goes through the memory probe first.
// ============================================================================
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
namespace RynthCore.Engine.Compatibility;
internal static unsafe class AcMouseOver
{
private const int MgrMouseOver = 0x244; // raw element under the mouse (SwitchMouseOver)
private const int MgrMouseOutside = 0x2D4; // byte: cursor left the client (MouseLeaveEvent)
private const int ElementIdOffset = 0x2E4;
private const int VtGetUIElementType = 0x98;
private const int VtGetParent = 0xA0;
/// <summary>One read of AC's mouse-over state (diagnostics carry the ids).</summary>
public struct Sample
{
public AcMouseTarget Target;
public IntPtr Element;
public uint ElementId;
public bool TypeKnown;
public int Type;
}
// Main thread only. Element type per vtable: GetUIElementType returns a constant per
// class, so each class is asked once (113 UIElement classes in the client).
private static readonly Dictionary<IntPtr, int> TypeByVtable = new();
private static Sample _last;
private static long _watchUntil;
private static IntPtr _watchLastElement = new(-1);
private static int _watchLines;
/// <summary>AC's main thread: what AC's UI has under the mouse right now.</summary>
public static AcMouseTarget Current() => Read().Target;
/// <summary>AC's main thread: AC's mouse-over state, with the element's id and type.</summary>
public static Sample Read()
{
var s = new Sample { Target = AcMouseTarget.Unknown };
try
{
if (!MainThreadGuard.IsOnMainThread())
return s;
IntPtr mgr = UiElementHooks.Manager;
bool readable = mgr != IntPtr.Zero
&& ClientObjectHooks.IsReadableSpan(mgr + MgrMouseOver, 4)
&& ClientObjectHooks.IsReadableSpan(mgr + MgrMouseOutside, 1);
if (!readable)
return _last = s;
bool outside = *(byte*)(mgr + MgrMouseOutside) != 0;
s.Element = *(IntPtr*)(mgr + MgrMouseOver);
if (!outside && s.Element != IntPtr.Zero)
{
s.TypeKnown = TryGetType(s.Element, out s.Type);
if (ClientObjectHooks.IsReadableSpan(s.Element + ElementIdOffset, 4))
s.ElementId = *(uint*)(s.Element + ElementIdOffset);
}
s.Target = Identify(readable, outside, s.Element, s.TypeKnown, s.Type);
}
catch
{
s.Target = AcMouseTarget.Unknown;
}
return _last = s;
}
/// <summary>
/// The one decision: the 3D view is the SmartBox wrapper element (type 0x10000030);
/// any other element AC reports is one of its windows; nothing readable is Unknown.
/// </summary>
private static AcMouseTarget Identify(bool readable, bool outside, IntPtr element, bool typeKnown, int type)
=> AcMouseOverRules.Classify(readable, outside, (uint)element.ToInt32(), typeKnown, type);
/// <summary>The element's UIElement type (vtable +0x98), asked once per class. Main thread.</summary>
private static bool TryGetType(IntPtr element, out int type)
{
type = 0;
if (!ClientObjectHooks.TryReadAcObjectVtable(element, out IntPtr vtable))
return false;
if (TypeByVtable.TryGetValue(vtable, out type))
return true;
if (!ClientObjectHooks.IsReadableSpan(vtable + VtGetUIElementType, 4))
return false;
IntPtr fn = *(IntPtr*)(vtable + VtGetUIElementType);
if (!SmartBoxLocator.IsPointerInModule(fn))
return false;
type = ((delegate* unmanaged[Thiscall]<IntPtr, int>)fn)(element);
if (TypeByVtable.Count < 512)
TypeByVtable[vtable] = type;
return true;
}
/// <summary>The parent's id and type, for the diagnostics only. Main thread.</summary>
private static string DescribeParent(IntPtr element)
{
if (!ClientObjectHooks.TryReadAcObjectVtable(element, out IntPtr vtable)
|| !ClientObjectHooks.IsReadableSpan(vtable + VtGetParent, 4))
return "parent ?";
IntPtr fn = *(IntPtr*)(vtable + VtGetParent);
if (!SmartBoxLocator.IsPointerInModule(fn))
return "parent ?";
IntPtr parent = ((delegate* unmanaged[Thiscall]<IntPtr, IntPtr>)fn)(element);
if (parent == IntPtr.Zero)
return "no parent";
uint id = ClientObjectHooks.IsReadableSpan(parent + ElementIdOffset, 4) ? *(uint*)(parent + ElementIdOffset) : 0;
return TryGetType(parent, out int t) ? $"parent id 0x{id:X8} type 0x{t:X8}" : $"parent id 0x{id:X8} type ?";
}
private static string Format(in Sample s, bool withParent)
{
string what = s.Target switch
{
AcMouseTarget.World => "the 3D world (plates may take the click)",
AcMouseTarget.AcWindow => "an AC window (plates leave the click to AC)",
AcMouseTarget.Nothing => "nothing (plates may take the click)",
_ => "unknown - AC's UI state not readable (plates may take the click)",
};
if (s.Element == IntPtr.Zero)
return $"AC mouse-over: {what}.";
string type = s.TypeKnown ? $"0x{s.Type:X8}" : "?";
string parent = "";
if (withParent)
{
try { parent = ", " + DescribeParent(s.Element); } catch { parent = ", parent ?"; }
}
return $"AC mouse-over: {what}; element id 0x{s.ElementId:X8} type {type}{parent}.";
}
/// <summary>/rc acmouse: the state now (main thread: read live; elsewhere the last read).</summary>
public static string Describe()
{
bool live = MainThreadGuard.IsOnMainThread();
Sample s = live ? Read() : _last;
return Format(s, live) + (UiElementHooks.Manager == IntPtr.Zero ? " (UI manager not seen yet: the tooltip hooks are off or haven't run.)" : "");
}
/// <summary>/rc acmouse watch: every change of the element under the mouse, for <paramref name="seconds"/>.</summary>
public static void Watch(int seconds)
{
_watchLastElement = new IntPtr(-1);
_watchLines = 0;
Volatile.Write(ref _watchUntil, Stopwatch.GetTimestamp() + Stopwatch.Frequency * Math.Clamp(seconds, 1, 120));
}
/// <summary>Once a frame on AC's main thread (EngineFrameController): the watch, when on.</summary>
public static void Tick()
{
long until = Volatile.Read(ref _watchUntil);
if (until == 0)
return;
if (Stopwatch.GetTimestamp() > until || _watchLines >= 60)
{
_watchUntil = 0;
Say("AC mouse-over watch ended.");
return;
}
Sample s = Read();
if (s.Element == _watchLastElement)
return;
_watchLastElement = s.Element;
_watchLines++;
Say(Format(s, true));
}
private static void Say(string text)
{
RynthLog.Compat(text);
AcMainThreadQueue.EnqueueWriteToChat("[RynthCore] " + text, 1);
}
}

View file

@ -0,0 +1,54 @@
// ============================================================================
// RynthCore.Engine - Compatibility/AcMouseOverRules.cs
//
// The pure half of AcMouseOver: given what was read out of AC's UI manager,
// is the cursor on the 3D world or on one of AC's own windows, and may a world
// overlay (a RynthVision nameplate, drawn under AC's windows) take a click
// there? No AC memory, no engine state: tools/AcMouseOverTests compiles this
// file in and checks every case offline.
//
// Evidence for the constants is in AcMouseOver.cs.
// ============================================================================
namespace RynthCore.Engine.Compatibility;
/// <summary>What AC's own UI has under the mouse.</summary>
internal enum AcMouseTarget
{
/// <summary>AC's UI state couldn't be read (no manager yet, unreadable memory, not AC's thread).</summary>
Unknown,
/// <summary>AC reports nothing under the mouse (cursor outside the client, or no element took it).</summary>
Nothing,
/// <summary>The 3D view: AC's SmartBox wrapper element (UIElement type 0x10000030).</summary>
World,
/// <summary>Any other AC element: a window (inventory, chat, radar, vitals, the selected-object bar...).</summary>
AcWindow,
}
internal static class AcMouseOverRules
{
/// <summary>UIElement_SmartBoxWrapper::GetUIElementType (0x004E5E80) returns this; it is the 3D view.</summary>
public const int UIElementTypeSmartBoxWrapper = 0x10000030;
/// <summary>
/// Classifies one read of UIElementManager. <paramref name="stateReadable"/>: the manager
/// was known and its fields readable. <paramref name="mouseOutside"/>: its +0x2D4 flag (the
/// cursor left the client; AC then hit-tests nothing). <paramref name="element"/>: +0x244,
/// the raw element under the mouse. <paramref name="typeKnown"/>/<paramref name="elementType"/>:
/// that element's GetUIElementType, when it could be read safely.
/// </summary>
public static AcMouseTarget Classify(bool stateReadable, bool mouseOutside, uint element, bool typeKnown, int elementType)
{
if (!stateReadable) return AcMouseTarget.Unknown;
if (mouseOutside || element == 0) return AcMouseTarget.Nothing;
if (!typeKnown) return AcMouseTarget.Unknown;
return elementType == UIElementTypeSmartBoxWrapper ? AcMouseTarget.World : AcMouseTarget.AcWindow;
}
/// <summary>
/// May an overlay drawn under AC's windows take the click? Only an AC window under the
/// mouse says no: the world says yes, and so does anything AC can't tell us (fail open:
/// the plates keep today's behaviour when AC's UI can't be read).
/// </summary>
public static bool UnderUiOverlayMayTakeClick(AcMouseTarget target) => target != AcMouseTarget.AcWindow;
}

View file

@ -57,6 +57,8 @@ internal static unsafe class ChatCommandDispatcher
private const uint WM_KEYUP = 0x0101;
private const uint WM_CHAR = 0x0102;
private const int VK_RETURN = 0x0D;
/// <summary>ChatMessageType AC prints its own command notices in ("Someone must @tell you first!").</summary>
private const int ChatTypeNotice = 0x1A;
/// <summary>
/// When true, all commands are dispatched via keyboard simulation
@ -169,6 +171,18 @@ internal static unsafe class ChatCommandDispatcher
finally { _inPluginPreDispatch = false; }
}
// /reply (/r) and /retell (/rt) become a /tell to the last person who told you
// something / you told something (TellMemory.cs says why AC can't do them here).
if (TellMemory.Shared.TryRewrite(trimmed, out string? tellLine, out string? tellError))
{
if (tellLine == null)
{
AcMainThreadQueue.EnqueueWriteToChat(tellError!, ChatTypeNotice);
return false;
}
trimmed = tellLine;
}
// Direct Chat Input mode — everything goes through keyboard sim
if (UseDirectChatInput)
return SimulateChatInput(trimmed);
@ -298,6 +312,8 @@ internal static unsafe class ChatCommandDispatcher
if (targetName.Length == 0 || message.Length == 0)
return false;
// AC's /tell would remember this name for its /retell; this call skips AC's parser.
TellMemory.Shared.NoteTellSent(targetName);
var psMsg = LegacyPString.Create(message);
var psTarget = LegacyPString.Create(targetName);
try

View file

@ -57,6 +57,10 @@ namespace RynthCore.Engine.Compatibility;
/// (nameplates, combat text, Nav3D markers) draw in AC's frame
/// (<see cref="D3D9.Nav3DRenderInjector"/>): alone it reports the path and counters;
/// a mode forces it for this session (A/B checks). Auto at every start; not saved.</item>
/// <item><c>/rc acmouse [watch [seconds]]</c> (alias <c>/rc mouseover</c>) - what AC's own UI
/// has under the cursor (<see cref="AcMouseOver"/>: the 3D world or one of its windows,
/// with the element's id and type), i.e. whether a nameplate there may take the click;
/// watch = every change for a while (default 20 s), to chat and the log.</item>
/// <item><c>/rc netmsg [status|on|off|log on|off|capture on|off]</c> - the reassembled
/// server-message stream for plugins (<see cref="Net.ServerMessageStream"/>, API v78):
/// counters; on/off for this session (engine.json "ServerMessageStream": false is the
@ -170,6 +174,28 @@ internal static class RynthCoreChatCommands
return true;
}
// /rc acmouse [watch [seconds]] : what AC's own UI has under the cursor (the 3D world or
// one of its windows) - whether a nameplate there may take the click (AcMouseOver)
if (IsVerb(sub, "acmouse", out string acMouseArgs) || IsVerb(sub, "mouseover", out acMouseArgs))
{
try
{
string[] p = acMouseArgs.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (p.Length > 0 && p[0].Equals("watch", StringComparison.OrdinalIgnoreCase))
{
int secs = p.Length > 1 && int.TryParse(p[1], out int n) ? n : 20;
AcMouseOver.Watch(secs);
Reply($"Watching AC's mouse-over for {Math.Clamp(secs, 1, 120)} s: move the cursor over the world and over AC's windows.");
}
else
{
Reply(AcMouseOver.Describe());
}
}
catch (Exception ex) { RynthLog.Compat($"RynthCoreChatCommands: /rc acmouse failed - {ex.GetType().Name}: {ex.Message}"); }
return true;
}
// /rc video [status|off|world|unfocused|all|fps <n>] : the video patch (stop drawing the 3D world)
if (IsVerb(sub, "video", out string videoArgs) || IsVerb(sub, "videopatch", out videoArgs))
{

View file

@ -0,0 +1,146 @@
// ============================================================================
// RynthCore.Engine - Compatibility/TellMemory.cs
//
// /reply (/r) and /retell (/rt): who last sent you a tell, who you last sent
// one to, and the rewrite of "/r text" into "/tell Name, text".
//
// Retail AC answers these itself (ClientCommunicationSystem::DoReply/DoReTell),
// from state its own /tell and its own incoming-tell handler keep. Neither
// holds up under RynthCore: our /tell goes straight to Event_TalkDirectByName,
// so AC never learns who you told (its /retell says "provide a name using
// @tell"), and /r and /rt reach AC's parser only through the raw path, which
// depends on a captured chat-bar 'this' (keystroke simulation until then).
// So ChatCommandDispatcher rewrites them to a /tell, from what this class
// reads off the chat lines:
// - "<Tell:IIDString:id:Bob>Bob<\Tell> tells you, ..." (type 3) - AC adds the
// link only for a player, so NPC tells (no link) never become the reply
// target, as in retail;
// - "You tell Bob, ..." (type 4, the server's echo of any tell you sent,
// whichever chat sent it) and every /tell the dispatcher sends.
//
// Pure (no AC, no engine state) so tools\ChatTellTests can compile it in.
// ============================================================================
using System;
using System.Text.RegularExpressions;
using System.Threading;
namespace RynthCore.Engine.Compatibility;
internal enum TellShortcut { None, Reply, Retell }
internal sealed class TellMemory
{
/// <summary>The engine's one instance (chat lines in, dispatcher and chat input out).</summary>
public static readonly TellMemory Shared = new();
// Short enough for RynthChat's empty input box, where they show too.
public const string NoTellerMessage = "No one has sent you a tell yet - no one to /reply to.";
public const string NoTelleeMessage = "You haven't sent a tell yet - no one to /retell to.";
private string? _lastTeller, _lastTellee;
/// <summary>The player who last sent you a tell, or null.</summary>
public string? LastTeller => Volatile.Read(ref _lastTeller);
/// <summary>The player you last sent a tell to, or null.</summary>
public string? LastTellee => Volatile.Read(ref _lastTellee);
// AC's player link (HearDirectSpeech prints it for player senders only).
private static readonly Regex IncomingTell = new(
@"^\s*<Tell:IIDString:\d+:([^>]*)>[^<]*<\\Tell> tells you, ",
RegexOptions.CultureInvariant, TimeSpan.FromMilliseconds(20));
private static readonly Regex OutgoingTell = new(
@"^\s*You tell ([^,]+), ",
RegexOptions.CultureInvariant, TimeSpan.FromMilliseconds(20));
/// <summary>
/// An incoming chat line, as AC prints it. Any thread. Matched by its text, not its
/// chat type (3 and 4 on the native hook; the Decal bridge's numbering isn't relied on):
/// both shapes only ever start a tell line.
/// </summary>
public void OnChatLine(string? text)
{
if (string.IsNullOrEmpty(text) || text.IndexOf(" tell", StringComparison.Ordinal) < 0) return;
try
{
Match m = IncomingTell.Match(text);
if (m.Success) { Remember(ref _lastTeller, m.Groups[1].Value); return; }
m = OutgoingTell.Match(text);
if (m.Success) Remember(ref _lastTellee, m.Groups[1].Value);
}
catch (RegexMatchTimeoutException) { }
}
/// <summary>A tell we sent (the dispatcher's /tell): its target is the /retell target.</summary>
public void NoteTellSent(string? name) => Remember(ref _lastTellee, name);
public void Clear()
{
Volatile.Write(ref _lastTeller, null);
Volatile.Write(ref _lastTellee, null);
}
private static void Remember(ref string? field, string? name)
{
name = CleanName(name);
if (name != null) Volatile.Write(ref field, name);
}
/// <summary>The name trimmed, without an Olthoi player's '^'/'&amp;' suffix; null if nothing is left.</summary>
private static string? CleanName(string? name)
{
if (name == null) return null;
name = name.Trim().TrimEnd('^', '&').Trim();
return name.Length == 0 || name.Contains(',') ? null : name;
}
/// <summary>
/// "/r", "/reply", "/rt", "/retell" (or '@'), alone or followed by a space and the
/// message. <paramref name="message"/> is the trimmed rest ("" when there is none).
/// </summary>
public static TellShortcut Parse(string? line, out string message)
{
message = "";
if (string.IsNullOrEmpty(line)) return TellShortcut.None;
string t = line.Trim();
if (t.Length < 2 || (t[0] != '/' && t[0] != '@')) return TellShortcut.None;
int end = 1;
while (end < t.Length && !char.IsWhiteSpace(t[end])) end++;
TellShortcut kind = t[1..end].ToLowerInvariant() switch
{
"r" or "reply" => TellShortcut.Reply,
"rt" or "retell" => TellShortcut.Retell,
_ => TellShortcut.None,
};
if (kind != TellShortcut.None) message = t[end..].Trim();
return kind;
}
/// <summary>The name a shortcut addresses (null: no one yet).</summary>
public string? TargetFor(TellShortcut kind) => kind switch
{
TellShortcut.Reply => LastTeller,
TellShortcut.Retell => LastTellee,
_ => null,
};
/// <summary>
/// Rewrites a /reply or /retell line to "/tell Name, message". Returns false when the
/// line isn't one (both outs null). When it is one but can't be sent, returns true with
/// <paramref name="tellLine"/> null and <paramref name="error"/> saying why.
/// </summary>
public bool TryRewrite(string? line, out string? tellLine, out string? error)
{
tellLine = error = null;
TellShortcut kind = Parse(line, out string message);
if (kind == TellShortcut.None) return false;
string? name = TargetFor(kind);
if (name == null)
error = kind == TellShortcut.Reply ? NoTellerMessage : NoTelleeMessage;
else if (message.Length == 0)
error = $"Type a message after {(kind == TellShortcut.Reply ? "/r" : "/rt")} to send it to {name}.";
else
tellLine = $"/tell {name}, {message}";
return true;
}
}

View file

@ -10,6 +10,7 @@
// stores the owner at +0x2F4, builds the tooltip element into +0x2F8.
// ResetTooltip() 0x0045C440 frees +0x2F8, then tail-jumps into CheckTooltip.
// CheckTooltip() 0x0045B7C0 per-frame tooltip timer (+0x325, +0x2D4, +0x24C).
// Its `this` is also kept as Manager for AcMouseOver (AC's mouse-over, +0x244).
// StartDragandDrop(UIElement*, int x, int y) -> bool 0x0045E120, ret 0Ch
// on success the drag icon is at +0x31C and its owner at +0x320; it calls
// itself once for a drag proxy (we report only the outermost call).
@ -247,6 +248,13 @@ internal static unsafe class UiElementHooks
/// <summary>The object whose tooltip AC shows, or 0 (any thread; a plain field).</summary>
public static uint CurrentTooltipObject => _tooltipShown ? _tooltipObject : 0;
/// <summary>
/// AC's main thread: the UIElementManager singleton (`this` of the detours; CheckTooltip
/// runs every frame from UseTime), or zero before the first call and after Client::Cleanup.
/// AcMouseOver reads AC's mouse-over element through it.
/// </summary>
public static IntPtr Manager => _dead ? IntPtr.Zero : _mgr;
/// <summary>UiFlowHooks, leaving the world (main thread): forget tooltip/drag state; no events.</summary>
public static void OnScreenLeaving()
{
@ -300,6 +308,7 @@ internal static unsafe class UiElementHooks
private static void ResetTooltipDetour(IntPtr mgr)
{
((delegate* unmanaged[Thiscall]<IntPtr, void>)_origResetTooltip)(mgr);
if (!_dead && mgr != IntPtr.Zero) _mgr = mgr;
if (ResetTooltipSlot.Enabled)
AfterTooltipCheck(mgr, ResetTooltipSlot);
}
@ -308,6 +317,7 @@ internal static unsafe class UiElementHooks
private static void CheckTooltipDetour(IntPtr mgr)
{
((delegate* unmanaged[Thiscall]<IntPtr, void>)_origCheckTooltip)(mgr);
if (!_dead && mgr != IntPtr.Zero) _mgr = mgr; // the manager for AcMouseOver, every frame
if (CheckTooltipSlot.Enabled)
AfterTooltipCheck(mgr, CheckTooltipSlot);
}

View file

@ -690,7 +690,11 @@ internal static class EngineFrameController
// too (ImGuiTextFocus): the keys typed right after the click stay out of AC.
ImGuiTextFocus.EndMainFrame(io.WantTextInput);
bool typing = io.WantTextInput || ImGuiTextFocus.MainBoxActive;
Win32Backend.UpdateCaptureFlags(io.WantCaptureMouse || Hud.MonsterHud.WantsMouse, typing);
// A plate that is only hovered lets the mouse moves through, so AC's own
// mouse-over stays current (MonsterHud.MouseMovesToGame, Compatibility/AcMouseOver).
Win32Backend.UpdateCaptureFlags(io.WantCaptureMouse || Hud.MonsterHud.WantsMouse, typing,
mouseMovesToGame: !io.WantCaptureMouse && Hud.MonsterHud.MouseMovesToGame);
Compatibility.AcMouseOver.Tick(); // /rc acmouse watch, when on
// The UI is released (Insert): no text box keeps the keyboard. Keys are not
// gated by the toggle any more (Win32Backend.UpdateCaptureFlags), so the edit
// ends instead and the next keys go to the game.

View file

@ -18,7 +18,11 @@
// on a plate and no ImGui panel is under it, WantsMouse asks the game window
// to keep that click from AC (EngineFrameController ORs it into the capture
// flags), and the press selects the plate's monster through the main-thread
// overlay-select slot. Every other click still goes to the game.
// overlay-select slot. Every other click still goes to the game - including
// one on an AC window that covers a plate: a plate only counts where AC's own
// mouse-over is the 3D world (Compatibility/AcMouseOver), and while a plate
// is only hovered the mouse moves still reach AC (MouseMovesToGame) so that
// answer follows the cursor.
//
// Two rates:
// Update (AC's render thread, before the ImGui frame): at most 4x a second
@ -222,6 +226,13 @@ internal static class MonsterHud
/// </summary>
public static bool WantsMouse => _wantsMouse || PlayerPlate.WantsMouse;
/// <summary>
/// The plates want the mouse only because one is under the cursor (no press held, no
/// self-plate drag): mouse moves still go to AC then, so AC's own mouse-over (what
/// AcMouseOver reads) follows the cursor onto a window that covers the plate.
/// </summary>
public static bool MouseMovesToGame => _wantsMouse && _pressId == 0 && !PlayerPlate.WantsMouse;
/// <summary>Plates being tracked (diagnostics).</summary>
public static int PlateCount => Plates.Count;
@ -712,6 +723,7 @@ internal static class MonsterHud
public long Now;
public float UiScale;
public ImDrawListPtr Dl;
public bool UnderUi; // Dl is UnderUiLayer's (under AC's windows), not the background list
}
/// <summary>
@ -773,7 +785,8 @@ internal static class MonsterHud
// plates (UnderUiLayer). The background list (over AC's UI) only if the
// layer isn't available.
f.Dl = UnderUiLayer.BeginBuild(display);
if (!UnderUiLayer.IsBuilding) f.Dl = ImGuiNET.ImGui.GetBackgroundDrawList();
f.UnderUi = UnderUiLayer.IsBuilding;
if (!f.UnderUi) f.Dl = ImGuiNET.ImGui.GetBackgroundDrawList();
return true;
}
@ -933,7 +946,7 @@ internal static class MonsterHud
}
// ── Click-to-select: which plate is under the cursor, and a press on it ──
PlateClick(f.UiScale);
PlateClick(f.UiScale, f.UnderUi);
// ── Paint: farthest first, nearest (and the target) on top ──
for (int i = DrawOrder.Count - 1; i >= 0; i--)
@ -1103,8 +1116,12 @@ internal static class MonsterHud
/// (Win32Backend.MouseCaptured) were up, so AC never saw it. The press selects at
/// once (as a click in the 3D world does) and the capture stays until the button
/// is released, so the release never reaches AC either. One select per press.
/// Drawn under AC's windows (<paramref name="underUi"/>), a plate only counts where
/// AC itself has the 3D world under the cursor (AcMouseOver): where one of AC's
/// windows covers it (inventory, chat, radar, the selected-object bar...) the
/// click is AC's. AC's UI state unreadable: the plate counts, as before.
/// </summary>
private static void PlateClick(float uiScale)
private static void PlateClick(float uiScale, bool underUi)
{
uint prevHover = _hoverId; // the plate whose hover put the capture up for this frame's input
_hoverId = 0;
@ -1123,6 +1140,14 @@ internal static class MonsterHud
}
}
// A plate (or last frame's, for a press that slipped off it) under one of AC's windows:
// no capture, no select. Only asked when a plate could take the mouse (one read per frame).
if (usable && underUi && (_hoverId != 0 || (_pressId == 0 && prevHover != 0)) && AcWindowUnderCursor())
{
_hoverId = 0;
prevHover = 0;
}
if (_pressId == 0)
{
// The press went where last frame's hover sent it: if the cursor slipped off
@ -1144,6 +1169,22 @@ internal static class MonsterHud
_wantsMouse = _hoverId != 0 || _pressId != 0;
}
private static int _leftToAcLogged;
/// <summary>AC's own UI has one of its windows under the cursor (not the 3D world). AC's main thread.</summary>
private static bool AcWindowUnderCursor()
{
AcMouseOver.Sample s = AcMouseOver.Read();
if (AcMouseOverRules.UnderUiOverlayMayTakeClick(s.Target))
return false;
if (_leftToAcLogged < 3)
{
_leftToAcLogged++;
RynthLog.UI($"MonsterHud: a plate is under AC's UI element 0x{s.ElementId:X8} (type 0x{s.Type:X8}) - its click stays with AC.");
}
return true;
}
/// <summary>Text width at <paramref name="size"/> px. No font push: this runs outside any window.</summary>
internal static float TextWidth(ImFontPtr font, float size, string text) =>
font.CalcTextSizeA(size, float.MaxValue, 0f, text).X;
@ -1581,6 +1622,7 @@ internal static class MonsterHud
$"weakness data {(_weakByWcid.Count + _weakByName.Count > 0 ? "loaded" : "none")}.",
PlateDebuffs.Describe(),
PlayerPlate.Describe() + " " + CombatText.Describe(),
AcMouseOver.Describe(),
};
}
}

View file

@ -20,7 +20,9 @@
//
// The input line belongs to ChatModel (UI/Data/ChatData.cs): Win32Backend
// turns the chat keys into ChatModel edits on AC's thread, which is also
// this face's thread. Clicking the box starts typing, like Enter.
// this face's thread. Clicking the box starts typing, like Enter. While
// typing, Ctrl+V pastes and Ctrl+C / Ctrl+X copy / cut the whole line;
// /r and /rt reply and retell (TellMemory).
//
// The panel has no strip under the body for the resize grip (PanelSpec.
// GripInBody): the input row stops short of the bottom-right corner by
@ -639,7 +641,7 @@ internal sealed class ChatFace : IImGuiPanel
ImGuiNET.ImGui.SetCursorScreenPos(p);
if (ImGuiNET.ImGui.InvisibleButton("##chat_input", new Vector2(boxW, h)))
ChatModel.BeginTyping();
if (!typing && ChatHooks.RynthChatOwnsChat) ImGuiNET.ImGui.SetItemTooltip("Click or press Enter to chat");
if (!typing && ChatHooks.RynthChatOwnsChat) ImGuiNET.ImGui.SetItemTooltip("Click or press Enter to chat (Ctrl+V pastes; /r replies, /rt retells)");
dl.AddRectFilled(p, p + new Vector2(boxW, h), InputBg, 3);
dl.AddRect(p, p + new Vector2(boxW, h), typing ? InputActive : InputBorder, 3);

View file

@ -7,6 +7,9 @@
//
// item its name and the profile the rule goes to
// match name + class (default), name only, items like this
// T11 "Include T11 attributes": also require the item's T11 tier,
// grade, damage %, modifiers, slot special and Cast on Strike,
// each at least this item's (any match; 2026-10-07)
// action Keep, Keep # (with the count), Salvage, Sell, Read
// name the rule's name (empty: RynthAi's default, "Keep Copper Pea")
// preview the rule in words, where it goes in the list and why, notes
@ -48,6 +51,7 @@ internal sealed class LootAddDialog
// What the popup asks for (0 / -1 = RynthAi's default).
private int _match, _action, _keep = -1;
private bool _includeT11;
private readonly byte[] _name = new byte[128];
private int _keepEdit = 1;
@ -88,6 +92,7 @@ internal sealed class LootAddDialog
_match = 0;
_action = 0;
_keep = -1;
_includeT11 = false;
Array.Clear(_name);
_draft = null;
_adding = false;
@ -113,7 +118,7 @@ internal sealed class LootAddDialog
Item = new LootEditItemRequestDto
{
ItemId = _itemId, Match = _match, Action = _action, KeepCount = _keep,
RuleName = Utf8(_name).Trim(), ToOpenProfile = _toOpenProfile, Seq = _seq,
RuleName = Utf8(_name).Trim(), ToOpenProfile = _toOpenProfile, IncludeT11 = _includeT11, Seq = _seq,
},
});
}
@ -255,6 +260,24 @@ internal sealed class LootAddDialog
if (ImGuiNET.ImGui.IsItemHovered()) ImGuiNET.ImGui.SetTooltip(MatchTips[i]);
}
// T11 attributes. Shown for every item: a non-T11 item answers with a note saying so.
bool t11 = _includeT11;
if (ImGuiNET.ImGui.Checkbox("Include T11 attributes##la_t11", ref t11))
{
_includeT11 = t11;
changed = true;
}
if (ImGuiNET.ImGui.IsItemHovered())
ImGuiNET.ImGui.SetTooltip(
"Also require this item's T11 tier, weapon grade, damage %, every modifier, slot special\n" +
"and Cast on Strike, each at least as good as this one. Works with any match.\n" +
"Not added: Can Wield (depends on your character) and Zone Locked (depends on where it was assessed).");
if (!d.IsT11)
{
ImGuiNET.ImGui.SameLine();
ImGuiNET.ImGui.TextDisabled("(not a T11 item)");
}
// Action.
ImGuiNET.ImGui.TextDisabled("Action:");
for (int i = 0; i < ActionIds.Length; i++)

View file

@ -554,19 +554,45 @@ internal sealed partial class RynthAiFace : IImGuiPanel
// ── Footer: FPS | version | uptime ─────────────────────────────────────
private static string Clock(TimeSpan t) =>
t.TotalHours >= 1 ? $"{(int)t.TotalHours}:{t.Minutes:D2}:{t.Seconds:D2}" : $"{t.Minutes}:{t.Seconds:D2}";
private static DateTime _clientStartedUtc = DateTime.MinValue;
private static bool _clientStartRead;
/// <summary>When acclient.exe started (read once; MinValue if Windows won't say).</summary>
private static DateTime ClientStartedUtc()
{
if (_clientStartRead) return _clientStartedUtc;
_clientStartRead = true;
try
{
using var p = System.Diagnostics.Process.GetCurrentProcess();
_clientStartedUtc = p.StartTime.ToUniversalTime();
}
catch { _clientStartedUtc = DateTime.MinValue; }
return _clientStartedUtc;
}
private void Footer(RynthAiView? view, float x0, float width)
{
int fps = (int)MathF.Round(D3D9.EndSceneHook.MeasuredFps);
if (fps != _fpsShown) { _fpsShown = fps; _fpsText = fps > 0 ? $"FPS {fps}" : "FPS —"; }
// Bot: since this engine loaded (a hot reload restarts it). Client: since the game client
// started (2026-10-08), which a reload doesn't touch.
DateTime started = EntryPoint.InitStartedUtc;
if (started != DateTime.MinValue)
{
TimeSpan up = DateTime.UtcNow - started;
DateTime now = DateTime.UtcNow;
TimeSpan up = now - started;
long secs = (long)up.TotalSeconds;
if (secs != _upShown)
{
_upShown = secs;
_upText = up.TotalHours >= 1 ? $"Up {(int)up.TotalHours}:{up.Minutes:D2}:{up.Seconds:D2}" : $"Up {up.Minutes}:{up.Seconds:D2}";
DateTime client = ClientStartedUtc();
_upText = client != DateTime.MinValue
? $"Bot {Clock(up)} Client {Clock(now - client)}"
: $"Up {Clock(up)}";
}
}
var dl = ImGuiNET.ImGui.GetWindowDrawList();

View file

@ -403,6 +403,10 @@ internal static unsafe class Win32Backend
private static readonly Queue<QueuedInputMessage> _pendingInput = new();
private static volatile bool _wantCaptureMouse;
private static volatile bool _wantCaptureKeyboard;
/// <summary>The mouse capture is only a nameplate under the cursor (MonsterHud.MouseMovesToGame):
/// WM_MOUSEMOVE still reaches AC, so AC's own mouse-over follows the cursor (Compatibility/AcMouseOver).
/// Means nothing while _wantCaptureMouse is false.</summary>
private static volatile bool _mouseMovesToGame;
/// <summary>
/// True while the game window eats mouse input for the ImGui layer: the capture
@ -479,6 +483,12 @@ internal static unsafe class Win32Backend
public static Action? OnChatUp;
/// <summary>Fired on VK_DOWN while capture is active (history next).</summary>
public static Action? OnChatDown;
/// <summary>Fired on Ctrl+V / Shift+Insert while capture is active.</summary>
public static Action? OnChatPaste;
/// <summary>Fired on Ctrl+C / Ctrl+Insert while capture is active.</summary>
public static Action? OnChatCopy;
/// <summary>Fired on Ctrl+X while capture is active.</summary>
public static Action? OnChatCut;
private static int _lastPanelClientX; // last game-client pos over the panel (for wheel)
private static int _lastPanelClientY;
@ -684,8 +694,9 @@ internal static unsafe class Win32Backend
bool insertDown = (GetAsyncKeyState(VK_INSERT) & 0x8000) != 0;
// GetAsyncKeyState reads the physical key whatever window has focus: without
// the focus test, Insert (or Shift/Ctrl+Insert paste/copy) pressed in another
// client or app flipped this client's capture off unseen.
if (insertDown && !_insertWasDown && _hasFocus)
// client or app flipped this client's capture off unseen. Not while typing in
// RynthChat: there Shift/Ctrl+Insert are paste/copy.
if (insertDown && !_insertWasDown && _hasFocus && !ChatCaptureActive)
{
_uiCaptureEnabled = !_uiCaptureEnabled;
RynthLog.Render($"Win32Backend: ImGui capture {(_uiCaptureEnabled ? "ENABLED" : "DISABLED")} (Insert)");
@ -868,7 +879,13 @@ internal static unsafe class Win32Backend
else if (msg == WM_KEYDOWN)
{
int vk = (int)wParam;
if (vk == VK_RETURN && !IsExtendedKey(lParam)) { ChatCaptureActive = false; _swallowEnterTail = true; PostMessage(_gameHwnd, WM_RYNTHCORE_CHAT, IntPtr.Zero, IntPtr.Zero); }
// Clipboard keys. Their WM_CHARs (Ctrl+V is 0x16, Ctrl+C 0x03) are
// control characters the branch above drops, so paste did nothing.
bool ctrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0, shift = (GetKeyState(VK_SHIFT) & 0x8000) != 0;
if ((ctrl && vk == 'V') || (shift && !ctrl && vk == VK_INSERT)) { OnChatPaste?.Invoke(); }
else if (ctrl && (vk == 'C' || vk == VK_INSERT)) { OnChatCopy?.Invoke(); }
else if (ctrl && vk == 'X') { OnChatCut?.Invoke(); }
else if (vk == VK_RETURN && !IsExtendedKey(lParam)) { ChatCaptureActive = false; _swallowEnterTail = true; PostMessage(_gameHwnd, WM_RYNTHCORE_CHAT, IntPtr.Zero, IntPtr.Zero); }
else if (vk == VK_ESCAPE) { ChatCaptureActive = false; _swallowEnterTail = true; OnChatCancel?.Invoke(); }
else if (vk == VK_BACK) { OnChatBackspace?.Invoke(); }
else if (vk == VK_DELETE) { OnChatDelete?.Invoke(); }
@ -1038,7 +1055,9 @@ internal static unsafe class Win32Backend
// ImGui wants the mouse (io.WantCaptureMouse): eat it, unless the held
// buttons were pressed for the game (see _heldButtonsBelongToGame).
if (_wantCaptureMouse && IsMouseMessage(msg) && !_heldButtonsBelongToGame)
// A nameplate that is only hovered keeps the clicks but not the moves.
if (_wantCaptureMouse && IsMouseMessage(msg) && !_heldButtonsBelongToGame
&& !(msg == WM_MOUSEMOVE && _mouseMovesToGame))
return IntPtr.Zero;
// An ImGui text box is being typed in (io.WantTextInput): keep keys from
@ -1523,10 +1542,14 @@ internal static unsafe class Win32Backend
/// box left open with the gate shut typed into the box AND the game. A key that
/// reaches the game WndProc means AC has keyboard focus anyway; Insert-off ends
/// the text edit instead (EngineFrameController), so keys go back to the game.
///
/// <paramref name="mouseMovesToGame"/>: the mouse is wanted only by a nameplate under
/// the cursor (no ImGui window, no press held); its clicks are eaten, its moves are not.
/// </summary>
public static void UpdateCaptureFlags(bool wantMouse, bool wantTextInput)
public static void UpdateCaptureFlags(bool wantMouse, bool wantTextInput, bool mouseMovesToGame = false)
{
bool live = _uiCaptureEnabled && _hasFocus;
_mouseMovesToGame = mouseMovesToGame;
_wantCaptureMouse = live && wantMouse;
_wantCaptureKeyboard = wantTextInput;
ImGuiTextInputActive = wantTextInput;

View file

@ -647,6 +647,8 @@ internal static partial class PluginManager
{
// RynthVision overlays (debuffs, combat text, gains) read chat engine-side, plugins or not.
ImGuiBackend.Hud.HudFeed.OnChat(text);
// Who to /reply and /retell to (ChatCommandDispatcher rewrites those to a /tell).
Compatibility.TellMemory.Shared.OnChatLine(text);
if (!_initialized || _plugins.Count == 0)
return false;

View file

@ -1300,6 +1300,27 @@ internal static class ChatModel
else { _historyIndex = -1; text = ""; }
SetInput(text, text.Length, null);
};
// The line has no selection: copy and cut take all of it, paste goes in at the caret.
Win32Backend.OnChatPaste = () =>
{
InputState s = _input;
string text = ChatInputPaste.Insert(s.Text, s.Cursor, GetClipboardText(), out int cursor);
if (ReferenceEquals(text, s.Text)) return;
_historyIndex = -1;
SetInput(text, cursor, null);
};
Win32Backend.OnChatCopy = () =>
{
string text = _input.Text;
if (text.Length > 0) SetClipboardText(text);
};
Win32Backend.OnChatCut = () =>
{
string text = _input.Text;
if (text.Length == 0 || !SetClipboardText(text)) return;
_historyIndex = -1;
SetInput("", 0, null);
};
Win32Backend.OnChatSend = OnSend;
Win32Backend.OnChatCancel = () =>
{
@ -1326,11 +1347,24 @@ internal static class ChatModel
SetInput("", 0, "Select an NPC or player in the game first, then Tell.");
return false;
}
BeginTellTo(name);
return true;
}
/// <summary>Starts "/tell &lt;name&gt;, " and keeps typing. AC's main thread.</summary>
private static void BeginTellTo(string name)
{
string text = $"/tell {name}, ";
_historyIndex = -1;
Win32Backend.ChatCaptureActive = true; // keys now go to this line
SetInput(text, text.Length, null);
return true;
}
private static void AddHistory(string text)
{
if (text.Length == 0 || (History.Count > 0 && History[^1] == text)) return;
History.Add(text);
if (History.Count > 100) History.RemoveAt(0);
}
// Win32Backend has already cleared ChatCaptureActive. RynthChatSendLine runs
@ -1346,11 +1380,26 @@ internal static class ChatModel
return;
}
_historyIndex = -1;
if (text.Length > 0 && (History.Count == 0 || History[^1] != text))
// /reply and /retell (TellMemory.cs; the dispatcher turns them into a /tell). Alone they
// start "/tell <name>, " the way "/tell" alone does; with no one to address, the box
// says so and the line stays in history (Up brings it back).
TellShortcut shortcut = TellMemory.Parse(text, out string tellMessage);
if (shortcut != TellShortcut.None)
{
History.Add(text);
if (History.Count > 100) History.RemoveAt(0);
string? name = TellMemory.Shared.TargetFor(shortcut);
if (name == null)
{
AddHistory(text);
SetInput("", 0, shortcut == TellShortcut.Reply ? TellMemory.NoTellerMessage : TellMemory.NoTelleeMessage);
return;
}
if (tellMessage.Length == 0)
{
BeginTellTo(name);
return;
}
}
AddHistory(text);
SetInput("", 0, null);
IntPtr send = SendLinePtr;
if (text.Length == 0 || send == IntPtr.Zero) return;

View file

@ -0,0 +1,50 @@
// ============================================================================
// RynthCore.Engine - UI/Data/ChatInputPaste.cs
// Ctrl+V into RynthChat's input line: clipboard text made into one chat line.
// Pure (tools\ChatTellTests compiles it in).
// ============================================================================
using System;
using System.Text;
namespace RynthCore.Engine.UI.Data;
internal static class ChatInputPaste
{
/// <summary>The input line never grows past this by pasting (a stray paste of a whole document).</summary>
public const int MaxLineChars = 1000;
/// <summary>
/// <paramref name="clip"/> as one line: each line break or tab becomes a space (a run of
/// them one space), other control characters are dropped, leading/trailing breaks go.
/// </summary>
public static string Clean(string? clip)
{
if (string.IsNullOrEmpty(clip)) return "";
var sb = new StringBuilder(clip.Length);
bool pendingSpace = false;
foreach (char c in clip)
{
if (c is '\r' or '\n' or '\t') { pendingSpace = sb.Length > 0; continue; }
if (c < 0x20 || c == 0x7F) continue;
if (pendingSpace) { if (c != ' ' && sb[^1] != ' ') sb.Append(' '); pendingSpace = false; }
sb.Append(c);
}
return sb.ToString();
}
/// <summary>The line with the clipboard text inserted at the cursor (cut to fit <see cref="MaxLineChars"/>).</summary>
public static string Insert(string text, int cursor, string? clip, out int newCursor)
{
cursor = Math.Clamp(cursor, 0, text.Length);
string add = Clean(clip);
int room = Math.Max(0, MaxLineChars - text.Length);
if (add.Length > room)
{
add = add[..room];
if (add.Length > 0 && char.IsHighSurrogate(add[^1])) add = add[..^1]; // never split a pair
}
newCursor = cursor + add.Length;
return add.Length == 0 ? text : text[..cursor] + add + text[cursor..];
}
}

View file

@ -684,7 +684,7 @@ internal static unsafe class DamageCommands
ExVuln = s.ExVuln, PetDamage = "PAuto",
Fester = s.Fester, Broadside = s.Broadside, GravityWell = s.GravityWell,
Imperil = s.Imperil, Yield = s.Yield, Vuln = s.Vuln,
UseArc = s.UseArc, UseBolt = s.UseBolt, UseRing = s.UseRing, UseStreak = s.UseStreak, UseBlast = s.UseBlast,
UseArc = s.UseArc, UseBolt = s.UseBolt, UseRing = s.UseRing, UseStreak = s.UseStreak, UseBlast = s.UseBlast, UseWall = s.UseWall,
CustomDebuffs = s.CustomDebuffs,
};
@ -765,6 +765,9 @@ internal static unsafe class DamageCommands
("UseBlast", "Blast", "Blast spells (Flame Blast, Frost Blast...): a spread of projectiles, from level III.\n" +
"Used instead of Bolt when both are on (Arc and Streak come first). A character who knows\n" +
"no blast of the element casts its Bolt."),
("UseWall", "Wall", "Wall spells (Slithering Flames, Os' Wall...): a line of projectiles straight ahead.\n" +
"Cast only when Wall Range is on and Min Wall Targets monsters stand in the wall's path to\n" +
"the target; RynthAi turns to face the target first. Otherwise the monster's other shape, or a bolt."),
};
public static readonly string[] ExVulnTypes =
@ -786,13 +789,13 @@ internal static unsafe class DamageCommands
{
bool on = !rule.GetToggle(field);
rule.SetToggle(field, on);
bool shape = field is "UseArc" or "UseBolt" or "UseRing" or "UseStreak" or "UseBlast";
bool shape = field is "UseArc" or "UseBolt" or "UseRing" or "UseStreak" or "UseBlast" or "UseWall";
if (shape && !on && !HasAnyShape(rule))
rule.UseBolt = true;
}
/// <summary>At least one spell shape is on (RynthAi refuses to attack with magic otherwise).</summary>
public static bool HasAnyShape(MonstersPanel.Rule r) => r.UseArc || r.UseBolt || r.UseRing || r.UseStreak || r.UseBlast;
public static bool HasAnyShape(MonstersPanel.Rule r) => r.UseArc || r.UseBolt || r.UseRing || r.UseStreak || r.UseBlast || r.UseWall;
/// <summary>The shape RynthAi casts when no ring is due (RynthAi CombatManager.PickBaseShape): Arc, Streak, Blast, then Bolt.</summary>
public static string BaseShapeName(MonstersPanel.Rule r)
@ -800,7 +803,7 @@ internal static unsafe class DamageCommands
if (r.UseArc) return "Arc";
if (r.UseStreak) return "Streak";
if (r.UseBlast) return "Blast";
if (r.UseBolt || r.UseRing) return "Bolt";
if (r.UseBolt || r.UseRing || r.UseWall) return "Bolt";
return "";
}
}

View file

@ -139,6 +139,8 @@ internal sealed class LootEditItemRequestDto
public string RuleName { get; set; } = string.Empty;
/// <summary>True: the profile open in the Loot Editor; false: the one RynthAi loots with.</summary>
public bool ToOpenProfile { get; set; }
/// <summary>Also require the item's T11 attributes (added 2026-10-07; an older RynthAi ignores it).</summary>
public bool IncludeT11 { get; set; }
public int Seq { get; set; }
}
@ -157,6 +159,10 @@ internal sealed class LootEditItemDraftDto
public bool TargetInUse { get; set; }
public string Format { get; set; } = string.Empty;
public int Match { get; set; }
/// <summary>The rule includes the item's T11 attributes (added 2026-10-07; false from an older RynthAi).</summary>
public bool IncludeT11 { get; set; }
/// <summary>The item is T11 gear (added 2026-10-07; false from an older RynthAi).</summary>
public bool IsT11 { get; set; }
public int Action { get; set; }
public int KeepCount { get; set; }
public string RuleName { get; set; } = string.Empty;

View file

@ -13,6 +13,7 @@ using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text.Json;
using RynthCore.Engine.ImGuiBackend.Hud;
using System.Text.Json.Serialization;
namespace RynthCore.Engine.UI.Data;
@ -122,12 +123,41 @@ internal static class NavCommands
5175, 5330, 5541, 6150, 6321, 6322,
};
public static readonly string[] RecallLabels = BuildRecallLabels();
private static string[] BuildRecallLabels()
/// <summary>
/// "Lifestone Recall (1635)": the recall spells by name (2026-10-08: they showed as
/// "Spell 1635 (1635)"). The names come from the client's spell table, which loads in the
/// background, so the list is rebuilt until every name is known.
/// </summary>
public static string[] RecallLabels
{
get
{
if (_recallLabels == null || !_recallLabelsNamed)
{
PortalSpellTable.EnsureLoadQueued();
_recallLabels = BuildRecallLabels(out _recallLabelsNamed);
}
return _recallLabels;
}
}
private static string[]? _recallLabels;
private static bool _recallLabelsNamed;
private static string[] BuildRecallLabels(out bool allNamed)
{
allNamed = true;
var labels = new string[RecallIds.Length];
for (int i = 0; i < labels.Length; i++) labels[i] = $"Spell {RecallIds[i]} ({RecallIds[i]})";
for (int i = 0; i < labels.Length; i++)
{
if (PortalSpellTable.TryGetName((uint)RecallIds[i], out string name) && name.Length > 0)
labels[i] = $"{name} ({RecallIds[i]})";
else
{
labels[i] = $"Spell {RecallIds[i]} ({RecallIds[i]})";
allNamed = false;
}
}
return labels;
}

View file

@ -41,6 +41,9 @@ internal sealed class RynthAiSettings
public bool PeaceModeWhenIdle { get; set; }
public bool StartMacroOnLogin { get; set; }
public bool PatrolOnLogin { get; set; }
// RynthAi's Escape Acid and Lava. Default on; an older RynthAi doesn't send it, and a missing
// field must not read as "off".
public bool EscapeHazards { get; set; } = true;
// Decal bridge: stop RynthAi's macro when VTank's starts (one bot per client). Default on;
// an older RynthAi doesn't send it, and a missing field must not read as "off".
public bool YieldToVTank { get; set; } = true;
@ -112,6 +115,10 @@ internal sealed class RynthAiSettings
public int MinRingTargets { get; set; } = 4;
public int BlastRange { get; set; }
public int MinBlastTargets { get; set; } = 3;
// RynthAi's wall override (2026-10-08). Nullable in RynthAi's payload: an engine without these
// rows leaves its values alone.
public int WallRange { get; set; }
public int MinWallTargets { get; set; } = 3;
public int MinSkillLevelTier1 { get; set; } = 35;
public int MinSkillLevelTier2 { get; set; } = 85;
public int MinSkillLevelTier3 { get; set; } = 135;
@ -476,6 +483,8 @@ internal static class SettingsSchema
"Automatically starts the macro when RynthAi loads."),
Bool("Patrol On Login", s => s.PatrolOnLogin, (s, v) => s.PatrolOnLogin = v,
"Automatically starts dungeon patrol when RynthAi loads."),
Bool("Escape Acid and Lava", s => s.EscapeHazards, (s, v) => s.EscapeHazards = v,
"When acid or lava hurts you, stop everything (combat, buffs, healing, looting)\nand walk back out the way you came. The spot is remembered so the patrol avoids it.\nTurn off for a character that walks through acid on purpose."),
Bool("Yield to VTank", s => s.YieldToVTank, (s, v) => s.YieldToVTank = v,
"With Decal: when VTank's macro starts (/vt start), RynthAi's macro stops, and it won't start while VTank runs.\nOne bot per client. Without Decal this does nothing. Also: /ra vtankyield on|off."),
Bool("Enable Raycasting", s => s.EnableRaycasting, (s, v) => s.EnableRaycasting = v),
@ -589,8 +598,8 @@ internal static class SettingsSchema
Section("War/Void Casting Settings"),
Int("Buff Spell Interval (ms)", s => s.SpellCastIntervalMs, (s, v) => s.SpellCastIntervalMs = v, 100, 1500, 50,
"Delay between BUFF / utility spell casts (not combat).\nLower = faster buff chains. 400ms is a good balance.\nBelow 200ms may cause fizzles or dropped casts on laggy servers."),
Int("Attack Spell Delay (ms)", s => s.AttackSpellIntervalMs, (s, v) => s.AttackSpellIntervalMs = v, 250, 5000, 50,
"Delay between offensive (war/void) COMBAT casts only.\nSpacing casts ~1-2s (1500ms default) stops back-to-back\n\"You're too busy!\" refusals that drop casts and cost kills.\nDoes NOT affect buffing speed."),
Int("Attack Spell Delay (ms)", s => s.AttackSpellIntervalMs, (s, v) => s.AttackSpellIntervalMs = v, 0, 5000, 50,
"Least time between offensive (war/void) COMBAT casts at one target.\nThe next cast also waits until the last one is finished (the server's\nanswer and the casting animation), so 0 = cast again as soon as it is.\nDoes NOT affect buffing speed."),
Bool("Cast Dispel Self", s => s.CastDispelSelf, (s, v) => s.CastDispelSelf = v),
Spacer(),
Section("Ring Spell Override"),
@ -603,6 +612,12 @@ internal static class SettingsSchema
Int("Min Blast Targets", s => s.MinBlastTargets, (s, v) => s.MinBlastTargets = v, 1, 20, 1,
"How many monsters (the target included) must be in the blast's fan, within Blast Range."),
Spacer(),
Section("Wall Spell Override"),
Int("Wall Range (yd)", s => s.WallRange, (s, v) => s.WallRange = v, 0, 100, 1,
"0 = off: walls are never cast.\nAbove 0: monsters with Wall on cast a wall when Min Wall Targets monsters stand in its\npath toward the target, within this range. RynthAi turns to face the target first\n(a wall flies straight ahead of the caster)."),
Int("Min Wall Targets", s => s.MinWallTargets, (s, v) => s.MinWallTargets = v, 1, 20, 1,
"How many monsters (the target included) must be in the wall's path, within Wall Range."),
Spacer(),
Section("Spell Difficulty (Min Buffed Skill)"),
Tiers(
new Func<RynthAiSettings, int>[] { s => s.MinSkillLevelTier1, s => s.MinSkillLevelTier2, s => s.MinSkillLevelTier3, s => s.MinSkillLevelTier4,

View file

@ -120,6 +120,8 @@ internal static class MonstersPanel
public bool UseBolt { get; set; } = true;
/// <summary>Blast spells (a spread of projectiles). Off in rules saved before 2026-10-03.</summary>
public bool UseBlast { get; set; }
/// <summary>Wall spells (RynthAi faces the target, then casts). Off in rules saved before 2026-10-08.</summary>
public bool UseWall { get; set; }
public string ExVuln { get; set; } = "None";
public int OffhandId { get; set; }
public string PetDamage { get; set; } = "PAuto";
@ -139,6 +141,7 @@ internal static class MonstersPanel
"UseRing" => UseRing,
"UseStreak" => UseStreak,
"UseBlast" => UseBlast,
"UseWall" => UseWall,
_ => false,
};
@ -157,6 +160,7 @@ internal static class MonstersPanel
case "UseRing": UseRing = v; break;
case "UseStreak": UseStreak = v; break;
case "UseBlast": UseBlast = v; break;
case "UseWall": UseWall = v; break;
}
}
}
@ -1017,7 +1021,7 @@ internal static class MonstersPanel
|| x.Fester != y.Fester || x.Broadside != y.Broadside || x.GravityWell != y.GravityWell
|| x.Imperil != y.Imperil || x.Yield != y.Yield || x.Vuln != y.Vuln
|| x.UseArc != y.UseArc || x.UseBolt != y.UseBolt
|| x.UseRing != y.UseRing || x.UseStreak != y.UseStreak || x.UseBlast != y.UseBlast
|| x.UseRing != y.UseRing || x.UseStreak != y.UseStreak || x.UseBlast != y.UseBlast || x.UseWall != y.UseWall
|| (x.CustomDebuffs ?? "") != (y.CustomDebuffs ?? ""))
return false;
}

View file

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Offline checks for src\RynthCore.Engine\Compatibility\AcMouseOverRules.cs (2026-10-08):
a nameplate drawn under AC's windows may take a click only where AC's own mouse-over is
the 3D world (the SmartBox wrapper, type 0x10000030) - never on one of AC's windows - and
keeps today's behaviour (takes it) whenever AC's UI state can't be read.
The AC-side facts (offsets, the type id) are checked against acclient.exe by
tools\ui_hooks_check.py.
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
-->
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<RootNamespace>AcMouseOverTests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\AcMouseOverRules.cs" Link="Engine\AcMouseOverRules.cs" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,93 @@
using RynthCore.Engine.Compatibility;
namespace AcMouseOverTests;
/// <summary>
/// AcMouseOverRules: what AC's UI manager says is under the mouse, and whether a nameplate
/// drawn under AC's windows may take the click there.
/// </summary>
internal static class Program
{
private const uint SomeElement = 0x1A2B3C40;
private const int SmartBox = AcMouseOverRules.UIElementTypeSmartBoxWrapper;
private const int ItemList = 0x10000031; // the inventory's item lists (UiElementHooks)
private static int _checks, _failed;
private static string _case = "";
private static int Main()
{
TheTypeId();
WorldTakesTheClick();
AcWindowsKeepTheClick();
FailOpen();
NothingUnderTheMouse();
Console.WriteLine();
Console.WriteLine($"{_checks - _failed}/{_checks} checks passed.");
Console.WriteLine(_failed == 0 ? "ALL AC MOUSE-OVER TESTS PASSED." : $"{_failed} FAILED.");
return _failed == 0 ? 0 : 1;
}
private static void TheTypeId()
{
Case("the 3D view's type is UIElement_SmartBoxWrapper's (GetUIElementType 0x004E5E80)");
Check(SmartBox == 0x10000030, "0x10000030");
}
private static void WorldTakesTheClick()
{
Case("cursor on the 3D world: the plate takes the click");
AcMouseTarget t = AcMouseOverRules.Classify(true, false, SomeElement, true, SmartBox);
Check(t == AcMouseTarget.World, $"SmartBox wrapper under the mouse = World (got {t})");
Check(AcMouseOverRules.UnderUiOverlayMayTakeClick(t), "may take the click");
}
private static void AcWindowsKeepTheClick()
{
Case("cursor on one of AC's windows: the click stays with AC");
foreach (int type in new[] { ItemList, 0x10000001, 0x10000032, 0, -1, SmartBox + 1 })
{
AcMouseTarget t = AcMouseOverRules.Classify(true, false, SomeElement, true, type);
Check(t == AcMouseTarget.AcWindow, $"type 0x{type:X8} = AcWindow (got {t})");
Check(!AcMouseOverRules.UnderUiOverlayMayTakeClick(t), $"type 0x{type:X8}: plate may not take the click");
}
}
private static void FailOpen()
{
Case("AC's UI state unreadable: today's behaviour (the plate takes the click)");
AcMouseTarget noMgr = AcMouseOverRules.Classify(false, false, SomeElement, true, ItemList);
Check(noMgr == AcMouseTarget.Unknown, $"no manager / unreadable = Unknown (got {noMgr})");
Check(AcMouseOverRules.UnderUiOverlayMayTakeClick(noMgr), "unknown manager: may take the click");
AcMouseTarget noType = AcMouseOverRules.Classify(true, false, SomeElement, false, 0);
Check(noType == AcMouseTarget.Unknown, $"element type unreadable = Unknown (got {noType})");
Check(AcMouseOverRules.UnderUiOverlayMayTakeClick(noType), "unknown type: may take the click");
Check(AcMouseOverRules.UnderUiOverlayMayTakeClick(AcMouseTarget.Unknown), "Unknown: may take the click");
}
private static void NothingUnderTheMouse()
{
Case("AC reports nothing (cursor left the client, or no element took the mouse)");
AcMouseTarget outside = AcMouseOverRules.Classify(true, true, SomeElement, true, ItemList);
Check(outside == AcMouseTarget.Nothing, $"+0x2D4 set = Nothing, whatever +0x244 still holds (got {outside})");
AcMouseTarget none = AcMouseOverRules.Classify(true, false, 0, false, 0);
Check(none == AcMouseTarget.Nothing, $"+0x244 zero = Nothing (got {none})");
Check(AcMouseOverRules.UnderUiOverlayMayTakeClick(outside) && AcMouseOverRules.UnderUiOverlayMayTakeClick(none),
"Nothing: may take the click");
}
private static void Case(string name)
{
_case = name;
Console.WriteLine($"-- {name}");
}
private static void Check(bool ok, string what)
{
_checks++;
if (ok) return;
_failed++;
Console.WriteLine($" FAIL [{_case}] {what}");
}
}

View file

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Offline checks for RynthChat's /reply + /retell and paste (compiled in):
src\RynthCore.Engine\Compatibility\TellMemory.cs - who to reply / retell to, read off the
chat lines, and the rewrite of "/r text" into "/tell Name, text";
src\RynthCore.Engine\UI\Data\ChatInputPaste.cs - clipboard text made into one input line.
Nothing native: no AC, no engine state.
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
-->
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<RootNamespace>ChatTellTests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\TellMemory.cs" Link="Engine\TellMemory.cs" />
<Compile Include="..\..\src\RynthCore.Engine\UI\Data\ChatInputPaste.cs" Link="Engine\ChatInputPaste.cs" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,184 @@
using RynthCore.Engine.Compatibility;
using RynthCore.Engine.UI.Data;
namespace ChatTellTests;
/// <summary>
/// RynthChat's /reply, /retell (TellMemory.cs) and Ctrl+V (ChatInputPaste.cs) without AC.
/// Chat lines are written the way AC prints them (HearDirectSpeech's player link, ACE's
/// "You tell" echo).
/// </summary>
internal static class Program
{
private static int _checks, _failed;
private static string _case = "";
private const string BobTells = "<Tell:IIDString:1342177281:Bob>Bob<\\Tell> tells you, \"hi there\"";
private static int Main()
{
ParseShortcuts();
IncomingTellSetsReplyTarget();
NpcAndOtherLinesIgnored();
OutgoingTellSetsRetellTarget();
RewriteCases();
PasteClean();
PasteInsert();
Console.WriteLine();
Console.WriteLine($"{_checks - _failed}/{_checks} checks passed.");
Console.WriteLine(_failed == 0 ? "ALL CHAT TELL TESTS PASSED." : $"{_failed} FAILED.");
return _failed == 0 ? 0 : 1;
}
// ── shortcuts ───────────────────────────────────────────────────────────
private static void ParseShortcuts()
{
Case("parse: /r /reply /rt /retell");
Check(TellMemory.Parse("/r hello", out string m) == TellShortcut.Reply && m == "hello", "/r hello");
Check(TellMemory.Parse("/reply hello there ", out m) == TellShortcut.Reply && m == "hello there", "/reply, trimmed");
Check(TellMemory.Parse("/R Hi", out m) == TellShortcut.Reply && m == "Hi", "case-insensitive, message case kept");
Check(TellMemory.Parse("@r hi", out m) == TellShortcut.Reply && m == "hi", "@ prefix, as AC accepts");
Check(TellMemory.Parse("/rt again", out m) == TellShortcut.Retell && m == "again", "/rt");
Check(TellMemory.Parse("/retell again", out m) == TellShortcut.Retell && m == "again", "/retell");
Check(TellMemory.Parse("/r", out m) == TellShortcut.Reply && m == "", "/r alone");
Check(TellMemory.Parse(" /rt ", out m) == TellShortcut.Retell && m == "", "/rt alone, padded");
Check(TellMemory.Parse("/ra start", out _) == TellShortcut.None, "/ra is RynthAi's");
Check(TellMemory.Parse("/rc ui", out _) == TellShortcut.None, "/rc is the engine's");
Check(TellMemory.Parse("/rn", out _) == TellShortcut.None, "/rn");
Check(TellMemory.Parse("/rtx hi", out _) == TellShortcut.None, "/rtx");
Check(TellMemory.Parse("r hi", out _) == TellShortcut.None, "no slash: said aloud");
Check(TellMemory.Parse("/tell Bob, hi", out _) == TellShortcut.None, "/tell");
Check(TellMemory.Parse("", out _) == TellShortcut.None && TellMemory.Parse(null, out _) == TellShortcut.None, "empty / null");
}
// ── tracking ────────────────────────────────────────────────────────────
private static void IncomingTellSetsReplyTarget()
{
Case("incoming player tell: the reply target");
var t = new TellMemory();
Check(t.LastTeller == null && t.LastTellee == null, "starts empty");
t.OnChatLine(BobTells);
Check(t.LastTeller == "Bob", "Bob");
t.OnChatLine("<Tell:IIDString:1342177300:Sir Alice Two>Sir Alice Two<\\Tell> tells you, \"x, y\"");
Check(t.LastTeller == "Sir Alice Two", "a spaced name; the newest tell wins");
t.OnChatLine("<Tell:IIDString:1342177301:Olthy&>Olthy&<\\Tell> tells you, \"grr\"");
Check(t.LastTeller == "Olthy", "an Olthoi player's suffix dropped");
t.OnChatLine("<Tell:IIDString:1342177302:Carl>Carl<\\Tell> tells you, \"bye\"\n");
Check(t.LastTeller == "Carl", "trailing line break");
Check(t.LastTellee == null, "an incoming tell is not a retell target");
}
private static void NpcAndOtherLinesIgnored()
{
Case("lines that aren't a player's tell change nothing");
var t = new TellMemory();
t.OnChatLine(BobTells);
t.OnChatLine("Town Crier tells you, \"Hear ye\""); // an NPC: AC adds no link (retail /r ignores it too)
Check(t.LastTeller == "Bob", "NPC tell");
t.OnChatLine("Dave says, \"<Tell:IIDString:1:Eve>Eve<\\Tell> tells you, nonsense\"");
Check(t.LastTeller == "Bob", "a quoted tell inside a say");
t.OnChatLine("[Allegiance] <Tell:IIDString:1342177400:Fred>Fred<\\Tell> says, \"hi\"");
Check(t.LastTeller == "Bob", "channel line with a link");
t.OnChatLine("Dave says, \"You tell Bob, nothing\"");
Check(t.LastTellee == null, "a quoted echo inside a say");
t.OnChatLine("");
t.OnChatLine(null);
Check(t.LastTeller == "Bob" && t.LastTellee == null, "empty / null");
}
private static void OutgoingTellSetsRetellTarget()
{
Case("tells you send: the retell target");
var t = new TellMemory();
t.OnChatLine("You tell Bob, \"hello\"");
Check(t.LastTellee == "Bob", "server echo");
t.NoteTellSent(" Alice ");
Check(t.LastTellee == "Alice", "dispatcher's /tell, trimmed");
t.OnChatLine("You tell Sir Bob Two, \"a, b\"");
Check(t.LastTellee == "Sir Bob Two", "echo with a spaced name and a comma in the message");
t.NoteTellSent("");
t.NoteTellSent(null);
t.NoteTellSent(" ");
Check(t.LastTellee == "Sir Bob Two", "blank names ignored");
Check(t.LastTeller == null, "a sent tell is not a reply target");
t.Clear();
Check(t.LastTeller == null && t.LastTellee == null, "Clear");
}
// ── rewrite ─────────────────────────────────────────────────────────────
private static void RewriteCases()
{
Case("rewrite to /tell");
var t = new TellMemory();
Check(!t.TryRewrite("/say hi", out string? line, out string? err) && line == null && err == null, "not a shortcut");
Check(t.TryRewrite("/r hi", out line, out err) && line == null && err == TellMemory.NoTellerMessage, "/r with no one to reply to");
Check(t.TryRewrite("/rt hi", out line, out err) && line == null && err == TellMemory.NoTelleeMessage, "/rt with no one to retell");
t.OnChatLine(BobTells);
t.NoteTellSent("Alice");
Check(t.TryRewrite("/r thanks, mate", out line, out err) && line == "/tell Bob, thanks, mate" && err == null, "/r -> Bob (message commas kept)");
Check(t.TryRewrite("/reply ok", out line, out _) && line == "/tell Bob, ok", "/reply -> Bob");
Check(t.TryRewrite("/rt again", out line, out _) && line == "/tell Alice, again", "/rt -> Alice");
Check(t.TryRewrite("/retell again", out line, out _) && line == "/tell Alice, again", "/retell -> Alice");
Check(t.TryRewrite("/r", out line, out err) && line == null && err != null && err.Contains("Bob"), "/r alone: says who it would go to");
// The dispatcher's /tell then remembers Bob, so /rt after /r goes to Bob (retail too: the server echoes "You tell Bob").
t.NoteTellSent("Bob");
Check(t.TryRewrite("/rt more", out line, out _) && line == "/tell Bob, more", "/rt after /r");
}
// ── paste ───────────────────────────────────────────────────────────────
private static void PasteClean()
{
Case("paste: one clean line");
Check(ChatInputPaste.Clean("hello") == "hello", "plain");
Check(ChatInputPaste.Clean("a\r\nb") == "a b", "CRLF -> space");
Check(ChatInputPaste.Clean("a\n\n\nb") == "a b", "a run of breaks -> one space");
Check(ChatInputPaste.Clean("a \nb") == "a b" && ChatInputPaste.Clean("a\n b") == "a b", "no double space at a break");
Check(ChatInputPaste.Clean("\r\nab\r\n") == "ab", "leading / trailing breaks dropped");
Check(ChatInputPaste.Clean("a\tb") == "a b", "tab -> space");
Check(ChatInputPaste.Clean("a\u0016b\u0003c\u007Fd") == "abcd", "control characters dropped");
Check(ChatInputPaste.Clean("héllo ✓") == "héllo ✓", "non-ASCII kept");
Check(ChatInputPaste.Clean(null) == "" && ChatInputPaste.Clean("") == "", "null / empty");
}
private static void PasteInsert()
{
Case("paste: inserted at the caret");
Check(ChatInputPaste.Insert("/tell Bob, ", 11, "hi there", out int c) == "/tell Bob, hi there" && c == 19, "at the end");
Check(ChatInputPaste.Insert("ac", 1, "b", out c) == "abc" && c == 2, "in the middle");
Check(ChatInputPaste.Insert("bc", 0, "a", out c) == "abc" && c == 1, "at the start");
Check(ChatInputPaste.Insert("ab", 99, "c", out c) == "abc" && c == 3, "caret past the end clamped");
string same = "keep";
Check(ReferenceEquals(ChatInputPaste.Insert(same, 2, "\r\n", out c), same) && c == 2, "nothing to paste: line unchanged");
Check(ReferenceEquals(ChatInputPaste.Insert(same, 2, null, out c), same) && c == 2, "empty clipboard: line unchanged");
string big = new('x', 5000);
string r = ChatInputPaste.Insert("ab", 2, big, out c);
Check(r.Length == ChatInputPaste.MaxLineChars && c == ChatInputPaste.MaxLineChars, "capped at MaxLineChars");
string full = new('y', ChatInputPaste.MaxLineChars);
Check(ReferenceEquals(ChatInputPaste.Insert(full, 3, "z", out c), full) && c == 3, "full line: nothing added");
string pair = new string('a', ChatInputPaste.MaxLineChars - 2);
r = ChatInputPaste.Insert(pair, pair.Length, "b\U0001F600c", out c); // room for "b" + half the pair
Check(r == pair + "b" && c == pair.Length + 1, "never splits a surrogate pair");
}
private static void Case(string name)
{
_case = name;
Console.WriteLine($"-- {name}");
}
private static void Check(bool ok, string what)
{
_checks++;
if (ok) return;
_failed++;
Console.WriteLine($" FAIL [{_case}] {what}");
}
}

View file

@ -93,6 +93,7 @@ ENQUEUE = "AcMainThreadQueue.Enqueue"
ENQUEUE_PRODUCER_ALLOW = {
("AutoIdService.cs", "DrainTick"), # appraisal: enqueues 0xC8, sent on main thread in DrainRequestIds
("RynthCoreChatCommands.cs", "Reply"), # /rc and /rv plates replies: only EnqueueWriteToChat
("AcMouseOver.cs", "Say"), # /rc acmouse watch lines: only EnqueueWriteToChat (and the log)
}
# CHECK C sinks: raw stores into memory. Comments are stripped before matching.

View file

@ -17,7 +17,12 @@ fails here instead of in game:
client has CatchDroppedItem there (directly, or UIElement_Field's, which calls it);
* every UIElement vtable has GetUIElementType at +0x98 (mov eax,imm32 / ret, or xor/ret),
UIElement_ItemList's returns 0x10000031, GetParent is the vtable +0xA0 call that
GetAncestorByID walks, and the element id is at +0x2E4.
GetAncestorByID walks, and the element id is at +0x2E4;
* AC's mouse-over (Compatibility/AcMouseOver.cs): SwitchMouseOver stores the element under
the mouse at +0x244, every hit test that feeds it skips +0x2D4 (cursor left) and starts
at the root (+0x9C), DeletingElement clears it, UseTime calls CheckTooltip with the
manager every frame, and exactly one UIElement class (SmartBoxWrapper, the 3D view)
has type 0x10000030.
Usage: python tools/ui_hooks_check.py ["<path-to-acclient.exe>"]
Exit 0 = every check passed.
@ -165,6 +170,51 @@ def main():
check(not bad_type, f"every UIElement vtable's +0x98 is GetUIElementType ({len(tables) - len(bad_type)}/{len(tables)})")
itemlist = [t for t in tables if at(u32(t + 0x98), 6) == bytes([0xB8, 0x31, 0x00, 0x00, 0x10, 0xC3])]
check(len(itemlist) >= 1, f"UIElement_ItemList's GetUIElementType returns 0x10000031 ({len(itemlist)} vtable(s))")
# 8a. the 3D view's element class (Compatibility/AcMouseOver.cs)
smartbox = [t for t in tables if at(u32(t + 0x98), 6) == bytes([0xB8, 0x30, 0x00, 0x00, 0x10, 0xC3])]
check(len(smartbox) == 1, f"UIElement_SmartBoxWrapper: one UIElement vtable whose GetUIElementType returns 0x10000030 ({len(smartbox)})")
# 8. AC's mouse-over element (Compatibility/AcMouseOver.cs): UIElementManager +0x244
switch = find([0x53, 0x8B, 0x5C, 0x24, 0x08, 0x56, 0x8B, 0xF1, 0x8B, 0x86, 0x44, 0x02, 0x00, 0x00, 0x57, 0x33, 0xFF,
0x3B, 0xD8, 0x74, 0x06, 0x89, 0x9E, 0x44, 0x02, 0x00, 0x00])
check(switch is not None, f"SwitchMouseOver found: stores its argument at +0x244 (0x{(switch or 0):08X})")
if switch:
check(body_has(switch, [0x8A, 0x83, 0x45, 0x05, 0x00, 0x00], 0x40), "SwitchMouseOver: the hover element needs the element's +0x545 byte")
hit_tests, recurse = 0, set()
for c in rel_callers(switch):
pre = W[c - BASE - 0x40:c - BASE]
calls = [c - 0x40 + k + 5 + struct.unpack_from("<i", pre, k + 1)[0] for k in range(len(pre) - 5) if pre[k] == 0xE8]
if b"\xD4\x02\x00\x00" in pre and b"\x9C\x00\x00\x00" in pre and calls:
hit_tests += 1
recurse.add(calls[-1])
check(hit_tests >= 4 and len(recurse) == 1,
f"{hit_tests} SwitchMouseOver calls follow a +0x2D4 test and a hit test from the root (+0x9C) "
f"through one function (MouseMoveHandler, MouseDownEvent, UpdateMouseOver, DoMouseUpdate)")
if len(recurse) == 1:
r = recurse.pop()
check(body_has(r, [0x8B, 0x85, 0xA4, 0x00, 0x00, 0x00], 0x20) and body_has(r, [0x8A, 0x85, 0x45, 0x05, 0x00, 0x00], 0xA0)
and body_has(r, [0xC1, 0xE9, 0x06], 0xA0),
f"MouseOverCriteria::Recurse (0x{r:08X}): visible elements only (+0xA4), returns one with +0x545 or +0xA4 bit 6")
leave = find([0x6A, 0x00, 0xC6, 0x81, 0xD4, 0x02, 0x00, 0x00, 0x01, 0xE8])
tgt = leave + 9 + 5 + struct.unpack_from("<i", W, leave - BASE + 10)[0] if leave else 0
check(tgt == switch, "MouseLeaveEvent: sets +0x2D4 (cursor left) and SwitchMouseOver(0)")
dele = find([0x39, 0xAE, 0x44, 0x02, 0x00, 0x00, 0x75, 0x21, 0x53, 0x8B, 0xCE, 0xE8, N, N, N, N,
0x89, 0x9E, 0x48, 0x02, 0x00, 0x00, 0x89, 0x9E, 0x44, 0x02, 0x00, 0x00])
check(dele is not None, "DeletingElement: clears +0x244 (and +0x248) when that element goes")
usetime = find([0x56, 0x8B, 0xF1, 0xE8, N, N, N, N, 0x8B, 0xCE, 0xE8, N, N, N, N, 0x8A, 0x86, 0x40, 0x02, 0x00, 0x00,
0x84, 0xC0, 0x74, 0x05, 0xE8, N, N, N, N, 0x8B, 0xCE, 0xE8])
tgt = usetime + 32 + 5 + struct.unpack_from("<i", W, usetime - BASE + 33)[0] if usetime else 0
check(tgt == va["UiElement.CheckTooltip"], "UIElementManager::UseTime calls CheckTooltip with ecx = the manager, every frame")
check(len(matches(W, [0x68, 0x30, 0x00, 0x00, 0x10], limit=8)) >= 1,
"push 10000030h present (SmartBoxWrapper::Register registers the type)")
src = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "src", "RynthCore.Engine", "Compatibility")
with open(os.path.join(src, "AcMouseOver.cs"), encoding="utf-8") as f:
mo = f.read()
with open(os.path.join(src, "AcMouseOverRules.cs"), encoding="utf-8") as f:
rules = f.read()
check("MgrMouseOver = 0x244" in mo and "MgrMouseOutside = 0x2D4" in mo and "VtGetUIElementType = 0x98" in mo,
"AcMouseOver.cs reads +0x244, +0x2D4 and vtable +0x98")
check("UIElementTypeSmartBoxWrapper = 0x10000030" in rules, "AcMouseOverRules.cs: the 3D view is type 0x10000030")
print("=" * 60)
print("PASS - the UI hooks' facts hold on this client." if fails == 0 else f"FAIL - {fails} check(s) failed.")