diff --git a/src/RynthCore.Engine/Compatibility/AcClientModule.cs b/src/RynthCore.Engine/Compatibility/AcClientModule.cs index 7ca8e21..eb752e4 100644 --- a/src/RynthCore.Engine/Compatibility/AcClientModule.cs +++ b/src/RynthCore.Engine/Compatibility/AcClientModule.cs @@ -59,7 +59,7 @@ internal static class AcClientModule if (!_loggedBaseOnce) { _loggedBaseOnce = true; - RynthLog.Compat($"Compat: acclient.exe base=0x{moduleBase.ToInt32():X8}, size=0x{imageSize:X}"); + RynthLog.Verbose($"Compat: acclient.exe base=0x{moduleBase.ToInt32():X8}, size=0x{imageSize:X}"); } int rawTextSize = imageSize - DefaultTextRva; diff --git a/src/RynthCore.Engine/Compatibility/AccountHooks.cs b/src/RynthCore.Engine/Compatibility/AccountHooks.cs index 1cee7c6..2403a30 100644 --- a/src/RynthCore.Engine/Compatibility/AccountHooks.cs +++ b/src/RynthCore.Engine/Compatibility/AccountHooks.cs @@ -78,7 +78,7 @@ internal static class AccountHooks _getAccountName = Marshal.GetDelegateForFunctionPointer( new IntPtr(ReferenceClientGetAccountName)); IsInitialized = true; - RynthLog.Compat("Compat: account hooks ready."); + RynthLog.Verbose("Compat: account hooks ready."); } catch (Exception ex) { @@ -121,7 +121,7 @@ internal static class AccountHooks MinHook.Enable(targetAddress); WorldHookInstalled = true; - RynthLog.Compat($"Compat: world-name hook ready - ECM_Login::SendNotice_WorldName @ 0x{targetAddress.ToInt32():X8}."); + RynthLog.Verbose($"Compat: world-name hook ready - ECM_Login::SendNotice_WorldName @ 0x{targetAddress.ToInt32():X8}."); } catch (Exception ex) { @@ -149,7 +149,7 @@ internal static class AccountHooks if (!string.IsNullOrEmpty(name)) { _cachedWorldName = name; - RynthLog.Compat($"Compat: world name captured - \"{name}\"."); + RynthLog.Verbose($"Compat: world name captured - \"{name}\"."); } } } diff --git a/src/RynthCore.Engine/Compatibility/AppraisalHooks.cs b/src/RynthCore.Engine/Compatibility/AppraisalHooks.cs index 87b4aa6..bedb552 100644 --- a/src/RynthCore.Engine/Compatibility/AppraisalHooks.cs +++ b/src/RynthCore.Engine/Compatibility/AppraisalHooks.cs @@ -172,7 +172,7 @@ internal static class AppraisalHooks _hookInstalled = true; _statusMessage = $"Hooked CM_Examine::SendNotice_SetAppraiseInfo @ 0x{targetAddress.ToInt32():X8}."; - RynthLog.Compat($"Compat: appraisal hook ready @ 0x{targetAddress.ToInt32():X8}, firstByte=0x{firstByte:X2}"); + RynthLog.Verbose($"Compat: appraisal hook ready @ 0x{targetAddress.ToInt32():X8}, firstByte=0x{firstByte:X2}"); } catch (Exception ex) { @@ -270,7 +270,7 @@ internal static class AppraisalHooks _intCache[guid] = props; } - RynthLog.Compat($"Compat: cached {props.Count} int prop(s) for guid=0x{guid:X8}"); + RynthLog.Verbose($"Compat: cached {props.Count} int prop(s) for guid=0x{guid:X8}"); } private static void CacheBoolProps(uint guid, IntPtr profilePtr) @@ -312,7 +312,7 @@ internal static class AppraisalHooks _boolCache[guid] = props; } - RynthLog.Compat($"Compat: cached {props.Count} bool prop(s) for guid=0x{guid:X8}"); + RynthLog.Verbose($"Compat: cached {props.Count} bool prop(s) for guid=0x{guid:X8}"); } private static void CacheStringProps(uint guid, IntPtr profilePtr) @@ -367,7 +367,7 @@ internal static class AppraisalHooks _stringCache[guid] = props; } - RynthLog.Compat($"Compat: cached {props.Count} string prop(s) for guid=0x{guid:X8}"); + RynthLog.Verbose($"Compat: cached {props.Count} string prop(s) for guid=0x{guid:X8}"); } private static void CacheSpellIds(uint guid, IntPtr profilePtr) @@ -386,7 +386,7 @@ internal static class AppraisalHooks if (mNum == 0) { - RynthLog.Compat($"Compat: guid=0x{guid:X8} spell book present but empty (mNum=0)"); + RynthLog.Verbose($"Compat: guid=0x{guid:X8} spell book present but empty (mNum=0)"); return; } if (mData == IntPtr.Zero || mNum < 0 || mNum > 512) @@ -402,7 +402,7 @@ internal static class AppraisalHooks lock (_cacheLock) _spellIdCache[guid] = ids; - RynthLog.Compat($"Compat: cached {mNum} spell ID(s) for guid=0x{guid:X8}"); + RynthLog.Verbose($"Compat: cached {mNum} spell ID(s) for guid=0x{guid:X8}"); } /// diff --git a/src/RynthCore.Engine/Compatibility/AutoIdService.cs b/src/RynthCore.Engine/Compatibility/AutoIdService.cs index 57b0b93..429ba39 100644 --- a/src/RynthCore.Engine/Compatibility/AutoIdService.cs +++ b/src/RynthCore.Engine/Compatibility/AutoIdService.cs @@ -38,7 +38,7 @@ internal static class AutoIdService return; _started = true; _drainTimer = new Timer(DrainTick, null, DrainIntervalMs, DrainIntervalMs); - RynthLog.Compat("Compat: AutoIdService started."); + RynthLog.Verbose("Compat: AutoIdService started."); } /// diff --git a/src/RynthCore.Engine/Compatibility/BusyCountHooks.cs b/src/RynthCore.Engine/Compatibility/BusyCountHooks.cs index 2389bf1..dd1f4bd 100644 --- a/src/RynthCore.Engine/Compatibility/BusyCountHooks.cs +++ b/src/RynthCore.Engine/Compatibility/BusyCountHooks.cs @@ -11,9 +11,18 @@ internal static class BusyCountHooks private const int IncrementBusyCountVa = 0x00565610; private const int DecrementBusyCountVa = 0x00565630; + // ClientUISystem::UpdateCursorState — per-frame cursor evaluation + private const int UpdateCursorStateVa = 0x005653D0; + + // ClientUISystem struct field offset for m_cBusy (confirmed via runtime dump) + private const int OffsetMCBusy = 0x14; + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] private delegate void BusyCountDelegate(IntPtr thisPtr); + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + private delegate void UpdateCursorStateDelegate(IntPtr thisPtr); + private static BusyCountDelegate? _originalIncrementBusyCount; private static BusyCountDelegate? _incrementBusyCountDetour; private static BusyCountDelegate? _originalDecrementBusyCount; @@ -24,6 +33,7 @@ internal static class BusyCountHooks private static int _incrementDispatchCount; private static int _decrementDispatchCount; private static int _netBusyCount; + private static IntPtr _lastThisPtr; public static bool IsInstalled { get; private set; } public static string StatusMessage => _statusMessage; @@ -31,6 +41,49 @@ internal static class BusyCountHooks /// Returns 0 if the character is idle, positive if a UI action is in progress. public static int GetBusyState() => Math.Max(0, _netBusyCount); + /// Force-reset the client's busy count to zero and re-evaluate the cursor. + /// Directly writes m_cBusy=0 then calls UpdateCursorState so the game + /// switches from hourglass back to the default arrow. + public static void ForceResetBusyCount() + { + if (!IsInstalled || _lastThisPtr == IntPtr.Zero) + return; + + int was = _netBusyCount; + + // Call the original decrement a few times to let the client run + // its own cleanup path (cursor reset, etc) for any non-zero count. + if (_originalDecrementBusyCount != null) + { + int calls = Math.Max(was, 3); + for (int i = 0; i < calls && i < 20; i++) + _originalDecrementBusyCount(_lastThisPtr); + } + + Interlocked.Exchange(ref _netBusyCount, 0); + + // Directly zero m_cBusy — DecrementBusyCount guards with if(m_cBusy>0) + // so it's a no-op when our tracked count drifts from the real value. + try { Marshal.WriteInt32(_lastThisPtr + OffsetMCBusy, 0); } + catch { /* non-fatal */ } + + // Clear pending commands and restore client control + CommandInterpreterHooks.ClearAllCommands(); + CommandInterpreterHooks.TakeControlFromServer(); + CommandInterpreterHooks.PlayerTeleported(); + + // Force the game's own cursor evaluation with the cleared state + try + { + var updateCursor = Marshal.GetDelegateForFunctionPointer( + new IntPtr(UpdateCursorStateVa)); + updateCursor(_lastThisPtr); + } + catch { /* non-fatal */ } + + RynthLog.Verbose($"Compat: force-reset busy count (was {was})"); + } + public static void Initialize() { if (IsInstalled) @@ -76,8 +129,7 @@ internal static class BusyCountHooks IsInstalled = true; _statusMessage = $"Hooked busy-count seams @ 0x{_incrementTargetAddress.ToInt32():X8}/0x{_decrementTargetAddress.ToInt32():X8}."; - RynthLog.Compat( - $"Compat: busy-count hooks ready - increment=0x{_incrementTargetAddress.ToInt32():X8} (0x{incrementByte:X2}), decrement=0x{_decrementTargetAddress.ToInt32():X8} (0x{decrementByte:X2})"); + RynthLog.Verbose($"Compat: busy-count hooks installed"); } catch (Exception ex) { @@ -88,24 +140,19 @@ internal static class BusyCountHooks private static void IncrementBusyCountDetour(IntPtr thisPtr) { + _lastThisPtr = thisPtr; _originalIncrementBusyCount!(thisPtr); - - int count = Interlocked.Increment(ref _incrementDispatchCount); - if (count <= 0) - RynthLog.Compat($"Compat: busy count incremented #{count}"); - + Interlocked.Increment(ref _incrementDispatchCount); Interlocked.Increment(ref _netBusyCount); PluginManager.QueueBusyCountIncremented(); } private static void DecrementBusyCountDetour(IntPtr thisPtr) { + if (_lastThisPtr == IntPtr.Zero) + _lastThisPtr = thisPtr; _originalDecrementBusyCount!(thisPtr); - - int count = Interlocked.Increment(ref _decrementDispatchCount); - if (count <= 0) - RynthLog.Compat($"Compat: busy count decremented #{count}"); - + Interlocked.Increment(ref _decrementDispatchCount); Interlocked.Decrement(ref _netBusyCount); PluginManager.QueueBusyCountDecremented(); } diff --git a/src/RynthCore.Engine/Compatibility/CharacterCaptureHooks.cs b/src/RynthCore.Engine/Compatibility/CharacterCaptureHooks.cs index de2ed6c..41b8235 100644 --- a/src/RynthCore.Engine/Compatibility/CharacterCaptureHooks.cs +++ b/src/RynthCore.Engine/Compatibility/CharacterCaptureHooks.cs @@ -79,7 +79,7 @@ internal static class CharacterCaptureHooks uint opcode = unchecked((uint)Marshal.ReadInt32(payloadPtr)); if (opcode == PostConnectReadyOpcode) { - RynthLog.Compat($"CharacterCapture: [{(isGameEvent ? "GameEvent" : "SmartBox")}] Observed post-connect packet (0xF7EA)."); + RynthLog.Verbose($"CharacterCapture: [{(isGameEvent ? "GameEvent" : "SmartBox")}] Observed post-connect packet (0xF7EA)."); LogoBypassHooks.NotifyPostConnectObserved(); return; } @@ -87,7 +87,7 @@ internal static class CharacterCaptureHooks if (opcode != CharacterListOpcode) return; - RynthLog.Compat($"CharacterCapture: [{(isGameEvent ? "GameEvent" : "SmartBox")}] Found CharacterList (0xF658)!"); + RynthLog.Verbose($"CharacterCapture: [{(isGameEvent ? "GameEvent" : "SmartBox")}] Found CharacterList (0xF658)!"); LogoBypassHooks.NotifyCharacterListObserved(); (List characters, int slotCount) = ParseAndSaveCharacterList(payloadPtr, blobSize); ScheduleAutoLoginIfRequested(characters, slotCount); @@ -112,7 +112,7 @@ internal static class CharacterCaptureHooks uint opcode = unchecked((uint)Marshal.ReadInt32(buffer)); if (opcode == PostConnectReadyOpcode) { - RynthLog.Compat("CharacterCapture: [InnerDispatcher] Observed post-connect packet (0xF7EA)."); + RynthLog.Verbose("CharacterCapture: [InnerDispatcher] Observed post-connect packet (0xF7EA)."); LogoBypassHooks.NotifyPostConnectObserved(); return; } @@ -120,7 +120,7 @@ internal static class CharacterCaptureHooks if (opcode != CharacterListOpcode) return; - RynthLog.Compat("CharacterCapture: [InnerDispatcher] Processing 0xF658 raw buffer."); + RynthLog.Verbose("CharacterCapture: [InnerDispatcher] Processing 0xF658 raw buffer."); LogoBypassHooks.NotifyCharacterListObserved(); (List characters, int slotCount) = size >= 12 ? ParseAndSaveCharacterList(buffer, size) @@ -177,7 +177,7 @@ internal static class CharacterCaptureHooks ? Marshal.ReadInt32(IntPtr.Add(payloadPtr, offset)) : characters.Count; - RynthLog.Compat($"CharacterCapture: Parsed {characters.Count} chars ({slotCount} slots): {string.Join(", ", characters)}"); + RynthLog.Verbose($"CharacterCapture: Parsed {characters.Count} chars ({slotCount} slots): {string.Join(", ", characters)}"); if (characters.Count > 0) { @@ -247,7 +247,7 @@ internal static class CharacterCaptureHooks if (!string.IsNullOrWhiteSpace(accountName)) { CharacterCacheStore.Write(accountName, serverName, characters); - RynthLog.Compat( + RynthLog.Verbose( !string.IsNullOrWhiteSpace(serverName) ? $"CharacterCapture: Saved {characters.Count} chars for '{accountName}' on '{serverName}'." : $"CharacterCapture: Saved {characters.Count} chars for '{accountName}' (no server name in context)."); @@ -298,7 +298,7 @@ internal static class CharacterCaptureHooks }; thread.Start(); - RynthLog.Compat( + RynthLog.Verbose( fallbackIndex >= 0 ? $"CharacterCapture: Auto-login scheduled for '{targetCharacter}' in {scheduledDelayMs}ms (native direct login first, fallback slot index {fallbackIndex}, logoDelay={logoDelayMs}ms)." : $"CharacterCapture: Auto-login scheduled for '{targetCharacter}' in {scheduledDelayMs}ms (native direct login only so far, logoDelay={logoDelayMs}ms)."); @@ -311,13 +311,13 @@ internal static class CharacterCaptureHooks { if (LoginLifecycleHooks.HasObservedLoginComplete) { - RynthLog.Compat($"CharacterCapture: Auto-login for '{targetCharacter}' skipped because login is already complete."); + RynthLog.Verbose($"CharacterCapture: Auto-login for '{targetCharacter}' skipped because login is already complete."); return; } if (CharacterManagementHooks.TryLogOnCharacter(targetCharacter, out string matchedCharacter, out uint avatarId, out string directStatus)) { - RynthLog.Compat( + RynthLog.Verbose( $"CharacterCapture: Direct auto-login succeeded for '{matchedCharacter}' (target '{targetCharacter}', avatar 0x{avatarId:X8}) on attempt {attempt}/{DirectAutoLoginAttempts}."); return; } @@ -350,7 +350,7 @@ internal static class CharacterCaptureHooks for (int attempt = 1; attempt <= AutoLoginAttempts; attempt++) { - RynthLog.Compat($"CharacterCapture: Auto-login attempt {attempt}/{AutoLoginAttempts} for '{targetCharacter}' at ({XCharList}, {yOffset})."); + RynthLog.Verbose($"CharacterCapture: Auto-login attempt {attempt}/{AutoLoginAttempts} for '{targetCharacter}' at ({XCharList}, {yOffset})."); PostMouseClick(hwnd, XCharList, yOffset); Thread.Sleep(AutoLoginDoubleClickGapMs); @@ -360,7 +360,7 @@ internal static class CharacterCaptureHooks Thread.Sleep(AutoLoginAttemptDelayMs); } - RynthLog.Compat($"CharacterCapture: Auto-login double-click sequence complete for '{targetCharacter}'."); + RynthLog.Verbose($"CharacterCapture: Auto-login double-click sequence complete for '{targetCharacter}'."); } private static IntPtr WaitForGameWindow() diff --git a/src/RynthCore.Engine/Compatibility/CharacterManagementHooks.cs b/src/RynthCore.Engine/Compatibility/CharacterManagementHooks.cs index aa4ad34..b53fa81 100644 --- a/src/RynthCore.Engine/Compatibility/CharacterManagementHooks.cs +++ b/src/RynthCore.Engine/Compatibility/CharacterManagementHooks.cs @@ -162,7 +162,7 @@ internal static class CharacterManagementHooks _characterSetGetGid = Marshal.GetDelegateForFunctionPointer(new IntPtr(CharacterSetGetGidVa)); _bound = true; _statusMessage = "Bound."; - RynthLog.Compat("CharacterManagement: Bound UIFlow and direct LogOnCharacter entry points."); + RynthLog.Verbose("CharacterManagement: Bound UIFlow and direct LogOnCharacter entry points."); } catch (Exception ex) { diff --git a/src/RynthCore.Engine/Compatibility/ChatCallbackHooks.cs b/src/RynthCore.Engine/Compatibility/ChatCallbackHooks.cs index 9888206..ccf42bf 100644 --- a/src/RynthCore.Engine/Compatibility/ChatCallbackHooks.cs +++ b/src/RynthCore.Engine/Compatibility/ChatCallbackHooks.cs @@ -153,7 +153,7 @@ internal static class ChatCallbackHooks } _statusMessage = $"Ready. incoming={incomingStatus}, outgoing={outgoingStatus}."; - RynthLog.Compat($"Compat: chat callback hooks ready - incoming={incomingStatus}, outgoing={outgoingStatus}"); + RynthLog.Verbose($"Compat: chat callback hooks ready - incoming={incomingStatus}, outgoing={outgoingStatus}"); } catch (Exception ex) { @@ -169,7 +169,7 @@ internal static class ChatCallbackHooks if (CurrentIncomingMode is not IncomingChatMode.WrapperQueuedText and not IncomingChatMode.WrapperQueuedTextHostEat) { - RynthLog.Compat("Compat: preferred incoming chat seam unavailable - falling back to wrapper path."); + RynthLog.Verbose("Compat: preferred incoming chat seam unavailable - falling back to wrapper path."); return TryInstallIncomingWrapperHook(textSection, out incomingStatus); } @@ -310,7 +310,7 @@ internal static class ChatCallbackHooks int count = Interlocked.Increment(ref _incomingCallCount); if (count <= 0) - RynthLog.Compat($"Compat: incoming chat #{count} type={chatType} len={length}"); + RynthLog.Verbose($"Compat: incoming chat #{count} type={chatType} len={length}"); return line; } @@ -491,7 +491,7 @@ internal static class ChatCallbackHooks if (IsLikelyExternalHookOpcode(entryByte)) { resolution = $"skipped (prepatched-0x{entryByte:X2})"; - RynthLog.Compat($"Compat: outgoing chat entry at 0x{OutgoingChatVa:X8} appears prepatched (opcode 0x{entryByte:X2}) - skipping RynthCore outgoing hook to avoid conflicting with another injector."); + RynthLog.Verbose($"Compat: outgoing chat entry at 0x{OutgoingChatVa:X8} appears prepatched (opcode 0x{entryByte:X2}) - skipping RynthCore outgoing hook to avoid conflicting with another injector."); return false; } } diff --git a/src/RynthCore.Engine/Compatibility/ClientActionHooks.cs b/src/RynthCore.Engine/Compatibility/ClientActionHooks.cs index b993282..ecedb46 100644 --- a/src/RynthCore.Engine/Compatibility/ClientActionHooks.cs +++ b/src/RynthCore.Engine/Compatibility/ClientActionHooks.cs @@ -33,7 +33,7 @@ internal static class ClientActionHooks public static void Probe() { - RynthLog.Compat("Compat: probing RynthAi action hooks..."); + RynthLog.Verbose("Compat: probing RynthAi action hooks..."); bool combatReady = CombatActionHooks.Probe(); bool movementReady = MovementActionHooks.Probe(); @@ -41,7 +41,7 @@ internal static class ClientActionHooks bool playerPhysicsReady = PlayerPhysicsHooks.Probe(); bool objectReady = ClientObjectHooks.Probe(); - RynthLog.Compat($"Compat: probe complete. combat={(combatReady ? "ready" : "off")}, movement={(movementReady ? "ready" : "off")}, local={(cmdInterpReady ? "ready" : "off")}, player={(playerPhysicsReady ? "ready" : "off")}, objects={(objectReady ? "ready" : "off")}"); + RynthLog.Verbose($"Compat: probe complete. combat={(combatReady ? "ready" : "off")}, movement={(movementReady ? "ready" : "off")}, local={(cmdInterpReady ? "ready" : "off")}, player={(playerPhysicsReady ? "ready" : "off")}, objects={(objectReady ? "ready" : "off")}"); } public static ClientActionHookStatus GetStatus() diff --git a/src/RynthCore.Engine/Compatibility/ClientCombatHooks.cs b/src/RynthCore.Engine/Compatibility/ClientCombatHooks.cs index 6cf0df4..2cba760 100644 --- a/src/RynthCore.Engine/Compatibility/ClientCombatHooks.cs +++ b/src/RynthCore.Engine/Compatibility/ClientCombatHooks.cs @@ -86,22 +86,22 @@ internal static class ClientCombatHooks // Verify the combat system singleton is accessible IntPtr cs = _getCombatSystem(); IntPtr globalPtr = Marshal.ReadIntPtr(new IntPtr(CombatSystemPtrVa)); - RynthLog.Compat($"Compat: ClientCombat GetCombatSystem()=0x{cs:X8}, global=0x{globalPtr:X8}"); + RynthLog.Verbose($"Compat: ClientCombat GetCombatSystem()=0x{cs:X8}, global=0x{globalPtr:X8}"); if (cs == IntPtr.Zero && globalPtr == IntPtr.Zero) { _statusMessage = "GetCombatSystem returned null — client not ready."; - RynthLog.Compat($"Compat: ClientCombat probe - {_statusMessage}"); + RynthLog.Verbose($"Compat: ClientCombat probe - {_statusMessage}"); // Don't fail — the pointer may be valid after login } else { IntPtr used = cs != IntPtr.Zero ? cs : globalPtr; - RynthLog.Compat($"Compat: ClientCombatSystem at 0x{used:X8}"); + RynthLog.Verbose($"Compat: ClientCombatSystem at 0x{used:X8}"); } _initialized = true; _statusMessage = "Ready."; - RynthLog.Compat("Compat: ClientCombat hooks ready — native attack pipeline available."); + RynthLog.Verbose("Compat: ClientCombat hooks ready — native attack pipeline available."); return true; } catch (Exception ex) diff --git a/src/RynthCore.Engine/Compatibility/ClientHelperHooks.cs b/src/RynthCore.Engine/Compatibility/ClientHelperHooks.cs index 0bda22f..9eef028 100644 --- a/src/RynthCore.Engine/Compatibility/ClientHelperHooks.cs +++ b/src/RynthCore.Engine/Compatibility/ClientHelperHooks.cs @@ -167,7 +167,7 @@ internal static class ClientHelperHooks _gmSalvageUISalvage = Marshal.GetDelegateForFunctionPointer(new IntPtr(GmSalvageUISalvageVa)); _initialized = true; _statusMessage = "Ready."; - RynthLog.Compat("Compat: helper hooks ready - validated select/state/chat helpers plus mapped interaction and inventory helpers."); + RynthLog.Verbose("Compat: helper hooks ready - validated select/state/chat helpers plus mapped interaction and inventory helpers."); return true; } catch (Exception ex) @@ -385,7 +385,7 @@ internal static class ClientHelperHooks int room = maxStack - targetCount; if (room <= 0) { - RynthLog.Compat($"Compat: Event_StackableMerge skipped - target 0x{targetObjectId:X8}({targetCount}) is full (max={maxStack})"); + RynthLog.Verbose($"Compat: Event_StackableMerge skipped - target 0x{targetObjectId:X8}({targetCount}) is full (max={maxStack})"); return false; } amount = Math.Min(sourceCount, room); @@ -401,7 +401,7 @@ internal static class ClientHelperHooks try { byte rv = _eventStackableMerge(sourceObjectId, targetObjectId, amount); - RynthLog.Compat($"Compat: Event_StackableMerge from=0x{sourceObjectId:X8}({sourceCount}) to=0x{targetObjectId:X8}({targetCount}) amount={amount}/{maxStack} rv={rv}"); + RynthLog.Verbose($"Compat: Event_StackableMerge from=0x{sourceObjectId:X8}({sourceCount}) to=0x{targetObjectId:X8}({targetCount}) amount={amount}/{maxStack} rv={rv}"); return rv != 0; } catch (Exception ex) @@ -622,7 +622,7 @@ internal static class ClientHelperHooks if (line.Length == 0) return false; - RynthLog.Compat($"Compat: InvokeParser text='{line}'"); + RynthLog.Verbose($"Compat: InvokeParser text='{line}'"); return ChatCommandDispatcher.Dispatch(line); } catch (Exception ex) @@ -673,7 +673,7 @@ internal static class ClientHelperHooks return; _interactionLogCount++; - RynthLog.Compat($"Compat: {message}"); + RynthLog.Verbose($"Compat: {message}"); } private static uint ReadUInt32(int address) diff --git a/src/RynthCore.Engine/Compatibility/ClientObjectHooks.cs b/src/RynthCore.Engine/Compatibility/ClientObjectHooks.cs index e182f03..346da27 100644 --- a/src/RynthCore.Engine/Compatibility/ClientObjectHooks.cs +++ b/src/RynthCore.Engine/Compatibility/ClientObjectHooks.cs @@ -296,7 +296,7 @@ internal static class ClientObjectHooks { IsInitialized = true; _statusMessage = "Ready."; - RynthLog.Compat($"Compat: client objects ready - smartbox candidates={SmartBoxLocator.CandidateCount}"); + RynthLog.Verbose($"Compat: client objects ready - smartbox candidates={SmartBoxLocator.CandidateCount}"); } else @@ -364,7 +364,7 @@ internal static class ClientObjectHooks _inqAttribute = Marshal.GetDelegateForFunctionPointer(new IntPtr(ReferenceInqAttribute)); _isSpellKnown = Marshal.GetDelegateForFunctionPointer(new IntPtr(ReferenceIsSpellKnown)); _getVitaeValue = Marshal.GetDelegateForFunctionPointer(new IntPtr(ReferenceGetVitaeValue)); - RynthLog.Compat( + RynthLog.Verbose( $"Compat: client object hooks ready - getWeenie=0x{getWeeniePtr.ToInt32():X8}, getNameStatic=0x{getNameStaticPtr.ToInt32():X8}, getNameInstance=0x{getNameInstancePtr.ToInt32():X8}"); return true; } @@ -447,7 +447,7 @@ internal static class ClientObjectHooks if (knownPtr == IntPtr.Zero || _getWeenieObject == null) { _weenieQualitiesOffset = FallbackWeenieQualitiesOffset; - RynthLog.Compat($"Compat: qualitiesOffsetProbe no known ptr, using fallback +0x{FallbackWeenieQualitiesOffset:X3}"); + RynthLog.Verbose($"Compat: qualitiesOffsetProbe no known ptr, using fallback +0x{FallbackWeenieQualitiesOffset:X3}"); return; } @@ -455,7 +455,7 @@ internal static class ClientObjectHooks if (playerId == 0) { _weenieQualitiesOffset = FallbackWeenieQualitiesOffset; - RynthLog.Compat($"Compat: qualitiesOffsetProbe playerId==0, using fallback +0x{FallbackWeenieQualitiesOffset:X3}"); + RynthLog.Verbose($"Compat: qualitiesOffsetProbe playerId==0, using fallback +0x{FallbackWeenieQualitiesOffset:X3}"); return; } @@ -465,7 +465,7 @@ internal static class ClientObjectHooks if (weeniePtr == IntPtr.Zero) { _weenieQualitiesOffset = FallbackWeenieQualitiesOffset; - RynthLog.Compat($"Compat: qualitiesOffsetProbe weenie null, using fallback +0x{FallbackWeenieQualitiesOffset:X3}"); + RynthLog.Verbose($"Compat: qualitiesOffsetProbe weenie null, using fallback +0x{FallbackWeenieQualitiesOffset:X3}"); return; } @@ -478,7 +478,7 @@ internal static class ClientObjectHooks if (val == target) { _weenieQualitiesOffset = scan; - RynthLog.Compat($"Compat: qualitiesOffsetProbe found m_pQualities at +0x{scan:X3} (player=0x{playerId:X8})"); + RynthLog.Verbose($"Compat: qualitiesOffsetProbe found m_pQualities at +0x{scan:X3} (player=0x{playerId:X8})"); return; } } @@ -486,7 +486,7 @@ internal static class ClientObjectHooks } _weenieQualitiesOffset = FallbackWeenieQualitiesOffset; - RynthLog.Compat($"Compat: qualitiesOffsetProbe no match, using fallback +0x{FallbackWeenieQualitiesOffset:X3} (player=0x{playerId:X8})"); + RynthLog.Verbose($"Compat: qualitiesOffsetProbe no match, using fallback +0x{FallbackWeenieQualitiesOffset:X3} (player=0x{playerId:X8})"); } catch { @@ -510,7 +510,7 @@ internal static class ClientObjectHooks else { _weenieQualitiesOffset = FallbackWeenieQualitiesOffset; - RynthLog.Compat($"Compat: TryGetQualitiesPtr - no probe ptr, using fallback +0x{FallbackWeenieQualitiesOffset:X3}"); + RynthLog.Verbose($"Compat: TryGetQualitiesPtr - no probe ptr, using fallback +0x{FallbackWeenieQualitiesOffset:X3}"); } } @@ -553,7 +553,7 @@ internal static class ClientObjectHooks { if (!TryGetObjectQualitiesPtr(objectId, out IntPtr qualitiesPtr)) { - RynthLog.Compat($"TryGetObjectSkill: m_pQualities null for 0x{objectId:X8}"); + RynthLog.Verbose($"TryGetObjectSkill: m_pQualities null for 0x{objectId:X8}"); return false; } @@ -566,7 +566,7 @@ internal static class ClientObjectHooks if (_skillProbeLogCount < 6) { _skillProbeLogCount++; - RynthLog.Compat( + RynthLog.Verbose( $"Compat: skillTableProbe obj=0x{objectId:X8} skill={skillStype} qualities=0x{qualitiesPtr.ToInt32():X8} " + $"table=0x{skillTablePtr.ToInt32():X8} buckets={tableSize} training={training} base={buffed}"); } @@ -801,7 +801,7 @@ internal static class ClientObjectHooks IntPtr weeniePtr = _getWeenieObject!(objectId); if (weeniePtr == IntPtr.Zero) { - RynthLog.Compat($"TryGetObjectSkill: GetWeenieObject(0x{objectId:X8}) returned null"); + RynthLog.Verbose($"TryGetObjectSkill: GetWeenieObject(0x{objectId:X8}) returned null"); return false; } @@ -1516,7 +1516,7 @@ internal static class ClientObjectHooks if (playerWeenie == IntPtr.Zero) { - RynthLog.Compat($"Compat: physOffsetProbe - GetWeenieObject returned null for player 0x{playerId:X8}"); + RynthLog.Verbose($"Compat: physOffsetProbe - GetWeenieObject returned null for player 0x{playerId:X8}"); return; } @@ -1540,12 +1540,12 @@ internal static class ClientObjectHooks if (foundOffset >= 0) { _weeniePhysicsObjOffset = foundOffset; - RynthLog.Compat($"Compat: physOffsetProbe discovered _phys_obj at +0x{foundOffset:X2} (player=0x{playerId:X8})"); + RynthLog.Verbose($"Compat: physOffsetProbe discovered _phys_obj at +0x{foundOffset:X2} (player=0x{playerId:X8})"); } else { _weeniePhysicsObjOffset = FallbackWeeniePhysicsObjOffset; - RynthLog.Compat($"Compat: physOffsetProbe no match found, using fallback +0x{FallbackWeeniePhysicsObjOffset:X2} (player=0x{playerId:X8})"); + RynthLog.Verbose($"Compat: physOffsetProbe no match found, using fallback +0x{FallbackWeeniePhysicsObjOffset:X2} (player=0x{playerId:X8})"); } } @@ -1597,6 +1597,6 @@ internal static class ClientObjectHooks return; _lookupLogCount++; - RynthLog.Compat(message); + RynthLog.Verbose(message); } } diff --git a/src/RynthCore.Engine/Compatibility/CombatActionHooks.cs b/src/RynthCore.Engine/Compatibility/CombatActionHooks.cs index 57877eb..83a65b6 100644 --- a/src/RynthCore.Engine/Compatibility/CombatActionHooks.cs +++ b/src/RynthCore.Engine/Compatibility/CombatActionHooks.cs @@ -32,6 +32,13 @@ internal static class CombatActionHooks [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate bool CastSpellDelegate(uint targetId, int spellId); + // Chorizite-style: ClientMagicSystem::CastSpell(uint spellId, byte targetIsSelected) + // VA 0x00568DE0 — static Cdecl. The client uses the currently selected target. + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void CastSpellClientDelegate(uint spellId, byte targetIsSelected); + + private const int ClientMagicSystemCastSpellVa = 0x00568DE0; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint QueryHealthResponseDelegate(IntPtr uiQueueManager, IntPtr buffer, uint size); @@ -53,6 +60,7 @@ internal static class CombatActionHooks private static QueryHealthDelegate? _queryHealth; private static RequestIdDelegate? _requestId; private static CastSpellDelegate? _castSpell; + private static CastSpellClientDelegate? _castSpellClient; private static QueryHealthResponseDelegate? _queryHealthResponseDetour; private static QueryHealthResponseDelegate? _originalQueryHealthResponse; private static QueryHealthResponseDelegate? _identifyObjectDetour; @@ -157,7 +165,7 @@ internal static class CombatActionHooks { castSpellOff = off; castSpellFuncOff = funcOff; - RynthLog.Compat($"Compat: CastSpell candidate opcode=0x{candidate[2]:X2} matched at text+0x{off:X}"); + RynthLog.Verbose($"Compat: CastSpell candidate opcode=0x{candidate[2]:X2} matched at text+0x{off:X}"); break; } } @@ -198,7 +206,7 @@ internal static class CombatActionHooks { int requestIdVa = textSection.TextBaseVa + requestIdFuncOff; _requestId = Marshal.GetDelegateForFunctionPointer(new IntPtr(requestIdVa)); - RynthLog.Compat($"Compat: RequestId (IdentifyObject 0xC8) found at 0x{requestIdVa:X8}"); + RynthLog.Verbose($"Compat: RequestId (IdentifyObject 0xC8) found at 0x{requestIdVa:X8}"); } else { @@ -209,20 +217,34 @@ internal static class CombatActionHooks { int castSpellVa = textSection.TextBaseVa + castSpellFuncOff; _castSpell = Marshal.GetDelegateForFunctionPointer(new IntPtr(castSpellVa)); - RynthLog.Compat($"Compat: CastSpell (0x4A) found at 0x{castSpellVa:X8}"); + RynthLog.Verbose($"Compat: CastSpell (0x4A) found at 0x{castSpellVa:X8}"); } else { RynthLog.Compat("Compat: CastSpell (0x4A) not found — magic combat unavailable."); } + // ClientMagicSystem::CastSpell — direct VA from Chorizite. + // Static Cdecl: void CastSpell(uint spellId, byte targetIsSelected) + // Uses the currently selected target (from SelectItem). + if (SmartBoxLocator.IsPointerInModule(new IntPtr(ClientMagicSystemCastSpellVa))) + { + _castSpellClient = Marshal.GetDelegateForFunctionPointer( + new IntPtr(ClientMagicSystemCastSpellVa)); + RynthLog.Verbose($"Compat: ClientMagicSystem::CastSpell bound at 0x{ClientMagicSystemCastSpellVa:X8}"); + } + else + { + RynthLog.Compat("Compat: ClientMagicSystem::CastSpell VA outside module — unavailable."); + } + InstallQueryHealthResponseHook(); InstallInnerDispatcherHook(); IsInitialized = true; _statusMessage = "Ready."; - RynthLog.Compat($"Compat: combat hooks ready - cancel=0x{cancelVa:X8}, mode=0x{changeModeVa:X8}, health=0x{queryHealthVa:X8}, melee=0x{meleeVa:X8}, missile=0x{missileVa:X8}"); + RynthLog.Verbose($"Compat: combat hooks ready - cancel=0x{cancelVa:X8}, mode=0x{changeModeVa:X8}, health=0x{queryHealthVa:X8}, melee=0x{meleeVa:X8}, missile=0x{missileVa:X8}"); return true; } catch (Exception ex) @@ -326,7 +348,27 @@ internal static class CombatActionHooks public static bool CastSpell(uint targetId, int spellId) { - if (_castSpell == null || targetId == 0 || spellId <= 0) + if (spellId <= 0) return false; + + // Prefer ClientMagicSystem::CastSpell — initiates the full client-side + // cast sequence (animation, state, network). The target must already be + // selected via SelectItem before calling this. + if (_castSpellClient != null) + { + try + { + byte targetIsSelected = targetId != 0 ? (byte)1 : (byte)0; + _castSpellClient((uint)spellId, targetIsSelected); + return true; + } + catch + { + // Fall through to game action method + } + } + + // Fallback: direct game action 0x4A (network message only) + if (_castSpell == null || targetId == 0) return false; try @@ -358,6 +400,7 @@ internal static class CombatActionHooks _queryHealth = null; _requestId = null; _castSpell = null; + _castSpellClient = null; _queryHealthResponseDetour = null; _originalQueryHealthResponse = null; _identifyObjectDetour = null; @@ -418,7 +461,7 @@ internal static class CombatActionHooks } int funcEntryVa = textBase + subEspOff; - RynthLog.Compat($"Compat: inner dispatcher entry @ 0x{funcEntryVa:X8}"); + RynthLog.Verbose($"Compat: inner dispatcher entry @ 0x{funcEntryVa:X8}"); try { @@ -426,7 +469,7 @@ internal static class CombatActionHooks { delegate* unmanaged[Thiscall] pDetour = &InnerDispatcherDetour; MinHook.Hook(new IntPtr(funcEntryVa), (IntPtr)pDetour, out _originalInnerDispatcherPtr); - RynthLog.Compat($"Compat: inner dispatcher hook installed @ 0x{funcEntryVa:X8}"); + RynthLog.Verbose($"Compat: inner dispatcher hook installed @ 0x{funcEntryVa:X8}"); } } catch (Exception ex) @@ -616,7 +659,7 @@ internal static class CombatActionHooks _originalQueryHealthResponse = Marshal.GetDelegateForFunctionPointer(originalPtr); Thread.MemoryBarrier(); MinHook.Enable(responsePtr); - RynthLog.Compat($"Compat: query-health-response hook ready - Handle_Combat__QueryHealthResponse=0x{QueryHealthResponseVa:X8}"); + RynthLog.Verbose($"Compat: query-health-response hook ready - Handle_Combat__QueryHealthResponse=0x{QueryHealthResponseVa:X8}"); } private static uint QueryHealthResponseDetour(IntPtr uiQueueManager, IntPtr buffer, uint size) diff --git a/src/RynthCore.Engine/Compatibility/CombatModeHooks.cs b/src/RynthCore.Engine/Compatibility/CombatModeHooks.cs index 64df2c1..42ec818 100644 --- a/src/RynthCore.Engine/Compatibility/CombatModeHooks.cs +++ b/src/RynthCore.Engine/Compatibility/CombatModeHooks.cs @@ -87,7 +87,7 @@ internal static class CombatModeHooks IsInstalled = true; _statusMessage = $"Hooked ClientCombatSystem::SetCombatMode @ 0x{_targetAddress.ToInt32():X8}."; - RynthLog.Compat($"Compat: combat-mode hook ready - SetCombatMode=0x{_targetAddress.ToInt32():X8}, firstByte=0x{firstByte:X2}"); + RynthLog.Verbose($"Compat: combat-mode hook ready - SetCombatMode=0x{_targetAddress.ToInt32():X8}, firstByte=0x{firstByte:X2}"); } catch (Exception ex) { diff --git a/src/RynthCore.Engine/Compatibility/CommandInterpreterHooks.cs b/src/RynthCore.Engine/Compatibility/CommandInterpreterHooks.cs index 0883b1c..956a644 100644 --- a/src/RynthCore.Engine/Compatibility/CommandInterpreterHooks.cs +++ b/src/RynthCore.Engine/Compatibility/CommandInterpreterHooks.cs @@ -14,10 +14,16 @@ internal static class CommandInterpreterHooks private const int ReferenceCommandInterpreterSetAutoRun = 0x006B5790; private const int ReferenceCommandInterpreterStopCompletely = 0x006B4A90; private const int ReferenceCommandInterpreterTurnToHeading = 0x006B54B0; + private const int ReferenceCommandInterpreterPlayerTeleported = 0x006B41F0; + private const int ReferenceCommandInterpreterTakeControlFromServer = 0x006B4210; + private const int ReferenceCommandInterpreterClearAllCommands = 0x006B40E0; private const int SetMotionOffsetFromCommenceJump = ReferenceAccCmdInterpSetMotion - ReferenceAccCmdInterpCommenceJump; private const int SetMotionOffsetFromDoJump = ReferenceAccCmdInterpSetMotion - ReferenceAccCmdInterpDoJump; private const int StopCompletelyOffsetFromSetAutoRun = ReferenceCommandInterpreterStopCompletely - ReferenceCommandInterpreterSetAutoRun; private const int TurnToHeadingOffsetFromSetAutoRun = ReferenceCommandInterpreterTurnToHeading - ReferenceCommandInterpreterSetAutoRun; + private const int PlayerTeleportedOffsetFromSetAutoRun = ReferenceCommandInterpreterPlayerTeleported - ReferenceCommandInterpreterSetAutoRun; + private const int TakeControlOffsetFromSetAutoRun = ReferenceCommandInterpreterTakeControlFromServer - ReferenceCommandInterpreterSetAutoRun; + private const int ClearAllCommandsOffsetFromSetAutoRun = ReferenceCommandInterpreterClearAllCommands - ReferenceCommandInterpreterSetAutoRun; [UnmanagedFunctionPointer(CallingConvention.ThisCall)] private delegate void CommenceJumpDelegate(IntPtr thisPtr); @@ -37,6 +43,15 @@ internal static class CommandInterpreterHooks [UnmanagedFunctionPointer(CallingConvention.ThisCall)] private delegate void TurnToHeadingDelegate(IntPtr thisPtr, float headingDegrees); + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + private delegate void PlayerTeleportedDelegate(IntPtr thisPtr); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + private delegate void TakeControlFromServerDelegate(IntPtr thisPtr); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + private delegate void ClearAllCommandsDelegate(IntPtr thisPtr); + private static IntPtr _smartboxStaticAddr; private static IntPtr _boundCmdInterp; private static CommenceJumpDelegate? _commenceJump; @@ -45,6 +60,9 @@ internal static class CommandInterpreterHooks private static SetMotionDelegate? _setMotion; private static StopCompletelyDelegate? _stopCompletely; private static TurnToHeadingDelegate? _turnToHeading; + private static PlayerTeleportedDelegate? _playerTeleported; + private static TakeControlFromServerDelegate? _takeControlFromServer; + private static ClearAllCommandsDelegate? _clearAllCommands; private static string _statusMessage = "Not probed yet."; public static bool IsInitialized { get; private set; } @@ -53,6 +71,8 @@ internal static class CommandInterpreterHooks public static bool HasSetMotion => _setMotion != null; public static bool HasStopCompletely => _stopCompletely != null; public static bool HasTurnToHeading => _turnToHeading != null; + public static bool HasTakeControlFromServer => _takeControlFromServer != null; + public static bool HasClearAllCommands => _clearAllCommands != null; public static string StatusMessage => _statusMessage; public static bool Probe() @@ -73,20 +93,15 @@ internal static class CommandInterpreterHooks return false; } - RynthLog.Compat($"Compat: command interpreter found {SmartBoxLocator.CandidateCount} SmartBox candidate(s)."); - if (!TryBindDelegates()) { if (string.IsNullOrEmpty(_statusMessage)) _statusMessage = "cmdinterp unavailable."; - - RynthLog.Compat($"Compat: command interpreter probe pending - {_statusMessage}"); return false; } IsInitialized = true; _statusMessage = "Ready."; - RynthLog.Compat($"Compat: command interpreter hooks ready - smartbox=0x{_smartboxStaticAddr.ToInt32():X8}, cmdinterp=0x{_boundCmdInterp.ToInt32():X8}"); return true; } catch (Exception ex) @@ -162,6 +177,54 @@ internal static class CommandInterpreterHooks } } + public static bool PlayerTeleported() + { + if (!TryBindDelegates() || _playerTeleported == null) + return false; + + try + { + _playerTeleported(_boundCmdInterp); + return true; + } + catch + { + return false; + } + } + + public static bool TakeControlFromServer() + { + if (!TryBindDelegates() || _takeControlFromServer == null) + return false; + + try + { + _takeControlFromServer(_boundCmdInterp); + return true; + } + catch + { + return false; + } + } + + public static bool ClearAllCommands() + { + if (!TryBindDelegates() || _clearAllCommands == null) + return false; + + try + { + _clearAllCommands(_boundCmdInterp); + return true; + } + catch + { + return false; + } + } + public static bool TapJump() { if (!TryBindDelegates()) @@ -191,7 +254,6 @@ internal static class CommandInterpreterHooks if (!SmartBoxLocator.TryGetSmartBox(out smartBox, out selectedStaticAddr, out string smartBoxFailure)) { _statusMessage = smartBoxFailure; - RynthLog.Compat($"Compat: command interpreter bind pending - {_statusMessage}"); return false; } @@ -200,12 +262,7 @@ internal static class CommandInterpreterHooks cmdInterp = Marshal.ReadIntPtr(smartBox + SmartBoxLocator.SmartBoxCmdInterpOffset); if (cmdInterp == IntPtr.Zero) { - uint playerId = unchecked((uint)Marshal.ReadInt32(smartBox + SmartBoxLocator.SmartBoxPlayerIdOffset)); - IntPtr player = Marshal.ReadIntPtr(smartBox + SmartBoxLocator.SmartBoxPlayerOffset); - _statusMessage = playerId != 0 || player != IntPtr.Zero - ? $"CommandInterpreter not ready (playerId=0x{playerId:X8}, player=0x{player.ToInt32():X8})." - : "SmartBox active but player not ready."; - RynthLog.Compat($"Compat: command interpreter bind pending - {_statusMessage}"); + _statusMessage = "SmartBox active but CommandInterpreter not ready."; return false; } @@ -213,14 +270,12 @@ internal static class CommandInterpreterHooks if (!SmartBoxLocator.IsPointerInModule(vtable)) { _statusMessage = $"CommandInterpreter vtable looks invalid (0x{vtable.ToInt32():X8})."; - RynthLog.Compat($"Compat: command interpreter bind failed - {_statusMessage}"); return false; } } catch (Exception ex) { _statusMessage = ex.Message; - RynthLog.Compat($"Compat: command interpreter bind pending - {_statusMessage}"); return false; } @@ -230,7 +285,10 @@ internal static class CommandInterpreterHooks _setAutoRun != null && _setMotion != null && _stopCompletely != null && - _turnToHeading != null) + _turnToHeading != null && + _playerTeleported != null && + _takeControlFromServer != null && + _clearAllCommands != null) { _smartboxStaticAddr = selectedStaticAddr; IsInitialized = true; @@ -244,17 +302,21 @@ internal static class CommandInterpreterHooks IntPtr setMotionPtr = ResolveSetMotionPointer(commenceJumpPtr, doJumpPtr); IntPtr stopCompletelyPtr = AddOffset(setAutoRunPtr, StopCompletelyOffsetFromSetAutoRun); IntPtr turnToHeadingPtr = AddOffset(setAutoRunPtr, TurnToHeadingOffsetFromSetAutoRun); + IntPtr playerTeleportedPtr = AddOffset(setAutoRunPtr, PlayerTeleportedOffsetFromSetAutoRun); + IntPtr takeControlPtr = AddOffset(setAutoRunPtr, TakeControlOffsetFromSetAutoRun); + IntPtr clearAllCommandsPtr = AddOffset(setAutoRunPtr, ClearAllCommandsOffsetFromSetAutoRun); if (!SmartBoxLocator.IsPointerInModule(commenceJumpPtr) || !SmartBoxLocator.IsPointerInModule(doJumpPtr) || !SmartBoxLocator.IsPointerInModule(setAutoRunPtr) || !SmartBoxLocator.IsPointerInModule(setMotionPtr) || !SmartBoxLocator.IsPointerInModule(stopCompletelyPtr) || - !SmartBoxLocator.IsPointerInModule(turnToHeadingPtr)) + !SmartBoxLocator.IsPointerInModule(turnToHeadingPtr) || + !SmartBoxLocator.IsPointerInModule(playerTeleportedPtr) || + !SmartBoxLocator.IsPointerInModule(takeControlPtr) || + !SmartBoxLocator.IsPointerInModule(clearAllCommandsPtr)) { - _statusMessage = - $"CommandInterpreter pointers look invalid (commence=0x{commenceJumpPtr.ToInt32():X8}, doJump=0x{doJumpPtr.ToInt32():X8}, autorun=0x{setAutoRunPtr.ToInt32():X8}, setMotion=0x{setMotionPtr.ToInt32():X8}, stop=0x{stopCompletelyPtr.ToInt32():X8}, turn=0x{turnToHeadingPtr.ToInt32():X8})."; - RynthLog.Compat($"Compat: command interpreter bind failed - {_statusMessage}"); + _statusMessage = "CommandInterpreter pointers look invalid."; return false; } @@ -264,13 +326,15 @@ internal static class CommandInterpreterHooks _setMotion = Marshal.GetDelegateForFunctionPointer(setMotionPtr); _stopCompletely = Marshal.GetDelegateForFunctionPointer(stopCompletelyPtr); _turnToHeading = Marshal.GetDelegateForFunctionPointer(turnToHeadingPtr); + _playerTeleported = Marshal.GetDelegateForFunctionPointer(playerTeleportedPtr); + _takeControlFromServer = Marshal.GetDelegateForFunctionPointer(takeControlPtr); + _clearAllCommands = Marshal.GetDelegateForFunctionPointer(clearAllCommandsPtr); _smartboxStaticAddr = selectedStaticAddr; _boundCmdInterp = cmdInterp; IsInitialized = true; _statusMessage = "Ready."; - RynthLog.Compat( - $"Compat: command interpreter bound - smartboxStatic=0x{selectedStaticAddr.ToInt32():X8}, smartbox=0x{smartBox.ToInt32():X8}, cmdinterp=0x{cmdInterp.ToInt32():X8}, setMotion=0x{setMotionPtr.ToInt32():X8}, stop=0x{stopCompletelyPtr.ToInt32():X8}, turn=0x{turnToHeadingPtr.ToInt32():X8}, autorun=0x{setAutoRunPtr.ToInt32():X8}"); + RynthLog.Verbose("Compat: command interpreter bound"); return true; } @@ -296,6 +360,9 @@ internal static class CommandInterpreterHooks _setMotion = null; _stopCompletely = null; _turnToHeading = null; + _playerTeleported = null; + _takeControlFromServer = null; + _clearAllCommands = null; IsInitialized = false; _statusMessage = "Not probed yet."; } diff --git a/src/RynthCore.Engine/Compatibility/CreateObjectHooks.cs b/src/RynthCore.Engine/Compatibility/CreateObjectHooks.cs index 0759aeb..c2579d0 100644 --- a/src/RynthCore.Engine/Compatibility/CreateObjectHooks.cs +++ b/src/RynthCore.Engine/Compatibility/CreateObjectHooks.cs @@ -59,7 +59,7 @@ internal static class CreateObjectHooks IsInstalled = true; _statusMessage = $"Hooked ACCObjectMaint::CreateObject @ 0x{_targetAddress.ToInt32():X8}."; - RynthLog.Compat($"Compat: create-object hook ready - CreateObject=0x{_targetAddress.ToInt32():X8}"); + RynthLog.Verbose($"Compat: create-object hook ready - CreateObject=0x{_targetAddress.ToInt32():X8}"); } catch (Exception ex) { @@ -76,7 +76,7 @@ internal static class CreateObjectHooks int count = Interlocked.Increment(ref _dispatchCount); if (count <= 0) - RynthLog.Compat($"Compat: create object #{count} id=0x{objectId:X8} ptr=0x{result.ToInt32():X8}"); + RynthLog.Verbose($"Compat: create object #{count} id=0x{objectId:X8} ptr=0x{result.ToInt32():X8}"); PluginManager.QueueCreateObject(objectId); AutoIdService.Enqueue(objectId); diff --git a/src/RynthCore.Engine/Compatibility/DeleteObjectHooks.cs b/src/RynthCore.Engine/Compatibility/DeleteObjectHooks.cs index b23bbd4..ba83b9f 100644 --- a/src/RynthCore.Engine/Compatibility/DeleteObjectHooks.cs +++ b/src/RynthCore.Engine/Compatibility/DeleteObjectHooks.cs @@ -58,7 +58,7 @@ internal static class DeleteObjectHooks IsInstalled = true; _statusMessage = $"Hooked ACCObjectMaint::DeleteObject @ 0x{_targetAddress.ToInt32():X8}."; - RynthLog.Compat($"Compat: delete-object hook ready - DeleteObject=0x{_targetAddress.ToInt32():X8}"); + RynthLog.Verbose($"Compat: delete-object hook ready - DeleteObject=0x{_targetAddress.ToInt32():X8}"); } catch (Exception ex) { diff --git a/src/RynthCore.Engine/Compatibility/DoMotionHooks.cs b/src/RynthCore.Engine/Compatibility/DoMotionHooks.cs index 864b9e9..c8239a0 100644 --- a/src/RynthCore.Engine/Compatibility/DoMotionHooks.cs +++ b/src/RynthCore.Engine/Compatibility/DoMotionHooks.cs @@ -89,7 +89,7 @@ internal static class DoMotionHooks _hookInstalled = true; _statusMessage = $"Hooked CPhysicsObj::DoMotion @ 0x{targetAddress.ToInt32():X8}."; - RynthLog.Compat($"Compat: do-motion hook ready @ 0x{targetAddress.ToInt32():X8}, firstByte=0x{firstByte:X2}"); + RynthLog.Verbose($"Compat: do-motion hook ready @ 0x{targetAddress.ToInt32():X8}, firstByte=0x{firstByte:X2}"); } catch (Exception ex) { diff --git a/src/RynthCore.Engine/Compatibility/EnchantmentHooks.cs b/src/RynthCore.Engine/Compatibility/EnchantmentHooks.cs index b7b4735..e7611ac 100644 --- a/src/RynthCore.Engine/Compatibility/EnchantmentHooks.cs +++ b/src/RynthCore.Engine/Compatibility/EnchantmentHooks.cs @@ -63,7 +63,7 @@ internal static class EnchantmentHooks if (_initialized) return true; _initialized = true; - RynthLog.Compat("Compat: enchantment reader ready (hookless, CACQualities+0x70)"); + RynthLog.Verbose("Compat: enchantment reader ready (hookless, CACQualities+0x70)"); return true; } @@ -85,7 +85,7 @@ internal static class EnchantmentHooks if (!_loggedFirstRead && count > 0) { _loggedFirstRead = true; - RynthLog.Compat($"[EnchRead] first player read: {count} enchantments"); + RynthLog.Verbose($"[EnchRead] first player read: {count} enchantments"); } return count; diff --git a/src/RynthCore.Engine/Compatibility/LoginLifecycleHooks.cs b/src/RynthCore.Engine/Compatibility/LoginLifecycleHooks.cs index c424c5c..81ba67c 100644 --- a/src/RynthCore.Engine/Compatibility/LoginLifecycleHooks.cs +++ b/src/RynthCore.Engine/Compatibility/LoginLifecycleHooks.cs @@ -49,7 +49,7 @@ internal static class LoginLifecycleHooks { int imageSize = textSection.ImageSize; if (imageSize != ExpectedImageSize) - RynthLog.Compat($"Compat: login lifecycle hook using unverified acclient image size 0x{imageSize:X} (expected 0x{ExpectedImageSize:X})."); + RynthLog.Verbose($"Compat: login lifecycle hook using unverified acclient image size 0x{imageSize:X} (expected 0x{ExpectedImageSize:X})."); int callSiteOff = PatternScanner.FindPattern(textSection.Bytes, SendLoginCompletePattern); if (callSiteOff < 0) @@ -82,7 +82,7 @@ internal static class LoginLifecycleHooks IsInstalled = true; _statusMessage = $"Hooked SendLoginCompleteNotification @ 0x{_targetAddress.ToInt32():X8}."; _nextStatusLogTick = Environment.TickCount64 + 3000; - RynthLog.Compat( + RynthLog.Verbose( $"Compat: login lifecycle hook ready - SendLoginCompleteNotification=0x{_targetAddress.ToInt32():X8}, callSite=0x{textSection.TextBaseVa + callSiteOff:X8}"); } catch (Exception ex) @@ -105,7 +105,7 @@ internal static class LoginLifecycleHooks if (!_waitingLogged) { _waitingLogged = true; - RynthLog.Compat("Compat: login lifecycle awaiting SendLoginCompleteNotification."); + RynthLog.Verbose("Compat: login lifecycle awaiting SendLoginCompleteNotification."); } } @@ -122,7 +122,7 @@ internal static class LoginLifecycleHooks HasObservedLoginComplete = true; _statusMessage = $"Login complete observed via {source}."; - RynthLog.Compat($"Compat: login complete observed via {source}."); + RynthLog.Verbose($"Compat: login complete observed via {source}."); LoginComplete?.Invoke(); } } diff --git a/src/RynthCore.Engine/Compatibility/LogoBypassHooks.cs b/src/RynthCore.Engine/Compatibility/LogoBypassHooks.cs index bbe16d9..9eb8a8b 100644 --- a/src/RynthCore.Engine/Compatibility/LogoBypassHooks.cs +++ b/src/RynthCore.Engine/Compatibility/LogoBypassHooks.cs @@ -68,7 +68,7 @@ internal static class LogoBypassHooks if (LoginLifecycleHooks.HasObservedLoginComplete) { - RynthLog.Compat("LogoBypass: Login already complete at start - skipping."); + RynthLog.Verbose("LogoBypass: Login already complete at start - skipping."); return; } @@ -87,7 +87,7 @@ internal static class LogoBypassHooks }; thread.Start(); - RynthLog.Compat("LogoBypass: Started - waiting for post-connect or character-list signal before dismiss clicks."); + RynthLog.Verbose("LogoBypass: Started - waiting for post-connect or character-list signal before dismiss clicks."); } public static void NotifyCharacterListObserved() @@ -121,7 +121,7 @@ internal static class LogoBypassHooks return; } - RynthLog.Compat($"LogoBypass: Found game HWND 0x{hwnd:X8} - awaiting post-connect or character-list signal."); + RynthLog.Verbose($"LogoBypass: Found game HWND 0x{hwnd:X8} - awaiting post-connect or character-list signal."); BypassLoop(hwnd); } @@ -147,7 +147,7 @@ internal static class LogoBypassHooks if (scheduled) { - RynthLog.Compat( + RynthLog.Verbose( $"LogoBypass: {triggerName} observed - scheduling {ScheduledDismissClicks} dismiss click(s) at ({DismissClickX}, {DismissClickY}) with {startDelayMs}ms start delay."); } } @@ -198,7 +198,7 @@ internal static class LogoBypassHooks finally { string reason = LoginLifecycleHooks.HasObservedLoginComplete ? "login complete" : "timeout"; - RynthLog.Compat($"LogoBypass: Stopped ({reason})."); + RynthLog.Verbose($"LogoBypass: Stopped ({reason})."); } } @@ -225,7 +225,7 @@ internal static class LogoBypassHooks PostMessage(hwnd, WM_MOUSEMOVE, IntPtr.Zero, lParam); PostMessage(hwnd, WM_LBUTTONDOWN, (IntPtr)0x0001, lParam); PostMessage(hwnd, WM_LBUTTONUP, IntPtr.Zero, lParam); - RynthLog.Compat($"LogoBypass: Sent dismiss click at ({DismissClickX}, {DismissClickY})."); + RynthLog.Verbose($"LogoBypass: Sent dismiss click at ({DismissClickX}, {DismissClickY})."); } private static IntPtr MakeLParam(int x, int y) => diff --git a/src/RynthCore.Engine/Compatibility/MovementActionHooks.cs b/src/RynthCore.Engine/Compatibility/MovementActionHooks.cs index 47143a8..7fc83fa 100644 --- a/src/RynthCore.Engine/Compatibility/MovementActionHooks.cs +++ b/src/RynthCore.Engine/Compatibility/MovementActionHooks.cs @@ -112,14 +112,14 @@ internal static class MovementActionHooks { int jumpVa = textSection.TextBaseVa + jumpFuncOff; _jumpNonAutonomous = Marshal.GetDelegateForFunctionPointer(new IntPtr(jumpVa)); - RynthLog.Compat($"Compat: movement jump hook ready - jump=0x{jumpVa:X8}"); + RynthLog.Verbose($"Compat: movement jump hook ready - jump=0x{jumpVa:X8}"); } if (autonomyFuncOff >= 0) { int autonomyVa = textSection.TextBaseVa + autonomyFuncOff; _autonomyLevel = Marshal.GetDelegateForFunctionPointer(new IntPtr(autonomyVa)); - RynthLog.Compat($"Compat: movement autonomy hook ready - autonomy=0x{autonomyVa:X8}"); + RynthLog.Verbose($"Compat: movement autonomy hook ready - autonomy=0x{autonomyVa:X8}"); } IsInitialized = true; @@ -127,7 +127,7 @@ internal static class MovementActionHooks ? "Ready." : $"Partial. jump={jumpFuncOff >= 0}, autonomy={autonomyFuncOff >= 0}."; - RynthLog.Compat($"Compat: movement hooks ready - stop=0x{stopVa:X8}, move=0x{doVa:X8}"); + RynthLog.Verbose($"Compat: movement hooks ready - stop=0x{stopVa:X8}, move=0x{doVa:X8}"); return true; } catch (Exception ex) diff --git a/src/RynthCore.Engine/Compatibility/MultiClientHooks.cs b/src/RynthCore.Engine/Compatibility/MultiClientHooks.cs index 6d74a8f..c4bf943 100644 --- a/src/RynthCore.Engine/Compatibility/MultiClientHooks.cs +++ b/src/RynthCore.Engine/Compatibility/MultiClientHooks.cs @@ -63,7 +63,7 @@ internal static class MultiClientHooks if (!allowMultipleClients) { - RynthLog.Compat($"Compat: multi-client bypass skipped - {_statusMessage}"); + RynthLog.Verbose($"Compat: multi-client bypass skipped - {_statusMessage}"); return; } @@ -77,7 +77,7 @@ internal static class MultiClientHooks try { if (textSection.ImageSize != ExpectedImageSize) - RynthLog.Compat($"Compat: multi-client hook using unverified acclient image size 0x{textSection.ImageSize:X} (expected 0x{ExpectedImageSize:X})."); + RynthLog.Verbose($"Compat: multi-client hook using unverified acclient image size 0x{textSection.ImageSize:X} (expected 0x{ExpectedImageSize:X})."); int funcOff = IsAlreadyRunningVa - textSection.TextBaseVa; if (funcOff < 0 || funcOff + IsAlreadyRunningSignature.Length > textSection.Bytes.Length) @@ -147,7 +147,7 @@ internal static class MultiClientHooks MinHook.Enable(_targetAddress); IsAlreadyRunningInstalled = true; - RynthLog.Compat($"Compat: multi-client hook ready - IsAlreadyRunning=0x{IsAlreadyRunningVa:X8}"); + RynthLog.Verbose($"Compat: multi-client hook ready - IsAlreadyRunning=0x{IsAlreadyRunningVa:X8}"); } private static void TryInstallOpenDataFileHook(AcClientTextSection textSection) @@ -177,7 +177,7 @@ internal static class MultiClientHooks MinHook.Enable(_openDataFileAddress); OpenDataFileInstalled = true; - RynthLog.Compat($"Compat: multi-client data-file hook ready - CLBlockAllocator::OpenDataFile=0x{OpenDataFileVa:X8}"); + RynthLog.Verbose($"Compat: multi-client data-file hook ready - CLBlockAllocator::OpenDataFile=0x{OpenDataFileVa:X8}"); } private static byte IsAlreadyRunningDetour(IntPtr thisPtr) diff --git a/src/RynthCore.Engine/Compatibility/PlayerPhysicsHooks.cs b/src/RynthCore.Engine/Compatibility/PlayerPhysicsHooks.cs index 051c0b0..3d73436 100644 --- a/src/RynthCore.Engine/Compatibility/PlayerPhysicsHooks.cs +++ b/src/RynthCore.Engine/Compatibility/PlayerPhysicsHooks.cs @@ -41,7 +41,7 @@ internal static class PlayerPhysicsHooks if (ready) { BindPhysicsDelegates(); - RynthLog.Compat($"Compat: player physics ready - smartbox candidates={SmartBoxLocator.CandidateCount}"); + RynthLog.Verbose($"Compat: player physics ready - smartbox candidates={SmartBoxLocator.CandidateCount}"); } return ready; @@ -276,7 +276,7 @@ internal static class PlayerPhysicsHooks _getHeading = Marshal.GetDelegateForFunctionPointer(getHeadingPtr); _setHeading = Marshal.GetDelegateForFunctionPointer(setHeadingPtr); - RynthLog.Compat( + RynthLog.Verbose( $"Compat: player heading hooks ready - get=0x{getHeadingPtr.ToInt32():X8}, set=0x{setHeadingPtr.ToInt32():X8}"); return true; } diff --git a/src/RynthCore.Engine/Compatibility/PlayerVitalsHooks.cs b/src/RynthCore.Engine/Compatibility/PlayerVitalsHooks.cs index d01c17f..f1c1259 100644 --- a/src/RynthCore.Engine/Compatibility/PlayerVitalsHooks.cs +++ b/src/RynthCore.Engine/Compatibility/PlayerVitalsHooks.cs @@ -120,7 +120,7 @@ internal static class PlayerVitalsHooks IsInstalled = true; _statusMessage = "Hooks installed."; - RynthLog.Compat($"Compat: player vitals hooks ready - update=0x{UpdateAttribute2ndVa:X8}, level=0x{UpdateAttribute2ndLevelVa:X8}, private=0x{PrivateUpdateAttribute2ndVa:X8}, privateLevel=0x{PrivateUpdateAttribute2ndLevelVa:X8}, stat=0x{OnStatUpdatedIntVa:X8}, playerDesc=0x{SendNoticePlayerDescReceivedVa:X8}"); + RynthLog.Verbose($"Compat: player vitals hooks ready - update=0x{UpdateAttribute2ndVa:X8}, level=0x{UpdateAttribute2ndLevelVa:X8}, private=0x{PrivateUpdateAttribute2ndVa:X8}, privateLevel=0x{PrivateUpdateAttribute2ndLevelVa:X8}, stat=0x{OnStatUpdatedIntVa:X8}, playerDesc=0x{SendNoticePlayerDescReceivedVa:X8}"); } catch (Exception ex) { @@ -211,7 +211,7 @@ internal static class PlayerVitalsHooks MaxStamina = maxStamina > 0 ? maxStamina : _snapshot.MaxStamina, MaxMana = maxMana > 0 ? maxMana : _snapshot.MaxMana }; - RynthLog.Compat($"Compat: player max vitals from identify hp={maxHealth} st={maxStamina} mn={maxMana}"); + RynthLog.Verbose($"Compat: player max vitals from identify hp={maxHealth} st={maxStamina} mn={maxMana}"); } } @@ -234,7 +234,7 @@ internal static class PlayerVitalsHooks if (derivedMax > _snapshot.MaxHealth) { _snapshot = _snapshot with { MaxHealth = derivedMax }; - RynthLog.Compat($"Compat: player MaxHealth derived from ratio={healthRatio:0.000} hp={_snapshot.Health} → max={derivedMax}"); + RynthLog.Verbose($"Compat: player MaxHealth derived from ratio={healthRatio:0.000} hp={_snapshot.Health} → max={derivedMax}"); } } } @@ -369,7 +369,7 @@ internal static class PlayerVitalsHooks { _updateLogCount++; string scope = isPrivate ? "private" : $"sender=0x{sender:X8}"; - RynthLog.Compat($"Compat: player vital update #{_updateLogCount} {scope} stype={stype} value={value}"); + RynthLog.Verbose($"Compat: player vital update #{_updateLogCount} {scope} stype={stype} value={value}"); } } @@ -422,7 +422,7 @@ internal static class PlayerVitalsHooks if (changed && _seedLogCount < 1) { _seedLogCount++; - RynthLog.Compat($"Compat: player vitals seeded from player desc #{_seedLogCount} hp={health}/{maxHealth} st={stamina}/{maxStamina} mn={mana}/{maxMana}"); + RynthLog.Verbose($"Compat: player vitals seeded from player desc #{_seedLogCount} hp={health}/{maxHealth} st={stamina}/{maxStamina} mn={mana}/{maxMana}"); } } diff --git a/src/RynthCore.Engine/Compatibility/PropertyUpdateHooks.cs b/src/RynthCore.Engine/Compatibility/PropertyUpdateHooks.cs index a826c58..90fe456 100644 --- a/src/RynthCore.Engine/Compatibility/PropertyUpdateHooks.cs +++ b/src/RynthCore.Engine/Compatibility/PropertyUpdateHooks.cs @@ -148,7 +148,7 @@ internal static class PropertyUpdateHooks _statusMessage = _hookInstalled ? $"{_hookCount}/5 hooks installed." : "All hooks failed."; - RynthLog.Compat($"Compat: property-update hooks — {_statusMessage}"); + RynthLog.Verbose($"Compat: property-update hooks — {_statusMessage}"); } // --- Hook installation helpers --- @@ -181,7 +181,7 @@ internal static class PropertyUpdateHooks MinHook.Enable(target); _hookCount++; - RynthLog.Compat($"Compat: {name} hooked @ 0x{target.ToInt32():X8}"); + RynthLog.Verbose($"Compat: {name} hooked @ 0x{target.ToInt32():X8}"); } catch (Exception ex) { @@ -216,7 +216,7 @@ internal static class PropertyUpdateHooks MinHook.Enable(target); _hookCount++; - RynthLog.Compat($"Compat: BeingDeleted hooked @ 0x{target.ToInt32():X8}"); + RynthLog.Verbose($"Compat: BeingDeleted hooked @ 0x{target.ToInt32():X8}"); } catch (Exception ex) { diff --git a/src/RynthCore.Engine/Compatibility/RawPacketHooks.cs b/src/RynthCore.Engine/Compatibility/RawPacketHooks.cs index 16be92d..698f74a 100644 --- a/src/RynthCore.Engine/Compatibility/RawPacketHooks.cs +++ b/src/RynthCore.Engine/Compatibility/RawPacketHooks.cs @@ -49,7 +49,7 @@ internal static class RawPacketHooks delegate* unmanaged[Stdcall] pDetour = &RecvFromDetour; MinHook.Hook(recvFromAddr, (IntPtr)pDetour, out _originalRecvFromPtr); IsInstalled = true; - RynthLog.Compat($"RawPacket: RecvFrom hook installed @ 0x{recvFromAddr.ToInt32():X8}"); + RynthLog.Verbose($"RawPacket: RecvFrom hook installed @ 0x{recvFromAddr.ToInt32():X8}"); } catch (Exception ex) { diff --git a/src/RynthCore.Engine/Compatibility/SalvageHooks.cs b/src/RynthCore.Engine/Compatibility/SalvageHooks.cs index 3c2f7c1..3990b79 100644 --- a/src/RynthCore.Engine/Compatibility/SalvageHooks.cs +++ b/src/RynthCore.Engine/Compatibility/SalvageHooks.cs @@ -79,7 +79,7 @@ internal static class SalvageHooks _hookInstalled = true; _statusMessage = $"Hooked gmSalvageUI::OpenSalvagePanel @ 0x{targetAddress.ToInt32():X8}."; - RynthLog.Compat($"Compat: salvage hook ready @ 0x{targetAddress.ToInt32():X8}, firstByte=0x{firstByte:X2}"); + RynthLog.Verbose($"Compat: salvage hook ready @ 0x{targetAddress.ToInt32():X8}, firstByte=0x{firstByte:X2}"); } catch (Exception ex) { diff --git a/src/RynthCore.Engine/Compatibility/SelectedTargetHooks.cs b/src/RynthCore.Engine/Compatibility/SelectedTargetHooks.cs index 3bb97ce..e3e6ea6 100644 --- a/src/RynthCore.Engine/Compatibility/SelectedTargetHooks.cs +++ b/src/RynthCore.Engine/Compatibility/SelectedTargetHooks.cs @@ -59,7 +59,7 @@ internal static class SelectedTargetHooks IsInstalled = true; _statusMessage = $"Hooked ACCWeenieObject::SetSelectedObject @ 0x{_targetAddress.ToInt32():X8}."; - RynthLog.Compat( + RynthLog.Verbose( $"Compat: selected-target hook ready - SetSelectedObject=0x{_targetAddress.ToInt32():X8}, selectedId=0x{SelectedIdVa:X8}"); } catch (Exception ex) diff --git a/src/RynthCore.Engine/Compatibility/SessionStateRegistry.cs b/src/RynthCore.Engine/Compatibility/SessionStateRegistry.cs index 0aaddf5..e75dd1d 100644 --- a/src/RynthCore.Engine/Compatibility/SessionStateRegistry.cs +++ b/src/RynthCore.Engine/Compatibility/SessionStateRegistry.cs @@ -68,7 +68,7 @@ internal static class SessionStateRegistry CharacterCacheStore.UpsertCharacter(accountName, serverName, characterName); _loginRecorded = true; - RynthLog.Compat($"SessionState: recorded login session for PID {Environment.ProcessId} account='{accountName}' character='{characterName}'."); + RynthLog.Verbose($"SessionState: recorded login session for PID {Environment.ProcessId} account='{accountName}' character='{characterName}'."); } catch (Exception ex) { diff --git a/src/RynthCore.Engine/Compatibility/SmartBoxHooks.cs b/src/RynthCore.Engine/Compatibility/SmartBoxHooks.cs index ec22973..9893f0b 100644 --- a/src/RynthCore.Engine/Compatibility/SmartBoxHooks.cs +++ b/src/RynthCore.Engine/Compatibility/SmartBoxHooks.cs @@ -74,7 +74,7 @@ internal static class SmartBoxHooks { delegate* unmanaged[Thiscall] pSbDetour = &DispatchSmartBoxEventDetour; MinHook.Hook(sbAddr, (IntPtr)pSbDetour, out _originalDispatchSmartBoxEventPtr); - RynthLog.Compat($"Compat: smartbox hook ready @ 0x{sbAddr.ToInt32():X8}"); + RynthLog.Verbose($"Compat: smartbox hook ready @ 0x{sbAddr.ToInt32():X8}"); } } else RynthLog.Compat("Compat: smartbox pattern not found."); @@ -88,7 +88,7 @@ internal static class SmartBoxHooks { delegate* unmanaged[Thiscall] pGeDetour = &DispatchGameEventDetour; MinHook.Hook(geAddr, (IntPtr)pGeDetour, out _originalDispatchGameEventPtr); - RynthLog.Compat($"Compat: game-event hook ready @ 0x{geAddr.ToInt32():X8}"); + RynthLog.Verbose($"Compat: game-event hook ready @ 0x{geAddr.ToInt32():X8}"); } else RynthLog.Compat("Compat: game-event pattern matched already-hooked address."); } @@ -267,7 +267,7 @@ internal static class SmartBoxHooks int count = Interlocked.Increment(ref _identifyLogCount); if (count <= 12) - RynthLog.Compat($"Compat: identify 0xC9 obj=0x{objectId:X8} maxHealth={maxHealth}"); + RynthLog.Verbose($"Compat: identify 0xC9 obj=0x{objectId:X8} maxHealth={maxHealth}"); } } catch diff --git a/src/RynthCore.Engine/Compatibility/SmartBoxSetStateHooks.cs b/src/RynthCore.Engine/Compatibility/SmartBoxSetStateHooks.cs index f890caa..7276cc2 100644 --- a/src/RynthCore.Engine/Compatibility/SmartBoxSetStateHooks.cs +++ b/src/RynthCore.Engine/Compatibility/SmartBoxSetStateHooks.cs @@ -53,7 +53,7 @@ internal static class SmartBoxSetStateHooks // Physics state is now read directly from CPhysicsObj+0xA8 via TryGetObjectPhysicsState. // Hook not installed; TryGetObjectState remains available for future use. _statusMessage = "Disabled — using direct CPhysicsObj state read instead."; - RynthLog.Compat("Compat: smartbox-setstate hook skipped — direct read via CPhysicsObj+0xA8 in use."); + RynthLog.Verbose("Compat: smartbox-setstate hook skipped — direct read via CPhysicsObj+0xA8 in use."); } /// @@ -74,7 +74,7 @@ internal static class SmartBoxSetStateHooks int n = Interlocked.Increment(ref _debugLogCount); if (n <= 60) - RynthLog.Compat($"SetState#{n} obj=0x{objectId:X8} state=0x{newState:X8}"); + RynthLog.Verbose($"SetState#{n} obj=0x{objectId:X8} state=0x{newState:X8}"); } catch { } diff --git a/src/RynthCore.Engine/Compatibility/TeleportStateHooks.cs b/src/RynthCore.Engine/Compatibility/TeleportStateHooks.cs index 2996810..a7de9a6 100644 --- a/src/RynthCore.Engine/Compatibility/TeleportStateHooks.cs +++ b/src/RynthCore.Engine/Compatibility/TeleportStateHooks.cs @@ -41,6 +41,6 @@ internal static class TeleportStateHooks // Called from EntryPoint.Initialize chain — nothing to install for a direct read. public static void Initialize() { - RynthLog.Compat($"Compat: teleport-state ready — direct read CPlayerSystem+0x238 @ PlayerSystemPtr=0x{PlayerSystemPtrVa:X8}"); + RynthLog.Verbose($"Compat: teleport-state ready — direct read CPlayerSystem+0x238 @ PlayerSystemPtr=0x{PlayerSystemPtrVa:X8}"); } } diff --git a/src/RynthCore.Engine/Compatibility/TimeSyncHooks.cs b/src/RynthCore.Engine/Compatibility/TimeSyncHooks.cs index a86867c..9c490c4 100644 --- a/src/RynthCore.Engine/Compatibility/TimeSyncHooks.cs +++ b/src/RynthCore.Engine/Compatibility/TimeSyncHooks.cs @@ -71,7 +71,7 @@ internal static class TimeSyncHooks } _initialized = true; - RynthLog.Compat($"Compat: time-sync hook ready - HandleTimeSynch=0x{HandleTimeSynchVa:X8}"); + RynthLog.Verbose($"Compat: time-sync hook ready - HandleTimeSynch=0x{HandleTimeSynchVa:X8}"); } catch (Exception ex) { diff --git a/src/RynthCore.Engine/Compatibility/UiLifecycleHooks.cs b/src/RynthCore.Engine/Compatibility/UiLifecycleHooks.cs index ed40309..1b8e552 100644 --- a/src/RynthCore.Engine/Compatibility/UiLifecycleHooks.cs +++ b/src/RynthCore.Engine/Compatibility/UiLifecycleHooks.cs @@ -68,14 +68,14 @@ internal static class UiLifecycleHooks _statusMessage = $"Hooked SetUIReady @ 0x{_targetAddress.ToInt32():X8}."; _nextStatusLogTick = Environment.TickCount64 + 3000; - RynthLog.Compat( + RynthLog.Verbose( $"Compat: UI lifecycle hook ready - SetUIReady=0x{_targetAddress.ToInt32():X8}, uiReadyFlag=0x{_uiReadyFlagAddress.ToInt32():X8}"); if (_uiReadyFlagAddress != IntPtr.Zero && Marshal.ReadInt32(_uiReadyFlagAddress) != 0) { HasObservedUiInitialized = true; _statusMessage = "UI ready already active (late attach)."; - RynthLog.Compat("Compat: UI lifecycle already active at inject time."); + RynthLog.Verbose("Compat: UI lifecycle already active at inject time."); } } catch (Exception ex) @@ -98,7 +98,7 @@ internal static class UiLifecycleHooks if (!_waitingLogged) { _waitingLogged = true; - RynthLog.Compat("Compat: UI lifecycle awaiting SetUIReady(1)."); + RynthLog.Verbose("Compat: UI lifecycle awaiting SetUIReady(1)."); } } @@ -116,7 +116,7 @@ internal static class UiLifecycleHooks HasObservedUiInitialized = true; _statusMessage = $"UI initialized observed via {source}."; - RynthLog.Compat($"Compat: UI initialized observed via {source}."); + RynthLog.Verbose($"Compat: UI initialized observed via {source}."); UiInitialized?.Invoke(); } } diff --git a/src/RynthCore.Engine/Compatibility/UpdateObjectInventoryHooks.cs b/src/RynthCore.Engine/Compatibility/UpdateObjectInventoryHooks.cs index 6286972..9dd2865 100644 --- a/src/RynthCore.Engine/Compatibility/UpdateObjectInventoryHooks.cs +++ b/src/RynthCore.Engine/Compatibility/UpdateObjectInventoryHooks.cs @@ -69,7 +69,7 @@ internal static class UpdateObjectInventoryHooks _statusMessage = $"Hooked ACCObjectMaint::UpdateObjectInventory @ 0x{_targetAddress.ToInt32():X8}" + $"{(updateUsedScan ? " (pattern)" : string.Empty)}."; - RynthLog.Compat($"Compat: update-object-inventory hook ready - {_statusMessage}"); + RynthLog.Verbose($"Compat: update-object-inventory hook ready - {_statusMessage}"); } catch (Exception ex) { @@ -124,7 +124,7 @@ internal static class UpdateObjectInventoryHooks if (_hasLoggedVtableScan) return; _hasLoggedVtableScan = true; - RynthLog.Compat($"Compat: === Vtable scan of weenie 0x{containerId:X8} at 0x{weeniePtr.ToInt32():X8} ==="); + RynthLog.Verbose($"Compat: === Vtable scan of weenie 0x{containerId:X8} at 0x{weeniePtr.ToInt32():X8} ==="); for (int off = 0; off < 0x80; off += 4) { try @@ -132,7 +132,7 @@ internal static class UpdateObjectInventoryHooks IntPtr addr = weeniePtr + off; if (!IsReadablePointer(addr)) { - RynthLog.Compat($"Compat: +0x{off:X2} UNREADABLE"); + RynthLog.Verbose($"Compat: +0x{off:X2} UNREADABLE"); continue; } @@ -141,15 +141,15 @@ internal static class UpdateObjectInventoryHooks bool readable = val != IntPtr.Zero && IsReadablePointer(val); if (inModule) - RynthLog.Compat($"Compat: +0x{off:X2} = 0x{val.ToInt32():X8} [VTABLE - in module]"); + RynthLog.Verbose($"Compat: +0x{off:X2} = 0x{val.ToInt32():X8} [VTABLE - in module]"); else if (readable && val.ToInt32() > 0x10000) - RynthLog.Compat($"Compat: +0x{off:X2} = 0x{val.ToInt32():X8} [heap ptr]"); + RynthLog.Verbose($"Compat: +0x{off:X2} = 0x{val.ToInt32():X8} [heap ptr]"); else - RynthLog.Compat($"Compat: +0x{off:X2} = 0x{val.ToInt32():X8}"); + RynthLog.Verbose($"Compat: +0x{off:X2} = 0x{val.ToInt32():X8}"); } catch { - RynthLog.Compat($"Compat: +0x{off:X2} ACCESS VIOLATION"); + RynthLog.Verbose($"Compat: +0x{off:X2} ACCESS VIOLATION"); break; } } @@ -158,7 +158,7 @@ internal static class UpdateObjectInventoryHooks try { IntPtr invPtr = Marshal.ReadIntPtr(weeniePtr + WeenieObjectInventoryOffset); - RynthLog.Compat($"Compat: Current WeenieObjectInventoryOffset=0x{WeenieObjectInventoryOffset:X2} -> 0x{invPtr.ToInt32():X8} readable={IsReadablePointer(invPtr)}"); + RynthLog.Verbose($"Compat: Current WeenieObjectInventoryOffset=0x{WeenieObjectInventoryOffset:X2} -> 0x{invPtr.ToInt32():X8} readable={IsReadablePointer(invPtr)}"); } catch (Exception ex) { diff --git a/src/RynthCore.Engine/Compatibility/UpdateObjectServerDispatchHooks.cs b/src/RynthCore.Engine/Compatibility/UpdateObjectServerDispatchHooks.cs index 897cd9b..0c2ed60 100644 --- a/src/RynthCore.Engine/Compatibility/UpdateObjectServerDispatchHooks.cs +++ b/src/RynthCore.Engine/Compatibility/UpdateObjectServerDispatchHooks.cs @@ -60,7 +60,7 @@ internal static class UpdateObjectServerDispatchHooks IsInstalled = true; _statusMessage = $"Hooked CM_Physics::DispatchSB_UpdateObject @ 0x{_targetAddress.ToInt32():X8}."; - RynthLog.Compat($"Compat: update-object hook ready - DispatchSB_UpdateObject=0x{_targetAddress.ToInt32():X8}"); + RynthLog.Verbose($"Compat: update-object hook ready - DispatchSB_UpdateObject=0x{_targetAddress.ToInt32():X8}"); } catch (Exception ex) { @@ -81,7 +81,7 @@ internal static class UpdateObjectServerDispatchHooks int count = Interlocked.Increment(ref _dispatchCount); if (count <= 8) - RynthLog.Compat($"Compat: update object #{count} id=0x{objectId:X8} status={status}"); + RynthLog.Verbose($"Compat: update object #{count} id=0x{objectId:X8} status={status}"); PluginManager.QueueUpdateObject(objectId); return status; diff --git a/src/RynthCore.Engine/Compatibility/VectorUpdateServerDispatchHooks.cs b/src/RynthCore.Engine/Compatibility/VectorUpdateServerDispatchHooks.cs index 4f14c4c..11aab19 100644 --- a/src/RynthCore.Engine/Compatibility/VectorUpdateServerDispatchHooks.cs +++ b/src/RynthCore.Engine/Compatibility/VectorUpdateServerDispatchHooks.cs @@ -57,7 +57,7 @@ internal static class VectorUpdateServerDispatchHooks IsInstalled = true; _statusMessage = $"Hooked CM_Physics::DispatchSB_VectorUpdate @ 0x{_targetAddress.ToInt32():X8}."; - RynthLog.Compat($"Compat: vector-update hook ready - DispatchSB_VectorUpdate=0x{_targetAddress.ToInt32():X8}"); + RynthLog.Verbose($"Compat: vector-update hook ready - DispatchSB_VectorUpdate=0x{_targetAddress.ToInt32():X8}"); } catch (Exception ex) { diff --git a/src/RynthCore.Engine/Compatibility/VendorHooks.cs b/src/RynthCore.Engine/Compatibility/VendorHooks.cs index a2505f4..245033c 100644 --- a/src/RynthCore.Engine/Compatibility/VendorHooks.cs +++ b/src/RynthCore.Engine/Compatibility/VendorHooks.cs @@ -98,7 +98,7 @@ internal static class VendorHooks IsInstalled = true; _statusMessage = $"Hooked vendor @ open=0x{_openAddress.ToInt32():X8} close=0x{_closeAddress.ToInt32():X8}."; - RynthLog.Compat($"Compat: vendor hooks ready - {_statusMessage}"); + RynthLog.Verbose($"Compat: vendor hooks ready - {_statusMessage}"); } catch (Exception ex) { diff --git a/src/RynthCore.Engine/Compatibility/ViewObjectContentsHooks.cs b/src/RynthCore.Engine/Compatibility/ViewObjectContentsHooks.cs index 74a4fae..b6cd753 100644 --- a/src/RynthCore.Engine/Compatibility/ViewObjectContentsHooks.cs +++ b/src/RynthCore.Engine/Compatibility/ViewObjectContentsHooks.cs @@ -88,7 +88,7 @@ internal static class ViewObjectContentsHooks IsInstalled = true; _statusMessage = $"Hooked contents view seams @ 0x{_viewTargetAddress.ToInt32():X8}/0x{_stopTargetAddress.ToInt32():X8}."; - RynthLog.Compat( + RynthLog.Verbose( $"Compat: view-object-contents hooks ready - view=0x{_viewTargetAddress.ToInt32():X8}, stop=0x{_stopTargetAddress.ToInt32():X8}"); } catch (Exception ex) @@ -108,7 +108,7 @@ internal static class ViewObjectContentsHooks int count = Interlocked.Increment(ref _viewDispatchCount); if (count <= 0) - RynthLog.Compat($"Compat: view contents #{count} id=0x{objectId:X8} contents=0x{newContents.ToInt32():X8}"); + RynthLog.Verbose($"Compat: view contents #{count} id=0x{objectId:X8} contents=0x{newContents.ToInt32():X8}"); PluginManager.QueueViewObjectContents(objectId); } @@ -123,7 +123,7 @@ internal static class ViewObjectContentsHooks int count = Interlocked.Increment(ref _stopDispatchCount); if (count <= 5) - RynthLog.Compat($"Compat: stop view contents #{count} id=0x{objectId:X8}"); + RynthLog.Verbose($"Compat: stop view contents #{count} id=0x{objectId:X8}"); PluginManager.QueueStopViewingObjectContents(objectId); } diff --git a/src/RynthCore.Engine/Plugins/PluginContract.cs b/src/RynthCore.Engine/Plugins/PluginContract.cs index 5007f9f..0f44a6a 100644 --- a/src/RynthCore.Engine/Plugins/PluginContract.cs +++ b/src/RynthCore.Engine/Plugins/PluginContract.cs @@ -450,6 +450,11 @@ internal struct RynthCoreAPI /// BF_DOOR = 0x1000, BF_VENDOR = 0x200, BF_CORPSE = 0x2000, etc. /// Returns 0 if the object is not found. public IntPtr GetObjectBitfieldFn; + + /// Function pointer: void ForceResetBusyCount() + /// Force-resets the client's ClientUISystem busy count to zero. + /// Use after portal teleports that interrupt actions and leave the hourglass cursor stuck. + public IntPtr ForceResetBusyCountFn; } @@ -838,3 +843,6 @@ internal unsafe delegate int GetObjectStateCallbackDelegate(uint objectId, uint* [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate uint GetObjectBitfieldCallbackDelegate(uint objectId); + +[UnmanagedFunctionPointer(CallingConvention.Cdecl)] +internal delegate void ForceResetBusyCountCallbackDelegate(); diff --git a/src/RynthCore.Engine/Plugins/PluginManager.cs b/src/RynthCore.Engine/Plugins/PluginManager.cs index 1f9dad6..2bd7cf7 100644 --- a/src/RynthCore.Engine/Plugins/PluginManager.cs +++ b/src/RynthCore.Engine/Plugins/PluginManager.cs @@ -181,6 +181,7 @@ internal static class PluginManager private static GetLastIdTimeCallbackDelegate? _getLastIdTimeCallback; private static GetObjectHeadingCallbackDelegate? _getObjectHeadingCallback; private static GetBusyStateCallbackDelegate? _getBusyStateCallback; + private static ForceResetBusyCountCallbackDelegate? _forceResetBusyCountCallback; private static GetObjectSpellIdsCallbackDelegate? _getObjectSpellIdsCallback; private static GetObjectSkillLevelCallbackDelegate? _getObjectSkillBuffedCallback; private static GetObjectAttributeCallbackDelegate? _getObjectAttributeCallback; @@ -1737,6 +1738,7 @@ internal static class PluginManager _getLastIdTimeCallback ??= GetLastIdTimeAction; _getObjectHeadingCallback ??= GetObjectHeadingAction; _getBusyStateCallback ??= GetBusyStateAction; + _forceResetBusyCountCallback ??= ForceResetBusyCountAction; _getObjectSpellIdsCallback ??= GetObjectSpellIdsAction; _getObjectSkillBuffedCallback ??= GetObjectSkillLevelAction; _getObjectAttributeCallback ??= GetObjectAttributeAction; @@ -1833,6 +1835,7 @@ internal static class PluginManager _api.GetObjectMotionOnFn = Marshal.GetFunctionPointerForDelegate(_getObjectMotionOnCallback); _api.GetObjectStateFn = Marshal.GetFunctionPointerForDelegate(_getObjectStateCallback); _api.GetObjectBitfieldFn = Marshal.GetFunctionPointerForDelegate(_getObjectBitfieldCallback); + _api.ForceResetBusyCountFn = Marshal.GetFunctionPointerForDelegate(_forceResetBusyCountCallback); } private static void ProbeClientHooks() @@ -2049,7 +2052,7 @@ internal static class PluginManager private static unsafe int GetContainerContentsAction(uint containerId, uint* itemIds, int maxCount) { - RynthLog.Compat($"Compat: GetContainerContentsAction ENTRY id=0x{containerId:X8} itemIds=0x{(int)itemIds:X8} maxCount={maxCount}"); + RynthLog.Verbose($"Compat: GetContainerContentsAction ENTRY id=0x{containerId:X8} itemIds=0x{(int)itemIds:X8} maxCount={maxCount}"); if (itemIds == null || maxCount <= 0) return 0; @@ -2379,6 +2382,8 @@ internal static class PluginManager private static int GetBusyStateAction() => BusyCountHooks.GetBusyState(); + private static void ForceResetBusyCountAction() => BusyCountHooks.ForceResetBusyCount(); + private static unsafe int GetObjectSpellIdsAction(uint guid, uint* spellIds, int maxCount) { if (spellIds == null || maxCount <= 0) diff --git a/src/RynthCore.PluginSdk/RynthCoreApiNative.cs b/src/RynthCore.PluginSdk/RynthCoreApiNative.cs index 5aea55f..18183f3 100644 --- a/src/RynthCore.PluginSdk/RynthCoreApiNative.cs +++ b/src/RynthCore.PluginSdk/RynthCoreApiNative.cs @@ -98,4 +98,5 @@ public struct RynthCoreApiNative public IntPtr GetObjectMotionOnFn; public IntPtr GetObjectStateFn; public IntPtr GetObjectBitfieldFn; + public IntPtr ForceResetBusyCountFn; } diff --git a/src/RynthCore.PluginSdk/RynthCoreHost.cs b/src/RynthCore.PluginSdk/RynthCoreHost.cs index 65e9186..59e3ea5 100644 --- a/src/RynthCore.PluginSdk/RynthCoreHost.cs +++ b/src/RynthCore.PluginSdk/RynthCoreHost.cs @@ -61,6 +61,7 @@ public readonly unsafe struct RynthCoreHost public bool HasGetLastIdTime => _api.GetLastIdTimeFn != IntPtr.Zero; public bool HasGetObjectHeading => _api.GetObjectHeadingFn != IntPtr.Zero; public bool HasGetBusyState => _api.GetBusyStateFn != IntPtr.Zero; + public bool HasForceResetBusyCount => _api.ForceResetBusyCountFn != IntPtr.Zero; public bool HasGetObjectSpellIds => _api.GetObjectSpellIdsFn != IntPtr.Zero; public bool HasSetMotion => _api.SetMotionFn != IntPtr.Zero; public bool HasStopCompletely => _api.StopCompletelyFn != IntPtr.Zero; @@ -515,6 +516,12 @@ public readonly unsafe struct RynthCoreHost return ((delegate* unmanaged[Cdecl])_api.GetBusyStateFn)(); } + public void ForceResetBusyCount() + { + if (_api.ForceResetBusyCountFn != IntPtr.Zero) + ((delegate* unmanaged[Cdecl])_api.ForceResetBusyCountFn)(); + } + public bool TryGetObjectName(uint objectId, out string name) { name = string.Empty;