Snapshot for release 2026.10.27.1 (internal ed07fd7)

This commit is contained in:
Tom Bohar 2026-10-27 08:41:02 -04:00
commit f4246dbbd0
7 changed files with 87 additions and 9 deletions

View file

@ -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<int, (int x, int y, int w, int h)> _baselineWindowRects = [];
// When each client's saved window was put back, and the put-backs since (AcWindowRestoreRule).
private readonly Dictionary<int, (DateTime At, DateTime? Last, int Count)> _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;
}

View file

@ -58,6 +58,7 @@
<Compile Include="..\RynthCore.App\FirstLoginRules.cs" Link="Shared\FirstLoginRules.cs" />
<Compile Include="..\RynthCore.App\AccountServerRules.cs" Link="Shared\AccountServerRules.cs" />
<Compile Include="..\RynthCore.App\CrashDumpWriterRule.cs" Link="Shared\CrashDumpWriterRule.cs" />
<Compile Include="..\RynthCore.App\AcWindowRestoreRule.cs" Link="Shared\AcWindowRestoreRule.cs" />
<Compile Include="..\RynthCore.App\AcClientLaunchSettingsService.cs" Link="Shared\AcClientLaunchSettingsService.cs" />
<Compile Include="..\RynthCore.App\UserPrefsSwapRecovery.cs" Link="Shared\UserPrefsSwapRecovery.cs" />
<Compile Include="..\RynthCore.App\AcClientLoginAutomationService.cs" Link="Shared\AcClientLoginAutomationService.cs" />

View file

@ -0,0 +1,41 @@
using System;
namespace RynthCore.App;
/// <summary>
/// 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.
/// </summary>
internal static class AcWindowRestoreRule
{
/// <summary>How long after the restore a login-size window is put back.</summary>
public static readonly TimeSpan Watch = TimeSpan.FromSeconds(60);
/// <summary>The most times it is put back after one restore.</summary>
public const int MaxReapplies = 5;
/// <summary>The least time between two put-backs (AC may still be resizing).</summary>
public static readonly TimeSpan ReapplyEvery = TimeSpan.FromSeconds(3);
/// <summary>The window collapsed below half the saved in-game area: AC's login / character-select window.</summary>
public static bool IsLoginShrink(int width, int height, int savedWidth, int savedHeight) =>
savedWidth > 0 && savedHeight > 0 && (long)width * height * 2L < (long)savedWidth * savedHeight;
/// <summary>
/// Put the saved window back now: a login-size window within <see cref="Watch"/> of the restore,
/// not logged out, fewer than <see cref="MaxReapplies"/> put-backs, the last one at least
/// <see cref="ReapplyEvery"/> ago.
/// </summary>
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);
}
}

View file

@ -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;

View file

@ -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))
{

View file

@ -37,6 +37,7 @@
<Compile Include="..\..\src\RynthCore.App\AccountServerRules.cs" Link="App\AccountServerRules.cs" />
<Compile Include="..\..\src\RynthCore.App\UserPrefsSwapRecovery.cs" Link="App\UserPrefsSwapRecovery.cs" />
<Compile Include="..\..\src\RynthCore.App\CrashDumpWriterRule.cs" Link="App\CrashDumpWriterRule.cs" />
<Compile Include="..\..\src\RynthCore.App\AcWindowRestoreRule.cs" Link="App\AcWindowRestoreRule.cs" />
</ItemGroup>
</Project>

View file

@ -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
{