From f4246dbbd04ae21ac7393a7d0c8b1dfa240ec58e Mon Sep 17 00:00:00 2001 From: Tom Bohar Date: Tue, 27 Oct 2026 08:41:02 -0400 Subject: [PATCH] Snapshot for release 2026.10.27.1 (internal ed07fd7) --- .../MainWindow.axaml.cs | 18 ++++++++ .../RynthCore.App.Avalonia.csproj | 1 + src/RynthCore.App/AcWindowRestoreRule.cs | 41 +++++++++++++++++++ .../Compatibility/AcPanels.cs | 3 +- .../Compatibility/AcShortcuts.cs | 12 ++---- .../LauncherSettingsTests.csproj | 1 + tools/LauncherSettingsTests/Program.cs | 20 +++++++++ 7 files changed, 87 insertions(+), 9 deletions(-) create mode 100644 src/RynthCore.App/AcWindowRestoreRule.cs diff --git a/src/RynthCore.App.Avalonia/MainWindow.axaml.cs b/src/RynthCore.App.Avalonia/MainWindow.axaml.cs index c749bd4..f8ad599 100644 --- a/src/RynthCore.App.Avalonia/MainWindow.axaml.cs +++ b/src/RynthCore.App.Avalonia/MainWindow.axaml.cs @@ -84,6 +84,8 @@ internal partial class MainWindow : Window // Last observed window rect per PID — set on first post-login observation, // used to detect an actual move before we commit anything to appsettings. private readonly Dictionary _baselineWindowRects = []; + // When each client's saved window was put back, and the put-backs since (AcWindowRestoreRule). + private readonly Dictionary _windowRestores = []; // Serializes prefs-swap launches so two accounts don't race on the live // UserPreferences.ini. Non-prefs launches don't acquire this and stay // parallel. @@ -3399,6 +3401,8 @@ internal partial class MainWindow : Window _everLoggedInPids.RemoveWhere(pid => !activePids.Contains(pid)); foreach (int pid in _baselineWindowRects.Keys.Where(pid => !activePids.Contains(pid)).ToList()) _baselineWindowRects.Remove(pid); + foreach (int pid in _windowRestores.Keys.Where(pid => !activePids.Contains(pid)).ToList()) + _windowRestores.Remove(pid); // Latch any PID that's currently reporting IsLoggedIn=true. Once // latched, the reaper will permanently exempt it — even if some race @@ -4474,6 +4478,7 @@ internal partial class MainWindow : Window profile.WindowWidth!.Value, profile.WindowHeight!.Value, SWP_NOZORDER | SWP_NOACTIVATE | SWP_ASYNCWINDOWPOS); + _windowRestores[process.Id] = (DateTime.UtcNow, null, 0); LauncherDiag.Info($"WindowPos PID {process.Id} ({accountName}@{serverName}): restored to ({profile.WindowX},{profile.WindowY},{profile.WindowWidth}x{profile.WindowHeight})."); return; } @@ -4557,6 +4562,19 @@ internal partial class MainWindow : Window } if (refW > 0 && refH > 0 && (long)w * h * 2L < (long)refW * refH) { + // Shortly after our restore it is AC shrinking the window back while it brings the character in + // (AcWindowRestoreRule): put the saved window back instead of leaving the game drawn into a small one. + if (hasSaved && _windowRestores.TryGetValue(process.Id, out var rs) + && AcWindowRestoreRule.ShouldReapply(DateTime.UtcNow, rs.At, rs.Last, rs.Count, sess?.LogoutAtUtc != null, + w, h, profile.WindowWidth!.Value, profile.WindowHeight!.Value)) + { + SetWindowPos(hwnd, IntPtr.Zero, profile.WindowX!.Value, profile.WindowY!.Value, + profile.WindowWidth!.Value, profile.WindowHeight!.Value, + SWP_NOZORDER | SWP_NOACTIVATE | SWP_ASYNCWINDOWPOS); + _windowRestores[process.Id] = (rs.At, DateTime.UtcNow, rs.Count + 1); + LauncherDiag.Info($"WindowPos PID {process.Id} ({accountName}@{serverName}): AC shrank it to {w}x{h} after the restore: put back to ({profile.WindowX},{profile.WindowY},{profile.WindowWidth}x{profile.WindowHeight}) (#{rs.Count + 1})."); + return; + } LauncherDiag.Info($"WindowPos PID {process.Id} ({accountName}@{serverName}): ignored char-select/login shrink ({w}x{h}, <50% of in-game {refW}x{refH})."); return; } diff --git a/src/RynthCore.App.Avalonia/RynthCore.App.Avalonia.csproj b/src/RynthCore.App.Avalonia/RynthCore.App.Avalonia.csproj index 68cd1fe..0430f7e 100644 --- a/src/RynthCore.App.Avalonia/RynthCore.App.Avalonia.csproj +++ b/src/RynthCore.App.Avalonia/RynthCore.App.Avalonia.csproj @@ -58,6 +58,7 @@ + diff --git a/src/RynthCore.App/AcWindowRestoreRule.cs b/src/RynthCore.App/AcWindowRestoreRule.cs new file mode 100644 index 0000000..a2da188 --- /dev/null +++ b/src/RynthCore.App/AcWindowRestoreRule.cs @@ -0,0 +1,41 @@ +using System; + +namespace RynthCore.App; + +/// +/// The launcher puts a client's saved window back once, when AC reports the login. AC can still shrink +/// its window to the small login / character-select size afterwards, while it brings the character in, +/// and then draw the game at full size into that small window. Drakkon (2026-10-25 23:04): restored to +/// 1606x929 three seconds after the login, back at 806x629 three seconds later, and left there all +/// night while the game drew 1600x900 into it; the tracker only refused to save that size. For a +/// short while after the restore, a window that collapsed below half the saved area is put back, a few +/// times at most, and never once the client has logged out (that is the real character select). +/// Pure: MainWindow does the window calls. Checked in tools\LauncherSettingsTests. +/// +internal static class AcWindowRestoreRule +{ + /// How long after the restore a login-size window is put back. + public static readonly TimeSpan Watch = TimeSpan.FromSeconds(60); + /// The most times it is put back after one restore. + public const int MaxReapplies = 5; + /// The least time between two put-backs (AC may still be resizing). + public static readonly TimeSpan ReapplyEvery = TimeSpan.FromSeconds(3); + + /// The window collapsed below half the saved in-game area: AC's login / character-select window. + public static bool IsLoginShrink(int width, int height, int savedWidth, int savedHeight) => + savedWidth > 0 && savedHeight > 0 && (long)width * height * 2L < (long)savedWidth * savedHeight; + + /// + /// Put the saved window back now: a login-size window within of the restore, + /// not logged out, fewer than put-backs, the last one at least + /// ago. + /// + public static bool ShouldReapply(DateTime nowUtc, DateTime restoredAtUtc, DateTime? lastReapplyUtc, int reapplies, + bool loggedOut, int width, int height, int savedWidth, int savedHeight) + { + if (loggedOut || reapplies >= MaxReapplies) return false; + if (nowUtc - restoredAtUtc > Watch) return false; + if (lastReapplyUtc is DateTime last && nowUtc - last < ReapplyEvery) return false; + return IsLoginShrink(width, height, savedWidth, savedHeight); + } +} diff --git a/src/RynthCore.Engine/Compatibility/AcPanels.cs b/src/RynthCore.Engine/Compatibility/AcPanels.cs index 8f99298..4c0f3d6 100644 --- a/src/RynthCore.Engine/Compatibility/AcPanels.cs +++ b/src/RynthCore.Engine/Compatibility/AcPanels.cs @@ -218,7 +218,8 @@ internal static unsafe class AcPanels { if (Requests.IsEmpty) return; long now = Environment.TickCount64; - if (PlayerLifecycleLog.HoldQueuedWork(now)) return; + // Not held between worlds: a panel opens and closes in portal space as with AC's own keys + // (held, a click there or just after landing was dropped; Tom 2026-10-23). while (Requests.TryDequeue(out Request r)) { if (now - r.QueuedMs > 3000) continue; diff --git a/src/RynthCore.Engine/Compatibility/AcShortcuts.cs b/src/RynthCore.Engine/Compatibility/AcShortcuts.cs index 5a3ce22..8055802 100644 --- a/src/RynthCore.Engine/Compatibility/AcShortcuts.cs +++ b/src/RynthCore.Engine/Compatibility/AcShortcuts.cs @@ -31,8 +31,7 @@ // clear gmToolbarUI::RemoveShortcutInSlotNum(slot, 1) 0x004BE180, ret 8. // Queued from any thread and run on AC's game thread just before its tick // (GameTickHooks, beside the cast drain: AC's own input -> UseTime order), -// held while the player is between worlds (PlayerLifecycleLog), dropped after -// 6 s. The slots are read on the game thread after the tick, 4 times a second, +// dropped after 6 s. Not held between worlds: the keys aren't either. The slots are read on the game thread after the tick, 4 times a second, // into a snapshot GetShortcuts returns from any thread. // ============================================================================ @@ -184,12 +183,9 @@ internal static unsafe class AcShortcuts { if (Queue.IsEmpty) return; long now = Environment.TickCount64; - if (PlayerLifecycleLog.HoldQueuedWork(now)) - { - // Between worlds: keep them, unless they waited too long. - while (Queue.TryPeek(out Request old) && now - old.QueuedMs > GiveUpMs) Queue.TryDequeue(out _); - return; - } + // Not held between worlds (portal space, the seconds after landing): a slot pressed then does + // what its key does then - AC's own toolbar call, which AC answers or refuses itself. Held, + // a click in portal space did nothing (Tom 2026-10-23). Logout empties the queue (Reset). IntPtr toolbar = RetailToolbarHooks.ShortcutToolbar(); while (Queue.TryDequeue(out Request r)) { diff --git a/tools/LauncherSettingsTests/LauncherSettingsTests.csproj b/tools/LauncherSettingsTests/LauncherSettingsTests.csproj index 10905ab..6be300f 100644 --- a/tools/LauncherSettingsTests/LauncherSettingsTests.csproj +++ b/tools/LauncherSettingsTests/LauncherSettingsTests.csproj @@ -37,6 +37,7 @@ + diff --git a/tools/LauncherSettingsTests/Program.cs b/tools/LauncherSettingsTests/Program.cs index 45afc1e..41c68b4 100644 --- a/tools/LauncherSettingsTests/Program.cs +++ b/tools/LauncherSettingsTests/Program.cs @@ -498,6 +498,26 @@ internal static class Program "expired stays expired through the grace"); Check(CrashDumpWriterRule.Grace == TimeSpan.FromSeconds(60), "the grace is 60 s"); }); + + // Drakkon 2026-10-25 23:04: the saved window was put back 3 s after the login, AC shrank it to its + // login size 3 s later and drew the game at 1600x900 into 806x629 all night. + Scenario("window restore: AC's shrink right after the restore is put back", root, () => + { + var at = new DateTime(2026, 10, 26, 3, 4, 48, DateTimeKind.Utc); + bool Re(double sec, DateTime? last = null, int count = 0, bool loggedOut = false, int w = 806, int h = 629) => + AcWindowRestoreRule.ShouldReapply(at.AddSeconds(sec), at, last, count, loggedOut, w, h, 1606, 929); + Check(Re(3), "806x629 three seconds after the restore: put back"); + Check(!Re(3, w: 1606, h: 929), "the saved size: nothing to do"); + Check(!Re(3, w: 1300, h: 800), "a moderate resize (the player's): left alone"); + Check(!Re(3, loggedOut: true), "logged out (the real character select): left alone"); + Check(!Re(61), "past the minute after the restore: left alone (the tracker only refuses to save it)"); + Check(!Re(5, last: at.AddSeconds(3), count: 1), "two seconds after a put-back: wait (AC may still be resizing)"); + Check(Re(6, last: at.AddSeconds(3), count: 1), "three seconds after: again"); + Check(!Re(30, last: at.AddSeconds(20), count: AcWindowRestoreRule.MaxReapplies), "after MaxReapplies: no more"); + Check(AcWindowRestoreRule.IsLoginShrink(806, 629, 1606, 929) && !AcWindowRestoreRule.IsLoginShrink(1200, 700, 1606, 929), + "login size is under half the saved area"); + Check(!AcWindowRestoreRule.IsLoginShrink(806, 629, 0, 0), "no saved size: never"); + }); } finally {