fix: SK engine and launcher fixes from 2026-10-14
- fix(engine): DAT share hook now patches only the CreateFile imports of
acclient.exe and MSVCR70.dll instead of hooking kernel32 process-wide, so
Direct3D and driver file opens are no longer routed through the detour
("Could not initialize Direct3D" on some machines). Uninstall restores the
import slots on engine unload.
- fix(launcher): a saved UserPreferences.ini that makes the client exit
within 30 s is quarantined and the previous live file is restored.
- fix(engine): target selects and attacks run during the gesture defer.
- feat(launcher): first login on a new server; pick any character on the
account.
- feat(settings): loot timers show their optimized defaults, with a
"Use optimized defaults" button.
Release notes are in Changelog/2026-10-14-*.md.
This commit is contained in:
parent
e3222805cb
commit
8919f7f169
25 changed files with 1373 additions and 163 deletions
|
|
@ -2,7 +2,7 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="RynthCore.App.Avalonia.AccountProfileDialog"
|
||||
Width="600"
|
||||
Height="620"
|
||||
Height="720"
|
||||
CanResize="False"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Title="Account Profile"
|
||||
|
|
@ -24,6 +24,9 @@
|
|||
<TextBlock x:Name="PasswordHintText"
|
||||
Foreground="#9AA8B3"
|
||||
TextWrapping="Wrap" />
|
||||
<TextBlock Text="Log in as" Foreground="#EAF0F4" />
|
||||
<ComboBox x:Name="LoginAsBox" HorizontalAlignment="Stretch" />
|
||||
<TextBlock x:Name="LoginAsHintText" Foreground="#9AA8B3" TextWrapping="Wrap" />
|
||||
<TextBlock Text="Alias" Foreground="#EAF0F4" />
|
||||
<TextBox x:Name="AliasBox" />
|
||||
|
||||
|
|
|
|||
|
|
@ -12,11 +12,21 @@ internal partial class AccountProfileDialog : Window
|
|||
{
|
||||
private readonly LaunchAccountProfile _profile;
|
||||
private readonly List<LaunchServerProfile> _servers;
|
||||
private readonly Func<string, string, List<string>> _knownCharactersFor;
|
||||
|
||||
public AccountProfileDialog(LaunchAccountProfile profile, List<LaunchServerProfile> servers)
|
||||
private List<string> _knownCharacters = [];
|
||||
// Set once the player picks in "Log in as"; until then the saved choice is kept as it is
|
||||
// (an empty one means "the only character, else character select").
|
||||
private bool _loginAsChanged;
|
||||
private bool _loadingLoginAs;
|
||||
|
||||
/// <param name="knownCharactersFor">(account name, server name) -> the characters known for it.</param>
|
||||
public AccountProfileDialog(LaunchAccountProfile profile, List<LaunchServerProfile> servers,
|
||||
Func<string, string, List<string>> knownCharactersFor)
|
||||
{
|
||||
_profile = profile;
|
||||
_servers = servers;
|
||||
_knownCharactersFor = knownCharactersFor;
|
||||
InitializeComponent();
|
||||
|
||||
ServerComboBox.ItemsSource = _servers.Select(s => s.DisplayName).ToList();
|
||||
|
|
@ -30,15 +40,52 @@ internal partial class AccountProfileDialog : Window
|
|||
PasswordHintText.Text = profile.PasswordNeedsReentry
|
||||
? "Password needs re-entering: the saved one can't be read on this Windows user (settings copied from another user or PC?). Type it again to launch this account."
|
||||
: !profile.HasSavedPassword
|
||||
? "No password is saved for this profile yet."
|
||||
? "No password is saved for this profile yet. The game client won't start without one; you'll be asked for it on the first launch."
|
||||
: "A password is saved for this profile, encrypted for this Windows user. It stays hidden unless you replace or clear it.";
|
||||
|
||||
ServerComboBox.SelectionChanged += (_, _) => RefreshLoginAs();
|
||||
AccountBox.TextChanged += (_, _) => RefreshLoginAs();
|
||||
LoginAsBox.SelectionChanged += (_, _) =>
|
||||
{
|
||||
if (!_loadingLoginAs)
|
||||
_loginAsChanged = true;
|
||||
};
|
||||
RefreshLoginAs();
|
||||
|
||||
SaveButton.Click += (_, _) => SaveAndClose();
|
||||
CancelButton.Click += (_, _) => Close(false);
|
||||
BrowseUserPrefsButton.Click += async (_, _) => await BrowseUserPrefsAsync();
|
||||
SnapshotUserPrefsButton.Click += (_, _) => SnapshotLiveUserPrefs();
|
||||
}
|
||||
|
||||
/// <summary>Lists the characters known for the account on the chosen server in "Log in as".</summary>
|
||||
private void RefreshLoginAs()
|
||||
{
|
||||
string accountName = AccountBox.Text?.Trim() ?? string.Empty;
|
||||
string serverName = ServerComboBox.SelectedIndex >= 0 ? _servers[ServerComboBox.SelectedIndex].Name : string.Empty;
|
||||
_knownCharacters = accountName.Length > 0 ? _knownCharactersFor(accountName, serverName) : [];
|
||||
|
||||
string? current = _loginAsChanged ? LoginAsBox.SelectedItem as string : null;
|
||||
List<string> choices = FirstLoginRules.LoginChoices(_knownCharacters, _profile.CharacterName);
|
||||
|
||||
_loadingLoginAs = true;
|
||||
try
|
||||
{
|
||||
LoginAsBox.ItemsSource = choices;
|
||||
LoginAsBox.SelectedItem = current != null && choices.Contains(current) ? current
|
||||
: choices.Contains(_profile.CharacterName) ? _profile.CharacterName
|
||||
: FirstLoginRules.StopAtCharacterSelect;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_loadingLoginAs = false;
|
||||
}
|
||||
|
||||
LoginAsHintText.Text = _knownCharacters.Count == 0
|
||||
? "No characters are known for this account on this server yet. Launch it: the client stops at character select, where you can create characters, and RynthCore picks them up there."
|
||||
: $"{_knownCharacters.Count} character(s) on this account. Pick the one that logs in automatically, or stop at character select. The launch list's dropdown changes this too.";
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task BrowseUserPrefsAsync()
|
||||
{
|
||||
var topLevel = GetTopLevel(this);
|
||||
|
|
@ -112,10 +159,24 @@ internal partial class AccountProfileDialog : Window
|
|||
return;
|
||||
}
|
||||
|
||||
if (ServerComboBox.SelectedIndex >= 0)
|
||||
_profile.ServerId = _servers[ServerComboBox.SelectedIndex].Id;
|
||||
LaunchServerProfile? server = ServerComboBox.SelectedIndex >= 0 ? _servers[ServerComboBox.SelectedIndex] : null;
|
||||
if (server == null && _servers.Count > 0)
|
||||
{
|
||||
ValidationText.Text = "Pick the server this account is for.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (AcLaunchArgumentBuilder.AccountNameProblem(AccountBox.Text, server?.Emulator ?? AcEmulatorKind.Ace) is string nameProblem)
|
||||
{
|
||||
ValidationText.Text = nameProblem;
|
||||
return;
|
||||
}
|
||||
|
||||
if (server != null)
|
||||
_profile.ServerId = server.Id;
|
||||
_profile.AccountName = AccountBox.Text.Trim();
|
||||
if (_loginAsChanged)
|
||||
_profile.CharacterName = FirstLoginRules.CharacterNameFor(LoginAsBox.SelectedItem as string, _knownCharacters);
|
||||
if (ClearPasswordCheckBox.IsChecked == true)
|
||||
{
|
||||
_profile.ClearPassword();
|
||||
|
|
|
|||
44
src/RynthCore.App.Avalonia/FirstLoginDialog.axaml
Normal file
44
src/RynthCore.App.Avalonia/FirstLoginDialog.axaml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="RynthCore.App.Avalonia.FirstLoginDialog"
|
||||
Width="560"
|
||||
SizeToContent="Height"
|
||||
CanResize="False"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Title="First Login"
|
||||
Background="#132028">
|
||||
<Grid RowDefinitions="*,Auto" Margin="18">
|
||||
<StackPanel Spacing="10">
|
||||
<TextBlock x:Name="HeaderText" Foreground="#EAF0F4" FontSize="16" FontWeight="SemiBold" TextWrapping="Wrap" />
|
||||
<TextBlock x:Name="IntroText" Foreground="#9AA8B3" TextWrapping="Wrap" />
|
||||
|
||||
<TextBlock Text="Use an account you already have (optional)" Foreground="#EAF0F4" />
|
||||
<ComboBox x:Name="KnownAccountBox" HorizontalAlignment="Stretch" PlaceholderText="Pick an account name, or type a new one below" />
|
||||
|
||||
<TextBlock Text="Account" Foreground="#EAF0F4" />
|
||||
<TextBox x:Name="AccountBox" Watermark="A new name creates the account on this server's first login (ACE)" />
|
||||
|
||||
<CheckBox x:Name="ReuseSavedPasswordCheckBox" Foreground="#EAF0F4" IsVisible="False" />
|
||||
|
||||
<StackPanel x:Name="PasswordPanel" Spacing="10">
|
||||
<TextBlock Text="Password" Foreground="#EAF0F4" />
|
||||
<TextBox x:Name="PasswordBox" PasswordChar="*" RevealPassword="False" />
|
||||
<TextBlock Text="Confirm password" Foreground="#EAF0F4" />
|
||||
<TextBox x:Name="ConfirmBox" PasswordChar="*" RevealPassword="False" />
|
||||
</StackPanel>
|
||||
<TextBlock Text="The password is saved encrypted for this Windows user, like the other accounts."
|
||||
Foreground="#9AA8B3" TextWrapping="Wrap" />
|
||||
|
||||
<TextBlock Text="Log in as" Foreground="#EAF0F4" />
|
||||
<ComboBox x:Name="LoginAsBox" HorizontalAlignment="Stretch" />
|
||||
<TextBlock x:Name="LoginAsHintText" Foreground="#9AA8B3" TextWrapping="Wrap" />
|
||||
|
||||
<TextBlock x:Name="ValidationText" Foreground="#E2B348" TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Spacing="8" Margin="0,16,0,0">
|
||||
<Button x:Name="CancelButton" Content="Cancel" />
|
||||
<Button x:Name="LoginButton" Content="Log In" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
122
src/RynthCore.App.Avalonia/FirstLoginDialog.axaml.cs
Normal file
122
src/RynthCore.App.Avalonia/FirstLoginDialog.axaml.cs
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Avalonia.Controls;
|
||||
using RynthCore.App;
|
||||
|
||||
namespace RynthCore.App.Avalonia;
|
||||
|
||||
/// <summary>
|
||||
/// Asked before launching an account that has no usable password (a new server, or a profile added
|
||||
/// without one): the account name (one you already use, or a new one), its password, and which
|
||||
/// character logs in. Edits the profile passed in only when the player presses Log In.
|
||||
/// </summary>
|
||||
internal partial class FirstLoginDialog : Window
|
||||
{
|
||||
private readonly LaunchAccountProfile _profile;
|
||||
private readonly LaunchServerProfile _server;
|
||||
private readonly IReadOnlyList<LaunchAccountProfile> _allProfiles;
|
||||
private readonly Func<string, List<string>> _knownCharactersFor;
|
||||
|
||||
private List<string> _knownCharacters = [];
|
||||
private LaunchAccountProfile? _passwordSource;
|
||||
|
||||
public FirstLoginDialog(
|
||||
LaunchAccountProfile profile,
|
||||
LaunchServerProfile server,
|
||||
IReadOnlyList<LaunchAccountProfile> allProfiles,
|
||||
Func<string, List<string>> knownCharactersFor)
|
||||
{
|
||||
_profile = profile;
|
||||
_server = server;
|
||||
_allProfiles = allProfiles;
|
||||
_knownCharactersFor = knownCharactersFor;
|
||||
InitializeComponent();
|
||||
|
||||
string serverLabel = server.DisplayName;
|
||||
HeaderText.Text = $"First login on {serverLabel}";
|
||||
IntroText.Text = profile.PasswordNeedsReentry
|
||||
? "The saved password for this account can't be read on this Windows user (settings copied from another user or PC?). Enter it again to log in."
|
||||
: "No password is saved for this account yet, and the game client won't start without one. "
|
||||
+ "ACE servers create a new account the first time it logs in (if the server allows it). "
|
||||
+ "With no character picked, the client stops at character select, where you can create characters. "
|
||||
+ "Every character on the account is remembered, and you pick which one logs in from the launch list.";
|
||||
|
||||
KnownAccountBox.ItemsSource = FirstLoginRules.KnownAccountNames(allProfiles, profile.Id);
|
||||
KnownAccountBox.IsEnabled = KnownAccountBox.ItemCount > 0;
|
||||
KnownAccountBox.SelectionChanged += (_, _) =>
|
||||
{
|
||||
if (KnownAccountBox.SelectedItem is string picked)
|
||||
AccountBox.Text = picked;
|
||||
};
|
||||
|
||||
AccountBox.Text = profile.AccountName;
|
||||
AccountBox.TextChanged += (_, _) => OnAccountChanged();
|
||||
ReuseSavedPasswordCheckBox.IsCheckedChanged += (_, _) => UpdatePasswordPanel();
|
||||
|
||||
LoginButton.Click += (_, _) => LogInAndClose();
|
||||
CancelButton.Click += (_, _) => Close(false);
|
||||
|
||||
OnAccountChanged();
|
||||
}
|
||||
|
||||
/// <summary>Re-reads the account's characters and whether another profile's password can be reused.</summary>
|
||||
private void OnAccountChanged()
|
||||
{
|
||||
string name = AccountBox.Text?.Trim() ?? string.Empty;
|
||||
|
||||
_passwordSource = FirstLoginRules.SavedPasswordSource(_allProfiles, name, _profile.Id);
|
||||
if (_passwordSource != null)
|
||||
{
|
||||
string from = _passwordSource.DisplayName;
|
||||
ReuseSavedPasswordCheckBox.Content = $"Use the password saved for '{name}' in profile {from}";
|
||||
ReuseSavedPasswordCheckBox.IsVisible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReuseSavedPasswordCheckBox.IsVisible = false;
|
||||
ReuseSavedPasswordCheckBox.IsChecked = false;
|
||||
}
|
||||
UpdatePasswordPanel();
|
||||
|
||||
_knownCharacters = name.Length > 0 ? _knownCharactersFor(name) : [];
|
||||
string? keep = LoginAsBox.SelectedItem as string;
|
||||
List<string> choices = FirstLoginRules.LoginChoices(_knownCharacters, _profile.CharacterName);
|
||||
LoginAsBox.ItemsSource = choices;
|
||||
LoginAsBox.SelectedItem = keep != null && choices.Contains(keep) ? keep
|
||||
: choices.Contains(_profile.CharacterName) ? _profile.CharacterName
|
||||
: FirstLoginRules.StopAtCharacterSelect;
|
||||
LoginAsHintText.Text = _knownCharacters.Count == 0
|
||||
? $"No characters are known for this account on {_server.DisplayName} yet. Create them at character select; RynthCore picks them up there."
|
||||
: $"{_knownCharacters.Count} character(s) known for this account. Pick one to log in automatically, or stop at character select.";
|
||||
}
|
||||
|
||||
private void UpdatePasswordPanel()
|
||||
{
|
||||
bool reuse = ReuseSavedPasswordCheckBox.IsVisible && ReuseSavedPasswordCheckBox.IsChecked == true;
|
||||
PasswordPanel.IsVisible = !reuse;
|
||||
}
|
||||
|
||||
private void LogInAndClose()
|
||||
{
|
||||
bool reuse = _passwordSource != null && ReuseSavedPasswordCheckBox.IsChecked == true;
|
||||
string name = AccountBox.Text?.Trim() ?? string.Empty;
|
||||
|
||||
if (FirstLoginRules.Problem(name, PasswordBox.Text, ConfirmBox.Text, reuse, _server.Emulator) is string problem)
|
||||
{
|
||||
ValidationText.Text = problem;
|
||||
return;
|
||||
}
|
||||
|
||||
_profile.AccountName = name;
|
||||
_profile.ServerId = _server.Id;
|
||||
if (reuse)
|
||||
_profile.CopyPasswordFrom(_passwordSource!);
|
||||
else
|
||||
_profile.SetPassword(PasswordBox.Text); // encrypted at once; the plain text isn't kept
|
||||
PasswordBox.Text = string.Empty;
|
||||
ConfirmBox.Text = string.Empty;
|
||||
|
||||
_profile.CharacterName = FirstLoginRules.CharacterNameFor(LoginAsBox.SelectedItem as string, _knownCharacters);
|
||||
Close(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -33,6 +33,7 @@ internal partial class MainWindow : Window
|
|||
// handle most of the work; this cooldown is a final belt-and-braces.
|
||||
private static readonly TimeSpan AutoLaunchCooldown = TimeSpan.FromSeconds(2);
|
||||
private static readonly TimeSpan AutoLaunchServerDownLogCooldown = TimeSpan.FromSeconds(30);
|
||||
private static readonly TimeSpan AutoLaunchNeedsPasswordLogCooldown = TimeSpan.FromMinutes(5);
|
||||
|
||||
// Auto-inject only after the external AC client has been continuously
|
||||
// graphics-ready for this long. The window gives Decal/UBLoader time to
|
||||
|
|
@ -90,6 +91,11 @@ internal partial class MainWindow : Window
|
|||
// After CreateProcess+inject+resume, hold the prefs lock this long so AC
|
||||
// has a chance to read UserPreferences.ini before another account swaps.
|
||||
private static readonly TimeSpan UserPrefsSettleDelay = TimeSpan.FromSeconds(2);
|
||||
// The UserPreferences.ini swap each launched PID started with, so a quick exit can set the
|
||||
// saved copy aside and put the previous live file back (UserPrefsSwapRecovery).
|
||||
private readonly Dictionary<int, PrefsSwapLaunch> _prefsSwapByPid = [];
|
||||
// Counts swaps; a quick exit only restores the live file when no later swap replaced it.
|
||||
private long _prefsSwapGeneration;
|
||||
private readonly Dictionary<int, DateTime> _autoInjectFirstReadyAtUtc = [];
|
||||
private readonly HashSet<int> _autoInjectAttemptedPids = [];
|
||||
private readonly HashSet<int> _autoInjectInFlightPids = [];
|
||||
|
|
@ -99,6 +105,7 @@ internal partial class MainWindow : Window
|
|||
private readonly Dictionary<string, ComboBox> _launchTargetInjectionDropdowns = [];
|
||||
private readonly Dictionary<string, DateTime> _autoLaunchAttemptTimesUtc = new(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly Dictionary<string, DateTime> _autoLaunchServerDownNoticeTimesUtc = new(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly Dictionary<string, DateTime> _autoLaunchNeedsPasswordNoticeTimesUtc = new(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly Dictionary<string, ServerAvailabilityState> _serverStatuses = new(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly List<PluginDefinition> _plugins =
|
||||
[
|
||||
|
|
@ -727,8 +734,10 @@ internal partial class MainWindow : Window
|
|||
|
||||
private async System.Threading.Tasks.Task AddAccountAsync()
|
||||
{
|
||||
var draft = new RynthCore.App.LaunchAccountProfile();
|
||||
var dialog = new AccountProfileDialog(draft, _settings.ServerProfiles);
|
||||
// Defaults to the server selected in the list (a new server's first account), not the
|
||||
// first profile, which RefreshLaunchTargets would otherwise assign.
|
||||
var draft = new RynthCore.App.LaunchAccountProfile { ServerId = GetSelectedServer()?.Id ?? string.Empty };
|
||||
var dialog = new AccountProfileDialog(draft, _settings.ServerProfiles, GetDetectedCharacters);
|
||||
bool? accepted = await dialog.ShowDialog<bool?>(this);
|
||||
if (accepted != true)
|
||||
return;
|
||||
|
|
@ -749,7 +758,7 @@ internal partial class MainWindow : Window
|
|||
return;
|
||||
|
||||
LaunchAccountProfile draft = selected.Clone();
|
||||
var dialog = new AccountProfileDialog(draft, _settings.ServerProfiles);
|
||||
var dialog = new AccountProfileDialog(draft, _settings.ServerProfiles, GetDetectedCharacters);
|
||||
bool? accepted = await dialog.ShowDialog<bool?>(this);
|
||||
if (accepted != true)
|
||||
return;
|
||||
|
|
@ -1637,6 +1646,29 @@ internal partial class MainWindow : Window
|
|||
}
|
||||
}
|
||||
|
||||
// No usable password: the client would refuse to start ("You can only run the game from
|
||||
// the launcher program") and exit within seconds. A manual launch asks for it (and the
|
||||
// account) in the First Login dialog; an automatic one skips the account.
|
||||
if (string.IsNullOrWhiteSpace(overrideArguments))
|
||||
{
|
||||
var ready = new List<LaunchAccountProfile>(accountsToLaunch.Count);
|
||||
foreach (LaunchAccountProfile account in accountsToLaunch)
|
||||
{
|
||||
if (!AcLaunchArgumentBuilder.NeedsPassword(account))
|
||||
ready.Add(account);
|
||||
else if (isAutomaticLaunch)
|
||||
AppendActivity($"Auto launch skipped for {account.DisplayName}: {AcLaunchArgumentBuilder.MissingPasswordMessage(account.AccountName)}");
|
||||
else if (await PromptFirstLoginAsync(account))
|
||||
ready.Add(account);
|
||||
else
|
||||
AppendActivity($"Launch cancelled for {account.DisplayName}: no password entered.");
|
||||
}
|
||||
|
||||
if (ready.Count == 0)
|
||||
return;
|
||||
accountsToLaunch = ready;
|
||||
}
|
||||
|
||||
SaveRuntimePaths(appendActivity: !isAutomaticLaunch);
|
||||
SaveLaunchBehavior(appendActivity: !isAutomaticLaunch);
|
||||
|
||||
|
|
@ -1784,10 +1816,7 @@ internal partial class MainWindow : Window
|
|||
|
||||
try
|
||||
{
|
||||
if (needsPrefsSwap)
|
||||
{
|
||||
_launchSettings.SwapUserPreferences(resolvedPrefsPath, _settings.AllowMultipleClients, AppendActivity);
|
||||
}
|
||||
PrefsSwapLaunch? prefsSwap = needsPrefsSwap ? ApplyPrefsSwap(account, launchContext.ServerName, resolvedPrefsPath) : null;
|
||||
|
||||
InjectionResult result = await Task.Run(() =>
|
||||
_injector.LaunchSuspendedAndInject(
|
||||
|
|
@ -1811,6 +1840,7 @@ internal partial class MainWindow : Window
|
|||
{
|
||||
_launchedSessionPids.Add(trackedPid);
|
||||
_launchedPidInfo[trackedPid] = (accountKey, DateTime.UtcNow);
|
||||
TrackPrefsSwap(trackedPid, prefsSwap);
|
||||
RegisterPidExitWatch(trackedPid);
|
||||
}
|
||||
|
||||
|
|
@ -1864,10 +1894,7 @@ internal partial class MainWindow : Window
|
|||
|
||||
try
|
||||
{
|
||||
if (needsPrefsSwap)
|
||||
{
|
||||
_launchSettings.SwapUserPreferences(resolvedPrefsPath, _settings.AllowMultipleClients, AppendActivity);
|
||||
}
|
||||
PrefsSwapLaunch? prefsSwap = needsPrefsSwap ? ApplyPrefsSwap(account, launchContext.ServerName, resolvedPrefsPath) : null;
|
||||
|
||||
// enginePath != null: "Decal + RynthCore" - Decal is injected first, then the
|
||||
// RynthCore loader, before the client resumes.
|
||||
|
|
@ -1894,6 +1921,7 @@ internal partial class MainWindow : Window
|
|||
{
|
||||
_launchedSessionPids.Add(trackedPid);
|
||||
_launchedPidInfo[trackedPid] = (accountKey, DateTime.UtcNow);
|
||||
TrackPrefsSwap(trackedPid, prefsSwap);
|
||||
RegisterPidExitWatch(trackedPid);
|
||||
}
|
||||
|
||||
|
|
@ -1943,10 +1971,7 @@ internal partial class MainWindow : Window
|
|||
|
||||
try
|
||||
{
|
||||
if (needsPrefsSwap)
|
||||
{
|
||||
_launchSettings.SwapUserPreferences(resolvedPrefsPath, _settings.AllowMultipleClients, AppendActivity);
|
||||
}
|
||||
PrefsSwapLaunch? prefsSwap = needsPrefsSwap ? ApplyPrefsSwap(account, launchContext.ServerName, resolvedPrefsPath) : null;
|
||||
|
||||
Process? proc = null;
|
||||
Exception? launchEx = null;
|
||||
|
|
@ -1978,6 +2003,7 @@ internal partial class MainWindow : Window
|
|||
{
|
||||
_launchedSessionPids.Add(proc.Id);
|
||||
_launchedPidInfo[proc.Id] = (BuildAccountKey(launchContext.AccountName, launchContext.ServerName), DateTime.UtcNow);
|
||||
TrackPrefsSwap(proc.Id, prefsSwap);
|
||||
RegisterPidExitWatch(proc.Id);
|
||||
LaunchContextStore.WriteForProcess(proc.Id, launchContext);
|
||||
WritePendingSessionState(proc.Id, launchContext);
|
||||
|
|
@ -2004,6 +2030,38 @@ internal partial class MainWindow : Window
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the First Login dialog for <paramref name="account"/> (no usable password). True when
|
||||
/// the player entered one: the profile is updated and saved (password encrypted at once).
|
||||
/// </summary>
|
||||
private async Task<bool> PromptFirstLoginAsync(LaunchAccountProfile account)
|
||||
{
|
||||
LaunchServerProfile? server = ResolveServerForAccount(account);
|
||||
if (server == null)
|
||||
{
|
||||
AppendActivity($"Launch blocked for {account.DisplayName}: add a server profile first.");
|
||||
return false;
|
||||
}
|
||||
|
||||
LaunchAccountProfile draft = account.Clone();
|
||||
var dialog = new FirstLoginDialog(draft, server, _settings.AccountProfiles,
|
||||
accountName => GetDetectedCharacters(accountName, server.Name));
|
||||
bool? accepted = await dialog.ShowDialog<bool?>(this);
|
||||
if (accepted != true)
|
||||
return false;
|
||||
|
||||
account.CopyFrom(draft);
|
||||
SaveSettings();
|
||||
RefreshLists();
|
||||
RefreshSummary();
|
||||
|
||||
string loginAs = string.IsNullOrWhiteSpace(account.CharacterName) || account.CharacterName == LaunchAccountProfile.NoneOption
|
||||
? "stopping at character select"
|
||||
: $"logging in as {account.CharacterName}";
|
||||
AppendActivity($"First login on {server.DisplayName}: account '{account.AccountName}', password saved (encrypted), {loginAs}.");
|
||||
return true;
|
||||
}
|
||||
|
||||
private LaunchContextRecord BuildLaunchContext(LaunchAccountProfile account, LaunchServerProfile? server)
|
||||
{
|
||||
string targetCharacter = ResolveTargetCharacterForLaunch(account, server);
|
||||
|
|
@ -3856,6 +3914,7 @@ internal partial class MainWindow : Window
|
|||
AppendActivity($"Account '{entry.Value.AccountKey}' client (PID {entry.Key}) exited after {uptime.TotalSeconds:F0}s — counted as crash.");
|
||||
int hist = _crashHistoryByAccount.TryGetValue(entry.Value.AccountKey, out List<DateTime>? h) ? h.Count : 0;
|
||||
LauncherDiag.Info($"DetectQuickExits: PID {entry.Key} ({entry.Value.AccountKey}) uptime={uptime.TotalSeconds:F1}s -> RecordCrash. crashHist now {hist}.");
|
||||
RecoverFailedPrefsSwap(entry.Key, entry.Value.AccountKey, uptime);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(entry.Value.AccountKey))
|
||||
{
|
||||
|
|
@ -3872,6 +3931,7 @@ internal partial class MainWindow : Window
|
|||
foreach (int pid in toRemove)
|
||||
{
|
||||
_launchedPidInfo.Remove(pid);
|
||||
_prefsSwapByPid.Remove(pid);
|
||||
// Drop the exit-watcher Process handle so the OS can reclaim
|
||||
// the kernel object. Exited already fired (or never will),
|
||||
// so we no longer need to hold the handle alive.
|
||||
|
|
@ -4212,17 +4272,14 @@ internal partial class MainWindow : Window
|
|||
if (!string.IsNullOrWhiteSpace(account.UserPrefsPath))
|
||||
return account.UserPrefsPath.Trim();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(account.AccountName))
|
||||
string legacyPath = ResolveLegacyUserPrefsPath(account);
|
||||
if (string.IsNullOrEmpty(legacyPath))
|
||||
return string.Empty;
|
||||
|
||||
string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
string prefsDir = Path.Combine(appdata, "RynthCore", "prefs");
|
||||
string safeName = SafePrefsFileName(account.AccountName);
|
||||
string legacyPath = Path.Combine(prefsDir, $"{safeName}.ini");
|
||||
if (string.IsNullOrWhiteSpace(serverName))
|
||||
return legacyPath;
|
||||
|
||||
string scopedPath = Path.Combine(prefsDir, $"{safeName}@{SafePrefsFileName(serverName)}.ini");
|
||||
string prefsDir = Path.GetDirectoryName(legacyPath)!;
|
||||
string scopedPath = Path.Combine(prefsDir, $"{SafePrefsFileName(account.AccountName)}@{SafePrefsFileName(serverName)}.ini");
|
||||
if (!File.Exists(scopedPath) && File.Exists(legacyPath))
|
||||
{
|
||||
try { File.Copy(legacyPath, scopedPath, overwrite: false); }
|
||||
|
|
@ -4232,9 +4289,98 @@ internal partial class MainWindow : Window
|
|||
return scopedPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The account's old name-only stash (%APPDATA%\RynthCore\prefs\name.ini), which seeds a
|
||||
/// missing per-server one. Empty when the account has no name yet.
|
||||
/// </summary>
|
||||
private static string ResolveLegacyUserPrefsPath(LaunchAccountProfile account)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(account.AccountName))
|
||||
return string.Empty;
|
||||
|
||||
string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
return Path.Combine(appdata, "RynthCore", "prefs", $"{SafePrefsFileName(account.AccountName)}.ini");
|
||||
}
|
||||
|
||||
private static string SafePrefsFileName(string name) =>
|
||||
string.Join("_", name.Trim().Split(Path.GetInvalidFileNameChars()));
|
||||
|
||||
/// <summary>
|
||||
/// A launch's UserPreferences.ini swap. <see cref="IsProfileOverride"/>: the stash is a file the
|
||||
/// user picked on the profile (never renamed by the launcher). <see cref="LegacyPath"/>: the
|
||||
/// account's name-only stash, set aside with a failed per-server one when identical.
|
||||
/// </summary>
|
||||
private sealed record PrefsSwapLaunch(UserPrefsSwap Swap, long Generation, bool IsProfileOverride, string LegacyPath);
|
||||
|
||||
/// <summary>
|
||||
/// Copies the account's saved UserPreferences.ini over the live one (caller holds
|
||||
/// _userPrefsSwapLock) and returns what was swapped, or null when nothing was.
|
||||
/// </summary>
|
||||
private PrefsSwapLaunch? ApplyPrefsSwap(LaunchAccountProfile account, string? serverName, string resolvedPrefsPath)
|
||||
{
|
||||
UserPrefsSwap? swap = _launchSettings.SwapUserPreferences(resolvedPrefsPath, _settings.AllowMultipleClients, AppendActivity);
|
||||
if (swap == null)
|
||||
return null;
|
||||
|
||||
long generation = ++_prefsSwapGeneration;
|
||||
bool isOverride = !string.IsNullOrWhiteSpace(account.UserPrefsPath);
|
||||
LauncherDiag.Info($"PrefsSwap: account='{account.AccountName}' server='{serverName}' gen={generation} override={isOverride} changedLive={UserPrefsSwapRecovery.SwapChangedPrefs(swap)} stash='{swap.StashPath}'");
|
||||
return new PrefsSwapLaunch(swap, generation, isOverride, ResolveLegacyUserPrefsPath(account));
|
||||
}
|
||||
|
||||
/// <summary>Remembers which swap a launched client started with (no-op without a swap).</summary>
|
||||
private void TrackPrefsSwap(int pid, PrefsSwapLaunch? prefsSwap)
|
||||
{
|
||||
if (prefsSwap != null)
|
||||
_prefsSwapByPid[pid] = prefsSwap;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A client quit within CrashQuickExitWindow. If it started with a saved UserPreferences.ini
|
||||
/// that differs from the live one, that saved copy is the likely cause (the game reads its
|
||||
/// display mode from it: "Could not initialize Direct3D"), and it would be swapped in again on
|
||||
/// every launch because it is only refreshed after a normal session. So: set the saved copy
|
||||
/// aside (renamed, kept), and put the previous live file back when no later launch replaced it.
|
||||
/// The next normal session saves a fresh copy.
|
||||
/// </summary>
|
||||
private void RecoverFailedPrefsSwap(int pid, string accountKey, TimeSpan uptime)
|
||||
{
|
||||
if (!_prefsSwapByPid.Remove(pid, out PrefsSwapLaunch? launch))
|
||||
return;
|
||||
|
||||
if (!UserPrefsSwapRecovery.SwapChangedPrefs(launch.Swap))
|
||||
{
|
||||
LauncherDiag.Info($"PrefsSwap: PID {pid} ({accountKey}) quick exit, but its stash matched the live file; left alone.");
|
||||
return;
|
||||
}
|
||||
|
||||
bool restoreLive = launch.Generation == _prefsSwapGeneration;
|
||||
try
|
||||
{
|
||||
UserPrefsRecoveryResult result = UserPrefsSwapRecovery.Recover(
|
||||
launch.Swap,
|
||||
quarantineStash: !launch.IsProfileOverride,
|
||||
restoreLive,
|
||||
launch.LegacyPath,
|
||||
DateTime.Now);
|
||||
|
||||
LauncherDiag.Info($"PrefsSwap: PID {pid} ({accountKey}) recovery: quarantined='{result.QuarantinedStashPath}' legacy='{result.QuarantinedLegacyPath}' liveRestored={result.LiveRestored}.");
|
||||
|
||||
string stashName = Path.GetFileName(launch.Swap.StashPath);
|
||||
string what = launch.IsProfileOverride
|
||||
? $"the UserPreferences file set on its profile ({launch.Swap.StashPath}). Fix or clear that file in the account's settings if launches keep failing"
|
||||
: $"this account's saved game settings ({stashName}). They were set aside as {Path.GetFileName(result.QuarantinedStashPath ?? stashName)}, so the next launch uses the current UserPreferences.ini";
|
||||
string live = result.LiveRestored
|
||||
? " The previous UserPreferences.ini was put back."
|
||||
: " UserPreferences.ini was left as is (another launch has swapped it since).";
|
||||
AppendActivity($"Account '{accountKey}' client (PID {pid}) quit after {uptime.TotalSeconds:F0}s using {what}.{live}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppendActivity($"Account '{accountKey}': could not undo the UserPreferences.ini swap after a quick exit: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the current live UserPreferences.ini to the resolved stash for
|
||||
/// the named account. Called on tracked-client exit so per-account prefs
|
||||
|
|
@ -4347,6 +4493,13 @@ internal partial class MainWindow : Window
|
|||
continue;
|
||||
}
|
||||
|
||||
// Needs the First Login dialog, which only a manual launch shows.
|
||||
if (AcLaunchArgumentBuilder.NeedsPassword(account))
|
||||
{
|
||||
MaybeLogAutoLaunchNeedsPassword(account, nowUtc);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_autoLaunchAttemptTimesUtc.TryGetValue(account.Id, out DateTime lastAttemptUtc) &&
|
||||
nowUtc - lastAttemptUtc < AutoLaunchCooldown)
|
||||
{
|
||||
|
|
@ -4399,6 +4552,18 @@ internal partial class MainWindow : Window
|
|||
AppendActivity($"Auto launch waiting for {account.DisplayName}: {(server?.DisplayName ?? "the selected server")} is reporting down.");
|
||||
}
|
||||
|
||||
private void MaybeLogAutoLaunchNeedsPassword(LaunchAccountProfile account, DateTime nowUtc)
|
||||
{
|
||||
if (_autoLaunchNeedsPasswordNoticeTimesUtc.TryGetValue(account.Id, out DateTime lastNoticeUtc) &&
|
||||
nowUtc - lastNoticeUtc < AutoLaunchNeedsPasswordLogCooldown)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_autoLaunchNeedsPasswordNoticeTimesUtc[account.Id] = nowUtc;
|
||||
AppendActivity($"Auto launch waiting for {account.DisplayName}: {AcLaunchArgumentBuilder.MissingPasswordMessage(account.AccountName)}");
|
||||
}
|
||||
|
||||
private bool IsServerKnownDown(LaunchServerProfile? server)
|
||||
{
|
||||
if (server == null)
|
||||
|
|
@ -4476,7 +4641,7 @@ internal partial class MainWindow : Window
|
|||
|
||||
string character = !string.IsNullOrWhiteSpace(session.CharacterName) ? session.CharacterName
|
||||
: !string.IsNullOrWhiteSpace(session.TargetCharacter) ? session.TargetCharacter
|
||||
: !string.IsNullOrWhiteSpace(account.CharacterName) ? account.CharacterName
|
||||
: !string.IsNullOrWhiteSpace(account.CharacterName) && account.CharacterName != LaunchAccountProfile.NoneOption ? account.CharacterName
|
||||
: "Logged in";
|
||||
string elapsed = FormatElapsed(DateTime.UtcNow - (session.LoginCompletedAtUtc ?? session.LaunchStartedAtUtc));
|
||||
return ($"{character} | online {elapsed}", "#66D687");
|
||||
|
|
@ -4490,12 +4655,16 @@ internal partial class MainWindow : Window
|
|||
Process? process = targets.FirstOrDefault(p => p.Id == pid);
|
||||
DateTime since = process != null ? GetProcessStartTimeUtc(process) : context.CreatedAtUtc.ToUniversalTime();
|
||||
string character = !string.IsNullOrWhiteSpace(context.TargetCharacter) ? context.TargetCharacter
|
||||
: !string.IsNullOrWhiteSpace(account.CharacterName) ? account.CharacterName
|
||||
: "Pending";
|
||||
: !string.IsNullOrWhiteSpace(account.CharacterName) && account.CharacterName != LaunchAccountProfile.NoneOption ? account.CharacterName
|
||||
: "Character select";
|
||||
string elapsed = FormatElapsed(DateTime.UtcNow - since);
|
||||
return ($"{character} | starting {elapsed}", "#E2B348");
|
||||
}
|
||||
|
||||
if (AcLaunchArgumentBuilder.NeedsPassword(account))
|
||||
return ("Needs password | launch to set up", "#E2B348");
|
||||
if (account.CharacterName == LaunchAccountProfile.NoneOption)
|
||||
return ("Character select | offline", "#73828D");
|
||||
return (!string.IsNullOrWhiteSpace(account.CharacterName) ? $"{account.CharacterName} | offline" : "Offline", "#73828D");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- Launcher assembly version (bump when changing launcher-only behavior). Previous: 0.1.4.
|
||||
<!-- Launcher assembly version (bump when changing launcher-only behavior). Previous: 0.1.6.
|
||||
No hard-coded InformationalVersion: release builds pass -p:Version=yyyy.m.d.n, and the
|
||||
product version derived from it is what the launcher/About show (BuildVersion.Format). -->
|
||||
<Version>0.1.5</Version>
|
||||
<AssemblyVersion>0.1.5.0</AssemblyVersion>
|
||||
<FileVersion>0.1.5.0</FileVersion>
|
||||
<Version>0.1.7</Version>
|
||||
<AssemblyVersion>0.1.7.0</AssemblyVersion>
|
||||
<FileVersion>0.1.7.0</FileVersion>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net10.0-windows7.0</TargetFramework>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
|
|
@ -53,7 +53,9 @@
|
|||
<Compile Include="..\RynthCore.App\DecalBridgeCheck.cs" Link="Shared\DecalBridgeCheck.cs" />
|
||||
<Compile Include="..\RynthCore.App\RealDecalCheckHost.cs" Link="Shared\RealDecalCheckHost.cs" />
|
||||
<Compile Include="..\RynthCore.App\AcLaunchArgumentBuilder.cs" Link="Shared\AcLaunchArgumentBuilder.cs" />
|
||||
<Compile Include="..\RynthCore.App\FirstLoginRules.cs" Link="Shared\FirstLoginRules.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" />
|
||||
<Compile Include="..\RynthCore.App\CharacterCacheStore.cs" Link="Shared\CharacterCacheStore.cs" />
|
||||
<Compile Include="..\RynthCore.App\LaunchContextStore.cs" Link="Shared\LaunchContextStore.cs" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue