Snapshot for release 2026.10.13.1 (internal 90a2f4a)

This commit is contained in:
Tom Bohar 2026-10-13 14:25:48 -04:00
commit 1d86acdf27
218 changed files with 24019 additions and 1517 deletions

View file

@ -1,6 +1,8 @@
using System;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using RynthCore;
namespace RynthCore.App.Avalonia;
@ -13,6 +15,18 @@ public partial class App : Application
public override void OnFrameworkInitializationCompleted()
{
try
{
string t = DateTime.Now.ToString("O");
DesktopRollingLog.AppendLine(DesktopRollingLog.StemLauncher,
$"[{t}] [pid:{Environment.ProcessId}] RynthCore.App.Avalonia started (launcher).");
// Detailed host + sidecar file layout (see LauncherHostDiagnostics) for runtime mis-detection triage.
LauncherHostDiagnostics.AppendDesktopLogBlock(t);
}
catch
{
}
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
desktop.MainWindow = new MainWindow();

View file

@ -120,4 +120,19 @@ internal static class EngineJsonStore
fields[field] = doc.RootElement.Clone();
Write(fields);
}
/// <summary>
/// Sets a single string field (e.g. "LoggingLevel"), preserving every other field.
/// </summary>
public static void SetString(string field, string value)
{
Dictionary<string, JsonElement> fields = Read();
using var ms = new MemoryStream();
using (var w = new Utf8JsonWriter(ms))
w.WriteStringValue(value);
using var doc = JsonDocument.Parse(ms.ToArray());
fields[field] = doc.RootElement.Clone();
Write(fields);
}
}

View file

@ -0,0 +1,29 @@
using System;
using System.Runtime.InteropServices;
using RynthCore.Install;
namespace RynthCore.App.Avalonia;
/// <summary>
/// One-shot values the installer leaves under <c>Software\Rynth</c> for the launcher
/// (e.g. <c>PendingPluginRegistration</c>). Kept out of the shared, read-only
/// <see cref="RynthInstallPaths"/>, which must stay byte-identical with RynthSuite's copy.
/// </summary>
internal static class InstallerHandoff
{
/// <summary>A string value from <c>Software\Rynth</c>: HKCU first, then HKLM (32-bit view); null when absent.</summary>
public static string? ReadSetting(string valueName)
=> SystemInstallSettings.Instance.CurrentUser(valueName)
?? SystemInstallSettings.Instance.LocalMachine(valueName);
/// <summary>Deletes a value from HKCU <c>Software\Rynth</c> once it has been acted on. Best effort.</summary>
public static void DeleteUserSetting(string valueName)
{
try { RegDeleteKeyValueW(HKEY_CURRENT_USER, RynthInstallPaths.RegistryKey, valueName); } catch { }
}
private static readonly IntPtr HKEY_CURRENT_USER = new(unchecked((int)0x80000001));
[DllImport("advapi32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
private static extern int RegDeleteKeyValueW(IntPtr hkey, string lpSubKey, string lpValueName);
}

View file

@ -2,6 +2,7 @@ using System;
using System.IO;
using System.Text;
using System.Threading;
using RynthCore.Install;
namespace RynthCore.App.Avalonia;

View file

@ -0,0 +1,110 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using RynthCore;
namespace RynthCore.App.Avalonia;
/// <summary>
/// One-shot host metadata for the Avalonia launcher: helps confirm the renamed apphost
/// (<c>RynthCore.exe</c>) sits next to matching <c>.runtimeconfig.json</c> / <c>.deps.json</c> after installer staging.
/// </summary>
internal static class LauncherHostDiagnostics
{
/// <summary>Single line for the in-window activity feed (short).</summary>
internal static string BuildActivitySummaryLine()
{
string exe = TryGetHostExePath();
string dir = Path.GetDirectoryName(exe) ?? AppContext.BaseDirectory;
HostSidecars side = DescribeSidecars(dir);
// x64 FDD tool prereq: same registry keys as installer/RynthCore.iss (see NetDesktopX64Prerequisite).
string suiteTools = NetDesktopX64Prerequisite.IsSatisfied()
? "x64 suite tools: .NET 10+ OK (registry, same as setup)"
: "x64 suite tools: .NET 10+ not found — install x64 runtime from " + NetDesktopX64Prerequisite.DotNet10RuntimeDownloadUrl;
if (!Environment.Is64BitOperatingSystem)
suiteTools = "x64 suite tools: n/a on 32-bit OS (same as setup)";
return
$"Host: {RuntimeInformation.FrameworkDescription}, arch={RuntimeInformation.ProcessArchitecture}, " +
$"runtimeconfig={(side.RenamedRuntimeConfig ? "RynthCore" : side.LegacyRuntimeConfig ? "App.Avalonia (mismatch?)" : "missing")}, " +
$"deps={(side.RenamedDeps ? "RynthCore" : side.LegacyDeps ? "App.Avalonia (mismatch?)" : "missing")}; {suiteTools}";
}
/// <summary>Writes a detailed block to the desktop rolling launcher log.</summary>
internal static void AppendDesktopLogBlock(string timestampIso)
{
try
{
string exe = TryGetHostExePath();
string dir = Path.GetDirectoryName(exe) ?? AppContext.BaseDirectory;
HostSidecars side = DescribeSidecars(dir);
var sb = new StringBuilder(512);
sb.Append('[').Append(timestampIso).Append("] [pid:").Append(Environment.ProcessId).AppendLine("] Launcher host resolution:");
sb.Append(" ProcessPath: ").AppendLine(exe);
sb.Append(" BaseDirectory: ").AppendLine(AppContext.BaseDirectory);
sb.Append(" Framework: ").AppendLine(RuntimeInformation.FrameworkDescription);
sb.Append(" OSDescription: ").AppendLine(RuntimeInformation.OSDescription);
sb.Append(" ProcessArchitecture: ").AppendLine(RuntimeInformation.ProcessArchitecture.ToString());
sb.Append(" CLR: ").AppendLine(Environment.Version.ToString());
sb.Append(" RynthCore.runtimeconfig.json: ").AppendLine(side.RenamedRuntimeConfig ? "present" : "absent");
sb.Append(" RynthCore.App.Avalonia.runtimeconfig.json: ").AppendLine(side.LegacyRuntimeConfig ? "present (unexpected if exe is RynthCore.exe)" : "absent");
sb.Append(" RynthCore.deps.json: ").AppendLine(side.RenamedDeps ? "present" : "absent");
sb.Append(" RynthCore.App.Avalonia.deps.json: ").AppendLine(side.LegacyDeps ? "present (unexpected if exe is RynthCore.exe)" : "absent");
// Loot/Monster editors are x64 FDD: probe matches RynthCore.iss prerequisite page (64-bit registry view).
sb.Append(" x64 FDD tool runtime (Loot/Monster, same checks as installer): ")
.AppendLine(NetDesktopX64Prerequisite.IsSatisfied() ? "present" : "not detected")
.Append(" .NET 10+ x64 download hub: ")
.AppendLine(NetDesktopX64Prerequisite.DotNet10RuntimeDownloadUrl);
DesktopRollingLog.AppendLine(DesktopRollingLog.StemLauncher, sb.ToString());
}
catch
{
// Logging must never prevent startup.
}
}
private static string TryGetHostExePath()
{
try
{
// Prefer the actual apphost path (works for published rename to RynthCore.exe).
string? p = Environment.ProcessPath;
if (!string.IsNullOrWhiteSpace(p))
return p;
}
catch
{
// ignore
}
try
{
return typeof(App).Assembly.Location;
}
catch
{
return string.Empty;
}
}
private static HostSidecars DescribeSidecars(string directory)
{
if (string.IsNullOrWhiteSpace(directory) || !Directory.Exists(directory))
return new HostSidecars(false, false, false, false);
bool renamedRc = File.Exists(Path.Combine(directory, "RynthCore.runtimeconfig.json"));
bool legacyRc = File.Exists(Path.Combine(directory, "RynthCore.App.Avalonia.runtimeconfig.json"));
bool renamedDeps = File.Exists(Path.Combine(directory, "RynthCore.deps.json"));
bool legacyDeps = File.Exists(Path.Combine(directory, "RynthCore.App.Avalonia.deps.json"));
return new HostSidecars(renamedRc, legacyRc, renamedDeps, legacyDeps);
}
private readonly record struct HostSidecars(
bool RenamedRuntimeConfig,
bool LegacyRuntimeConfig,
bool RenamedDeps,
bool LegacyDeps);
}

View file

@ -0,0 +1,192 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using System.Text.Json.Nodes;
using RynthCore.Install;
namespace RynthCore.App.Avalonia;
/// <summary>
/// Launcher-side access to every live logging switch:
/// <list type="bullet">
/// <item>Engine: engine.json "LoggingLevel" (global threshold) and "LogCategories" (per-category emit
/// level). The engine polls engine.json once a second, so edits apply to running clients.</item>
/// <item>RynthAi: Logs\Diagnostics\diagnostics.json "Categories" and "Events" (Off / Trace / Info).
/// RynthAi polls it every couple of seconds and rewrites it with the full catalog on load.</item>
/// </list>
/// </summary>
internal static class LoggingSettingsStore
{
/// <summary>One engine log category as shown in the launcher.</summary>
internal readonly record struct EngineCategory(string Name, string DefaultLevel, string Description);
/// <summary>One RynthAi category / event row read from diagnostics.json.</summary>
internal sealed record DiagnosticsRow(string Key, string Level, string Description);
/// <summary>Global level choices (engine.json "LoggingLevel"), most to least quiet.</summary>
internal static readonly string[] GlobalLevels = { "Off", "Error", "Warning", "Info", "Debug", "Trace" };
/// <summary>Engine category emit levels. Info = normal log; Debug/Trace show only at that global level.</summary>
internal static readonly string[] EngineCategoryLevels = { "Off", "Trace", "Debug", "Info" };
/// <summary>RynthAi category / event levels: Off, Trace (trace file only), Info (also the normal log).</summary>
internal static readonly string[] RynthAiLevels = { "Off", "Trace", "Info" };
/// <summary>Must match RynthCore.Engine.LogCategory names and LogSettings defaults.</summary>
internal static readonly EngineCategory[] EngineCategories =
{
new("General", "Info", "Uncategorised engine lines."),
new("D3D9", "Info", "D3D9 hook, EndScene, bootstrapper, matrix capture, nav markers."),
new("Compat", "Info", "Client hooks: objects, combat, movement, vitals, chat."),
new("Render", "Off", "ImGui rendering and Win32 input (very chatty)."),
new("Plugin", "Info", "Plugin loader/manager and every plugin host Log line."),
new("UI", "Info", "Avalonia overlay and panels."),
new("Verbose", "Debug", "Detail lines across all subsystems (Info = always in the normal log)."),
};
private const string EngineCategoriesProperty = "LogCategories";
/// <summary>RynthAi's diagnostics.json (created by RynthAi on its first load).</summary>
internal static string DiagnosticsPath =>
Path.Combine(RynthInstallPaths.RynthAiDir, "Logs", "Diagnostics", "diagnostics.json");
// ── Engine ──────────────────────────────────────────────────────────
/// <summary>Current engine category levels; categories missing from engine.json get their defaults.</summary>
internal static Dictionary<string, string> ReadEngineCategoryLevels()
{
var result = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
foreach (EngineCategory c in EngineCategories) result[c.Name] = c.DefaultLevel;
Dictionary<string, JsonElement> fields = EngineJsonStore.Read();
if (fields.TryGetValue(EngineCategoriesProperty, out JsonElement cats) && cats.ValueKind == JsonValueKind.Object)
{
foreach (JsonProperty p in cats.EnumerateObject())
{
if (p.Value.ValueKind == JsonValueKind.String && result.ContainsKey(p.Name))
result[p.Name] = p.Value.GetString() ?? result[p.Name];
}
}
return result;
}
/// <summary>Sets one engine category level in engine.json, preserving every other field.</summary>
internal static void SetEngineCategoryLevel(string category, string level)
{
Dictionary<string, string> levels = ReadEngineCategoryLevels();
levels[category] = level;
using var ms = new MemoryStream();
using (var w = new Utf8JsonWriter(ms))
{
w.WriteStartObject();
foreach (EngineCategory c in EngineCategories)
w.WriteString(c.Name, levels[c.Name]);
w.WriteEndObject();
}
Dictionary<string, JsonElement> fields = EngineJsonStore.Read();
using var doc = JsonDocument.Parse(ms.ToArray());
fields[EngineCategoriesProperty] = doc.RootElement.Clone();
EngineJsonStore.Write(fields);
}
// ── RynthAi ─────────────────────────────────────────────────────────
/// <summary>
/// Reads RynthAi's category and event rows. Returns false (with empty lists) when diagnostics.json
/// does not exist yet or cannot be parsed (e.g. RynthAi is mid-write; retry later).
/// </summary>
internal static bool TryReadRynthAi(out List<DiagnosticsRow> categories, out List<DiagnosticsRow> events, out string? error)
{
categories = new List<DiagnosticsRow>();
events = new List<DiagnosticsRow>();
error = null;
try
{
if (!File.Exists(DiagnosticsPath))
{
error = "diagnostics.json not found - start RynthAi once to create it.";
return false;
}
if (JsonNode.Parse(File.ReadAllText(DiagnosticsPath)) is not JsonObject root)
{
error = "diagnostics.json is not a JSON object.";
return false;
}
ReadRows(root["Categories"] as JsonArray, "Name", categories);
ReadRows(root["Events"] as JsonArray, "Key", events);
if (categories.Count == 0)
error = "diagnostics.json has no category list - update RynthAi to 0.6.18 or later.";
return true;
}
catch (Exception ex)
{
error = $"diagnostics.json unreadable ({ex.GetType().Name}: {ex.Message}).";
return false;
}
}
/// <summary>Sets a RynthAi category level ("Off", "Trace", "Info") and keeps "Traces" in sync.</summary>
internal static void SetRynthAiCategoryLevel(string category, string level)
=> UpdateDiagnostics("Categories", "Name", category, level);
/// <summary>Sets a RynthAi key-event level ("Off", "Trace", "Info").</summary>
internal static void SetRynthAiEventLevel(string eventKey, string level)
=> UpdateDiagnostics("Events", "Key", eventKey, level);
private static void ReadRows(JsonArray? array, string keyField, List<DiagnosticsRow> into)
{
if (array == null) return;
foreach (JsonNode? node in array)
{
if (node is not JsonObject o) continue;
string key = o[keyField]?.GetValue<string>() ?? string.Empty;
if (key.Length == 0) continue;
into.Add(new DiagnosticsRow(
key,
o["Level"]?.GetValue<string>() ?? "Off",
o["Description"]?.GetValue<string>() ?? string.Empty));
}
}
/// <summary>Read-modify-write of one row's Level; every other field in the file is preserved.</summary>
private static void UpdateDiagnostics(string section, string keyField, string key, string level)
{
string path = DiagnosticsPath;
if (JsonNode.Parse(File.ReadAllText(path)) is not JsonObject root)
throw new InvalidDataException("diagnostics.json is not a JSON object.");
if (root[section] is not JsonArray rows)
throw new InvalidDataException($"diagnostics.json has no \"{section}\" list.");
bool found = false;
foreach (JsonNode? node in rows)
{
if (node is JsonObject o && string.Equals(o[keyField]?.GetValue<string>(), key, StringComparison.OrdinalIgnoreCase))
{
o["Level"] = level;
found = true;
}
}
if (!found)
throw new KeyNotFoundException($"\"{key}\" is not in diagnostics.json {section}.");
// RynthAi reads Categories when present, but older readers (and /ra trace status) use Traces.
if (section == "Categories")
{
var traces = new JsonArray();
foreach (JsonNode? node in rows)
{
if (node is JsonObject o && !string.Equals(o["Level"]?.GetValue<string>(), "Off", StringComparison.OrdinalIgnoreCase))
traces.Add(o["Name"]?.GetValue<string>());
}
root["Traces"] = traces;
}
// Atomic swap so RynthAi's poll never reads a half-written file.
string tmp = path + ".tmp";
File.WriteAllText(tmp, root.ToJsonString(new JsonSerializerOptions { WriteIndented = false }));
File.Move(tmp, path, overwrite: true);
}
}

View file

@ -0,0 +1,173 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Principal;
using System.Threading.Tasks;
using RynthCore.Install;
namespace RynthCore.App.Avalonia;
/// <summary>
/// Recovery Actions > Fix folder permissions, and the start-up check that suggests it
/// (src\RynthCore.App\FolderAccess.cs, 2026-10-13). Players reported RynthAi metas and navs not
/// saving: the game client (never elevated) couldn't write in C:\Games\RynthSuite.
/// </summary>
internal partial class MainWindow
{
private const string FixFoldersTitle = "Fix folder permissions";
private bool _folderCheckShown;
/// <summary>The RynthSuite and RynthCore folders, as resolved for this account.</summary>
private static List<string> SuiteAndCoreDirs() =>
new[] { RynthInstallPaths.SuiteDir, RynthInstallPaths.CoreDir }
.Where(Directory.Exists).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
private static Task<(List<FolderAccess.FolderStatus> Folders, FolderAccess.CfaInfo Cfa)> CheckFoldersAsync() =>
Task.Run(() =>
{
var folders = FolderAccess.CheckAll(FolderAccess.FoldersToCheck(RynthInstallPaths.SuiteDir, RynthInstallPaths.CoreDir));
var cfa = FolderAccess.QueryControlledFolderAccess();
return (folders, cfa);
});
/// <summary>The Controlled folder access part of a message ("" when it isn't in the way).</summary>
private static string DescribeCfa(FolderAccess.CfaInfo cfa)
{
var mine = cfa.GameClientBlocks(DateTime.UtcNow);
if (mine.Count > 0)
{
var last = mine[0];
return $"Windows Security's Controlled folder access blocked the game client {mine.Count} time(s) recently " +
$"(last: {last.Time.ToLocalTime():g}, {last.Path}). Permissions can't fix that; allow the client instead:\n" +
FolderAccess.CfaAllowHowTo;
}
if (cfa.On)
return "Controlled folder access (Windows Security ransomware protection) is on. If RynthSuite is in a protected " +
"folder (Documents, Desktop, or one you added), it blocks acclient.exe from saving there. To allow it: " +
FolderAccess.CfaAllowHowTo;
return string.Empty;
}
/// <summary>At start: say so (Activity, log, one dialog) when the client won't be able to save.</summary>
private async Task CheckFolderAccessAtStartupAsync()
{
try
{
var (folders, cfa) = await CheckFoldersAsync();
List<string> problems = FolderAccess.DescribeProblems(folders);
string cfaText = DescribeCfa(cfa);
bool cfaBlocks = cfa.BlocksGameClient;
foreach (string p in problems)
{
LauncherDiag.Info("FOLDERS: " + p);
AppendActivity("Folders: " + p);
}
if (cfaText.Length > 0)
{
LauncherDiag.Info("FOLDERS: " + cfaText.Replace('\n', ' '));
if (cfaBlocks || problems.Count > 0) AppendActivity("Folders: " + cfaText.Replace('\n', ' '));
}
if ((problems.Count == 0 && !cfaBlocks) || _folderCheckShown) return;
_folderCheckShown = true;
if (problems.Count > 0)
{
string msg = "RynthAi won't be able to save metas, navs, loot or settings profiles here:\n\n" +
string.Join("\n", problems.Take(8)) +
(problems.Count > 8 ? $"\n... and {problems.Count - 8} more (Activity tab)." : "") +
"\n\nFix folder permissions gives your Windows account write access to the RynthSuite and RynthCore " +
"folders and clears read-only on their files (one administrator prompt)." +
(cfaText.Length > 0 ? "\n\n" + cfaText : "");
if (await DecalBridgeDialog.AskAsync(this, FixFoldersTitle, msg, "Fix now", "Not now"))
await FixFolderPermissionsAsync(ask: false);
}
else
{
await DecalBridgeDialog.InfoAsync(this, "Saves blocked by Windows Security", cfaText);
}
}
catch (Exception ex)
{
LauncherDiag.Info($"FOLDERS: start-up check failed ({ex.GetType().Name}: {ex.Message})");
}
}
/// <summary>
/// Recovery Actions > Fix folder permissions: one administrator prompt; the elevated launcher
/// (--fix-folder-permissions) grants this account Modify on the RynthSuite and RynthCore
/// folders and clears read-only on their files; then the check runs again.
/// </summary>
private async Task FixFolderPermissionsAsync(bool ask = true)
{
List<string> roots = SuiteAndCoreDirs();
if (roots.Count == 0)
{
await DecalBridgeDialog.InfoAsync(this, FixFoldersTitle, $"Neither {RynthInstallPaths.SuiteDir} nor {RynthInstallPaths.CoreDir} exists.");
return;
}
if (ask)
{
bool yes = await DecalBridgeDialog.AskAsync(this, FixFoldersTitle,
"Gives your Windows account write access (Modify) to these folders and everything in them, and clears " +
"read-only on their files, so RynthAi can save metas, navs, loot and settings profiles:\n\n" +
string.Join("\n", roots) + "\n\nWindows asks for administrator permission once. Nothing else is changed.",
"Fix", "Cancel");
if (!yes)
{
AppendActivity("Fix folder permissions: cancelled; nothing changed.");
return;
}
}
string? sid = WindowsIdentity.GetCurrent().User?.Value;
string? self = Environment.ProcessPath;
if (sid == null || self == null)
{
AppendActivity("Fix folder permissions: couldn't tell who you are or where the launcher is; nothing changed.");
return;
}
string reportPath = Path.Combine(Path.GetTempPath(), $"rynthcore-folderfix-{Guid.NewGuid():N}.txt");
string args = FolderAccess.BuildRepairArguments(sid, roots, reportPath);
LauncherDiag.Info($"FOLDERS: fix folder permissions: {args}");
AppendActivity("Fix folder permissions: waiting for the Windows administrator prompt...");
(DecalBridgeRegistration.Outcome outcome, string runReport) = await Task.Run(() =>
{
var o = DecalBridgeRegistration.RunElevated(self, args, out string r);
return (o, r);
});
string details = string.Empty;
try
{
if (File.Exists(reportPath))
{
details = File.ReadAllText(reportPath).Trim();
File.Delete(reportPath);
}
}
catch { }
LauncherDiag.Info($"FOLDERS: fix folder permissions: {outcome}: {runReport} {details.Replace(Environment.NewLine, " | ")}");
var (folders, cfa) = await CheckFoldersAsync();
List<string> left = FolderAccess.DescribeProblems(folders);
string cfaText = DescribeCfa(cfa);
string summary = left.Count == 0
? "Done: every RynthSuite / RynthCore folder can be written now."
: "Still a problem:\n" + string.Join("\n", left.Take(8));
if (outcome == DecalBridgeRegistration.Outcome.NeedsAdmin)
summary = "Cancelled at the Windows administrator prompt; nothing changed.";
AppendActivity("Fix folder permissions: " + summary.Replace('\n', ' '));
string text = summary +
(details.Length > 0 && outcome != DecalBridgeRegistration.Outcome.NeedsAdmin ? "\n\n" + LastLines(details, 6) : "") +
(cfaText.Length > 0 ? "\n\n" + cfaText : "") +
(left.Count == 0 ? "\n\nRestart the game clients that were running so RynthAi checks again." : "");
await DecalBridgeDialog.InfoAsync(this, FixFoldersTitle, text);
}
private static string LastLines(string text, int n)
{
string[] lines = text.Split('\n');
return string.Join("\n", lines.Skip(Math.Max(0, lines.Length - n)).Select(l => l.TrimEnd('\r')));
}
}

View file

@ -0,0 +1,153 @@
using System;
using System.Collections.Generic;
using Avalonia.Controls;
using Avalonia.Layout;
using Avalonia.Media;
namespace RynthCore.App.Avalonia;
/// <summary>
/// Runtime tab → Logging card and the live global Logging level box. Every change is written
/// straight to engine.json / diagnostics.json (see <see cref="LoggingSettingsStore"/>); running
/// clients poll those files, so nothing needs a restart or the Save button.
/// </summary>
internal partial class MainWindow
{
private static readonly IBrush LogNameBrush = new SolidColorBrush(Color.Parse("#EAF0F4"));
private static readonly IBrush LogMutedBrush = new SolidColorBrush(Color.Parse("#9AA8B3"));
// Set while the rows are being (re)built so programmatic selections don't write files.
private bool _suppressLoggingEvents;
/// <summary>Wires the Logging card and the live global level box. Called once after LoadRuntimeControls.</summary>
private void InitLoggingControls()
{
LoggingLevelComboBox.SelectionChanged += (_, _) => OnGlobalLoggingLevelChanged();
ReloadLoggingButton.Click += (_, _) => BuildLoggingRows();
BuildLoggingRows();
}
/// <summary>Global level changed: persist to the launcher settings and push to engine.json now.</summary>
private void OnGlobalLoggingLevelChanged()
{
if (_suppressLoggingEvents) return;
string level = GetSelectedLoggingLevel();
if (string.Equals(level, _settings.LoggingLevel, StringComparison.OrdinalIgnoreCase)) return;
try
{
_settings.LoggingLevel = level;
SaveSettings();
EngineJsonStore.SetString("LoggingLevel", level);
AppendActivity($"Logging level set to {level} (applied live to running clients).");
}
catch (Exception ex)
{
AppendActivity($"Failed to save logging level: {ex.Message}");
}
}
/// <summary>(Re)builds the engine category, RynthAi category and RynthAi event rows from disk.</summary>
private void BuildLoggingRows()
{
_suppressLoggingEvents = true;
try
{
EngineLogCategoriesPanel.Children.Clear();
Dictionary<string, string> engineLevels = LoggingSettingsStore.ReadEngineCategoryLevels();
foreach (LoggingSettingsStore.EngineCategory cat in LoggingSettingsStore.EngineCategories)
{
string name = cat.Name;
EngineLogCategoriesPanel.Children.Add(BuildLoggingRow(
name, cat.Description, LoggingSettingsStore.EngineCategoryLevels, engineLevels[name],
level =>
{
LoggingSettingsStore.SetEngineCategoryLevel(name, level);
AppendActivity($"Engine log category {name} set to {level} (applied live).");
}));
}
RynthAiLogCategoriesPanel.Children.Clear();
RynthAiLogEventsPanel.Children.Clear();
bool ok = LoggingSettingsStore.TryReadRynthAi(
out List<LoggingSettingsStore.DiagnosticsRow> categories,
out List<LoggingSettingsStore.DiagnosticsRow> events,
out string? error);
foreach (LoggingSettingsStore.DiagnosticsRow row in categories)
{
string key = row.Key;
RynthAiLogCategoriesPanel.Children.Add(BuildLoggingRow(
key, row.Description, LoggingSettingsStore.RynthAiLevels, row.Level,
level =>
{
LoggingSettingsStore.SetRynthAiCategoryLevel(key, level);
AppendActivity($"RynthAi log category {key} set to {level} (applied live).");
}));
}
foreach (LoggingSettingsStore.DiagnosticsRow row in events)
{
string key = row.Key;
RynthAiLogEventsPanel.Children.Add(BuildLoggingRow(
key, row.Description, LoggingSettingsStore.RynthAiLevels, row.Level,
level =>
{
LoggingSettingsStore.SetRynthAiEventLevel(key, level);
AppendActivity($"RynthAi log event {key} set to {level} (applied live).");
}));
}
LoggingStatusText.Text = ok && error == null
? $"engine.json: {EngineJsonStore.Path}\ndiagnostics.json: {LoggingSettingsStore.DiagnosticsPath}"
: $"RynthAi: {error}";
}
catch (Exception ex)
{
LoggingStatusText.Text = $"Failed to load logging settings: {ex.Message}";
}
finally
{
_suppressLoggingEvents = false;
}
}
/// <summary>One "Name | level box | description" row. <paramref name="apply"/> runs on user changes only.</summary>
private Control BuildLoggingRow(string name, string description, string[] levels, string current, Action<string> apply)
{
var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("170,110,*") };
grid.Children.Add(new TextBlock
{
Text = name,
Foreground = LogNameBrush,
VerticalAlignment = VerticalAlignment.Center,
});
var combo = new ComboBox { ItemsSource = levels, MinWidth = 100, Margin = new global::Avalonia.Thickness(0, 0, 8, 0) };
int index = Array.FindIndex(levels, l => string.Equals(l, current, StringComparison.OrdinalIgnoreCase));
combo.SelectedIndex = index >= 0 ? index : 0;
combo.SelectionChanged += (_, _) =>
{
if (_suppressLoggingEvents || combo.SelectedItem is not string level) return;
try { apply(level); }
catch (Exception ex)
{
AppendActivity($"Failed to set {name} to {level}: {ex.Message}");
// Show what is actually on disk; posted so the combo raising this event isn't torn down mid-handler.
global::Avalonia.Threading.Dispatcher.UIThread.Post(BuildLoggingRows);
}
};
Grid.SetColumn(combo, 1);
grid.Children.Add(combo);
var desc = new TextBlock
{
Text = description,
Foreground = LogMutedBrush,
TextWrapping = TextWrapping.Wrap,
VerticalAlignment = VerticalAlignment.Center,
};
Grid.SetColumn(desc, 2);
grid.Children.Add(desc);
return grid;
}
}

View file

@ -366,7 +366,17 @@
<CheckBox x:Name="OverrideWindowTitleCheckBox"
Content="Rewrite AC window titles per account"
ToolTip.Tip="Replaces &quot;Asheron's Call&quot; with &quot;Account / Character @ Server&quot; on tracked clients so multi-box taskbars are readable. Untracked external clients are left alone." />
<CheckBox x:Name="InjectAllRunningAcCheckBox" Content="Inject all running AC sessions" />
<TextBlock Text="Logging level (applies live)" Foreground="#EAF0F4" Margin="0,4,0,0" />
<ComboBox x:Name="LoggingLevelComboBox" SelectedIndex="3"
ToolTip.Tip="Engine log threshold. Written to engine.json immediately; running clients pick it up within a second. Off = errors only.">
<ComboBoxItem Content="Off" />
<ComboBoxItem Content="Error" />
<ComboBoxItem Content="Warning" />
<ComboBoxItem Content="Info" />
<ComboBoxItem Content="Debug" />
<ComboBoxItem Content="Trace" />
</ComboBox>
<Grid ColumnDefinitions="*,Auto" RowDefinitions="Auto,Auto,Auto" Margin="0,8,0,0">
<TextBlock Grid.Row="0" Grid.Column="0" Text="Inter-launch stagger (ms)" Foreground="#EAF0F4" VerticalAlignment="Center" Margin="0,0,8,6" />
<NumericUpDown Grid.Row="0" Grid.Column="1" x:Name="LaunchStaggerMsBox" Minimum="0" Maximum="5000" Increment="50" Width="120" Margin="0,0,0,6" />
@ -409,6 +419,42 @@
</StackPanel>
</Border>
<!-- Live logging switches: engine categories (engine.json) and RynthAi categories/events
(diagnostics.json). Rows are built in code (MainWindow.Logging.cs). -->
<Border Background="#132028" CornerRadius="16" Padding="18">
<StackPanel Spacing="8">
<Grid ColumnDefinitions="*,Auto">
<TextBlock Grid.Column="0" Text="Logging" FontSize="16" FontWeight="SemiBold" Foreground="#26C1A6" VerticalAlignment="Center" />
<Button Grid.Column="1" x:Name="ReloadLoggingButton" Content="Reload" />
</Grid>
<TextBlock Text="Every change is saved immediately and applies to running clients without a restart (engine within 1 s, RynthAi within 2 s). Set any Trace or Debug item to Info to see it in the normal log; Off silences it."
TextWrapping="Wrap"
Foreground="#9AA8B3" />
<Expander Header="Engine categories" IsExpanded="True" HorizontalAlignment="Stretch">
<StackPanel Spacing="4">
<TextBlock Text="The level each category's lines are written at. A line shows when its level is within the global Logging level above (Info = normal log)."
TextWrapping="Wrap" Foreground="#9AA8B3" />
<StackPanel x:Name="EngineLogCategoriesPanel" Spacing="2" />
</StackPanel>
</Expander>
<Expander Header="RynthAi categories" HorizontalAlignment="Stretch">
<StackPanel Spacing="4">
<TextBlock Text="Where each RynthAi category's trace lines go: Off = dropped, Trace = Logs\Diagnostics\Trace file only, Info = trace file and the normal log."
TextWrapping="Wrap" Foreground="#9AA8B3" />
<StackPanel x:Name="RynthAiLogCategoriesPanel" Spacing="2" />
</StackPanel>
</Expander>
<Expander Header="RynthAi key events" HorizontalAlignment="Stretch">
<StackPanel Spacing="4">
<TextBlock Text="Named milestones (Hub login, options refresh, ...). Off = dropped, Trace = trace file while that category is traced, Info = normal log."
TextWrapping="Wrap" Foreground="#9AA8B3" />
<StackPanel x:Name="RynthAiLogEventsPanel" Spacing="2" />
</StackPanel>
</Expander>
<TextBlock x:Name="LoggingStatusText" TextWrapping="Wrap" Foreground="#9AA8B3" />
</StackPanel>
</Border>
<Border Background="#132028" CornerRadius="16" Padding="18">
<StackPanel Spacing="8">
<TextBlock Text="Recovery Actions" FontSize="16" FontWeight="SemiBold" Foreground="#26C1A6" />
@ -424,8 +470,10 @@
ToolTip.Tip="For Decal + RynthCore (experimental): checks whether a client started now will load the RynthCore Decal bridge - where Decal reads its plugin list on this PC, whether the bridge is listed and enabled there, Decal's version and its .NET part. Changes nothing unless you press Repair." />
<Button x:Name="RepairDecalButton" Content="Repair Decal" Margin="0,0,8,8"
ToolTip.Tip="For Decal plugins that don't show up: Windows can make Decal read an old per-user copy of its settings (left by an earlier RynthCore, or by Decal itself), which hides plugins installed since. This backs that copy up to a .reg file in %APPDATA%\RynthCore and removes it, after asking. Close Asheron's Call first." />
<Button x:Name="FixFolderPermissionsButton" Content="Fix folder permissions" Margin="0,0,8,8"
ToolTip.Tip="When RynthAi metas, navs, loot or settings profiles don't save: gives your Windows account write access to the RynthSuite and RynthCore folders and clears read-only on their files (one administrator prompt). Also tells you when Windows Security's Controlled folder access is blocking the game client." />
</WrapPanel>
<TextBlock Text="Manual inject targets the first detected acclient.exe session. Reset Overlay Bar signals all running RynthCore clients via the dispatch file."
<TextBlock Text="Manual inject target scope follows the 'Inject all running AC sessions' launch behavior toggle. Reset Overlay Bar signals all running RynthCore clients via the dispatch file."
TextWrapping="Wrap"
Foreground="#9AA8B3" />
</StackPanel>

View file

@ -18,6 +18,7 @@ using Avalonia.Media;
using Avalonia.Platform.Storage;
using Avalonia.Threading;
using RynthCore.Injector;
using RynthCore.Install;
namespace RynthCore.App.Avalonia;
@ -136,6 +137,8 @@ internal partial class MainWindow : Window
SessionList.ItemsSource = _sessionItems;
LoadSettings();
LoadRuntimeControls();
InitLoggingControls();
ApplyInstallerPluginRegistration();
LoadPluginDllPaths();
BuildPluginLoadout();
WireEvents();
@ -149,6 +152,8 @@ internal partial class MainWindow : Window
Closing += (_, _) => SaveWindowLayout();
ShowVersion();
AppendActivity("Avalonia launcher preview ready.");
// One-line host/runtime sidecar check (full detail in Desktop RynthCore-Launcher.log).
AppendActivity(LauncherHostDiagnostics.BuildActivitySummaryLine());
_ = RefreshServerStatusesAsync();
_updateTimer.Tick += async (_, _) => await CheckForUpdatesAsync();
_updateTimer.Start();
@ -157,6 +162,7 @@ internal partial class MainWindow : Window
{
await AskAboutUsageStatsOnceAsync();
await CleanUpDecalBridgeIfUnusedAsync(atStartup: true);
await CheckFolderAccessAtStartupAsync(); // MainWindow.FolderAccess.cs: can the game client save?
};
}
@ -184,6 +190,7 @@ internal partial class MainWindow : Window
ResetOverlayBarButton.Click += (_, _) => ResetOverlayBar();
CheckDecalBridgeButton.Click += async (_, _) => await CheckDecalBridgeAsync();
RepairDecalButton.Click += async (_, _) => await RepairDecalAsync();
FixFolderPermissionsButton.Click += async (_, _) => await FixFolderPermissionsAsync();
AddPluginDllButton.Click += async (_, _) => await AddPluginDllAsync();
CheckUpdatesButton.Click += async (_, _) => await CheckForUpdatesAsync();
UpdateCardActionButton.Click += async (_, _) => await OnUpdateCardActionAsync();
@ -312,6 +319,8 @@ internal partial class MainWindow : Window
AutoLaunchHeaderCheckBox.IsChecked = _settings.AutoLaunch;
AutoInjectAfterLaunchCheckBox.IsChecked = _settings.AutoInjectAfterLaunch;
WatchForAcStartCheckBox.IsChecked = _settings.WatchForAcStart;
InjectAllRunningAcCheckBox.IsChecked = _settings.InjectAllRunningClients;
SetLoggingLevelSelection(_settings.LoggingLevel);
OverrideWindowTitleCheckBox.IsChecked = _settings.OverrideWindowTitle;
LaunchStaggerMsBox.Value = _settings.LaunchStaggerMs;
CrashRelaunchLimitBox.Value = _settings.CrashRelaunchLimitInWindow;
@ -1485,6 +1494,8 @@ internal partial class MainWindow : Window
_settings.AutoLaunch = AutoLaunchHeaderCheckBox.IsChecked == true;
_settings.AutoInjectAfterLaunch = AutoInjectAfterLaunchCheckBox.IsChecked == true;
_settings.WatchForAcStart = WatchForAcStartCheckBox.IsChecked == true;
_settings.InjectAllRunningClients = InjectAllRunningAcCheckBox.IsChecked == true;
_settings.LoggingLevel = GetSelectedLoggingLevel();
_settings.OverrideWindowTitle = OverrideWindowTitleCheckBox.IsChecked == true;
if (LaunchStaggerMsBox.Value is decimal staggerMs)
_settings.LaunchStaggerMs = (int)staggerMs;
@ -1499,8 +1510,12 @@ internal partial class MainWindow : Window
if (_settings.EnabledPluginIds.Count == 0)
_settings.EnabledPluginIds.Add("rynthcore-engine");
SaveSettings();
SyncPluginPathsToEngineSettings();
if (appendActivity)
{
AppendActivity($"Logging level saved: {_settings.LoggingLevel}.");
AppendActivity("Launch behavior saved.");
}
}
private void SaveAutoLaunchPreference()
@ -2157,6 +2172,78 @@ internal partial class MainWindow : Window
AppendActivity($"Runtime loadout updated: {Path.GetFileName(dllPath)} {(enabled ? "enabled" : "disabled")} (engine.json synced).");
}
/// <summary>
/// Applies the installer's one-shot plugin hand-off: the full installer writes the plugin
/// DLL paths it placed in the user-chosen RynthSuite folder to
/// <c>Software\Rynth\PendingPluginRegistration</c> (';'-separated). Each existing DLL is added
/// to the Plugins list, and any entry with the same file name that no longer exists (e.g. the
/// old <c>C:\Games\RynthSuite\...</c> path after moving the Suite folder) is replaced.
/// Rows pointing inside the RynthCore folder whose file the installer removed are dropped too.
/// The value is consumed once (deleted from HKCU; remembered in settings for HKLM).
/// </summary>
private void ApplyInstallerPluginRegistration()
{
try
{
string? pending = InstallerHandoff.ReadSetting("PendingPluginRegistration");
if (string.IsNullOrWhiteSpace(pending)
|| string.Equals(pending, _settings.AppliedInstallerPluginRegistration, StringComparison.OrdinalIgnoreCase))
return;
_settings.PluginDllPaths ??= [];
var added = new List<string>();
// The installer clears loose DLLs out of the RynthCore folder (old 0.4.x layouts kept plugins
// and SDK DLLs there), so drop rows that pointed inside it and are now gone. Rows elsewhere are
// left alone, since a missing file there may just be on a drive that isn't mounted.
string coreRoot = Path.TrimEndingDirectorySeparator(RynthInstallPaths.CoreDir) + Path.DirectorySeparatorChar;
bool IsRemovedCoreFile(string p) =>
p.StartsWith(coreRoot, StringComparison.OrdinalIgnoreCase) && !File.Exists(p);
int pruned = _settings.PluginDllPaths.RemoveAll(IsRemovedCoreFile);
_settings.DisabledPluginDllPaths.RemoveAll(IsRemovedCoreFile);
foreach (string raw in pending.Split(';', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries))
{
string path;
try { path = Path.GetFullPath(raw); } catch { continue; }
if (!File.Exists(path)) continue;
string fileName = Path.GetFileName(path);
// Drop stale rows for the same plugin that point at a file which is gone.
_settings.PluginDllPaths.RemoveAll(p =>
string.Equals(Path.GetFileName(p), fileName, StringComparison.OrdinalIgnoreCase)
&& !string.Equals(p, path, StringComparison.OrdinalIgnoreCase)
&& !File.Exists(p));
if (!_settings.PluginDllPaths.Any(p => string.Equals(p, path, StringComparison.OrdinalIgnoreCase)))
{
_settings.PluginDllPaths.Add(path);
added.Add(fileName);
}
}
_settings.AppliedInstallerPluginRegistration = pending;
SaveSettings();
InstallerHandoff.DeleteUserSetting("PendingPluginRegistration");
_pluginDllPaths.Clear();
foreach (string p in _settings.PluginDllPaths) _pluginDllPaths.Add(p);
SyncPluginPathsToEngineSettings();
string msg = added.Count > 0
? $"Installer registered plugin(s): {string.Join(", ", added)} (engine.json synced)."
: "Installer plugin registration already up to date.";
if (pruned > 0)
msg += $" Removed {pruned} plugin path(s) for files the installer cleared from {RynthInstallPaths.CoreDir}.";
LauncherDiag.Info("PLUGINS: " + msg);
try { AppendActivity(msg); } catch { }
}
catch (Exception ex)
{
LauncherDiag.Info("PLUGINS: installer registration failed: " + ex.Message);
}
}
private void LoadPluginDllPaths()
{
_pluginDllPaths.Clear();
@ -2245,6 +2332,8 @@ internal partial class MainWindow : Window
.Where(p => !disabled.Contains(p))
.ToList();
EngineJsonStore.SetStringArray("PluginPaths", enabledPaths);
// The engine reads its log verbosity from engine.json on init (EngineSettings.LoggingLevel).
EngineJsonStore.SetString("LoggingLevel", GetSelectedLoggingLevel());
}
catch (Exception ex)
{
@ -2740,18 +2829,28 @@ internal partial class MainWindow : Window
try
{
SetOperationState(true);
Process target = targets.OrderBy(process => process.Id).First();
AppendActivity($"Applying selected loadout to running AC (PID {target.Id}).");
IReadOnlyList<Process> orderedTargets = targets.OrderBy(process => process.Id).ToList();
bool injectAllSessions = InjectAllRunningAcCheckBox.IsChecked == true;
IReadOnlyList<Process> targetsToInject = injectAllSessions
? orderedTargets
: [orderedTargets[0]];
AppendActivity(injectAllSessions
? $"Applying selected loadout to {targetsToInject.Count} running AC session(s)."
: $"Applying selected loadout to first running AC session (PID {targetsToInject[0].Id}).");
InjectionResult result = await Task.Run(() => _injector.InjectIntoProcess(target, enginePath, AppendActivity));
if (result.Success)
foreach (Process target in targetsToInject)
{
_launchedSessionPids.Add(target.Id);
AppendActivity($"Injection complete for PID {target.Id}.");
}
else
{
AppendActivity($"Injection failed: {result.Summary}");
AppendActivity($"Injecting running AC (PID {target.Id}).");
InjectionResult result = await Task.Run(() => _injector.InjectIntoProcess(target, enginePath, AppendActivity));
if (result.Success)
{
_launchedSessionPids.Add(target.Id);
AppendActivity($"Injection complete for PID {target.Id}.");
}
else
{
AppendActivity($"Injection failed for PID {target.Id}: {result.Summary}");
}
}
}
catch (Exception ex)
@ -2765,6 +2864,39 @@ internal partial class MainWindow : Window
}
}
private string GetSelectedLoggingLevel()
{
return LoggingLevelComboBox.SelectedItem is ComboBoxItem item
? item.Content?.ToString() ?? "Info"
: "Info";
}
private void SetLoggingLevelSelection(string? loggingLevel)
{
string desiredLevel = string.IsNullOrWhiteSpace(loggingLevel) ? "Info" : loggingLevel.Trim();
if (LoggingLevelComboBox.Items == null)
{
LoggingLevelComboBox.SelectedIndex = 0;
return;
}
foreach (object? item in LoggingLevelComboBox.Items)
{
if (item is not ComboBoxItem comboItem)
continue;
string candidate = comboItem.Content?.ToString() ?? string.Empty;
if (!string.Equals(candidate, desiredLevel, StringComparison.OrdinalIgnoreCase))
continue;
LoggingLevelComboBox.SelectedItem = comboItem;
return;
}
// Unknown saved value: fall back to Info (index 3 after Off, Error, Warning), not the quietest level.
LoggingLevelComboBox.SelectedIndex = 3;
}
private void OnPrimarySelectionChanged()
{
if (_suppressPrimarySelectionChanged)
@ -3104,6 +3236,27 @@ internal partial class MainWindow : Window
// thread not draining the marshalled-action queue), and a stale heartbeat
// file.
private readonly Dictionary<int, DateTime> _wedgeZeroFpsSinceUtc = new();
// PIDs held off for a full-memory dump, and since when (DumpInProgressRule.Decide caps the
// hold at MaxHold). Kept while held or expired, dropped once no dump is in progress.
private readonly Dictionary<int, DateTime> _dumpHoldSinceUtc = new();
// Last write of the newest acclient_oom_<pid>_*.dmp in the shared Dumps folder, or null.
private static DateTime? NewestOomDumpWriteUtc(int pid)
{
try
{
string dir = System.IO.Path.Combine(RynthCore.Install.RynthInstallPaths.CoreDir, "Dumps");
if (!Directory.Exists(dir)) return null;
DateTime? newest = null;
foreach (string f in Directory.EnumerateFiles(dir, $"{RynthCore.Install.DumpInProgressRule.OomDumpPrefix}{pid}_*.dmp"))
{
DateTime w = File.GetLastWriteTimeUtc(f);
if (newest == null || w > newest) newest = w;
}
return newest;
}
catch { return null; }
}
// fps (1), plug pump rate (2), login (3), qd = main-thread queue depth (4, optional on older engines).
private static readonly System.Text.RegularExpressions.Regex WedgeHbRegex =
new(@"hb #\d+ .*?fps=(\d+) .*?plug=(\d+)/s .*?login=(\d)(?:.*?qd=(\d+))?", System.Text.RegularExpressions.RegexOptions.Compiled);
@ -3184,6 +3337,35 @@ internal partial class MainWindow : Window
int read = fs.Read(buf, 0, (int)want);
tail = System.Text.Encoding.UTF8.GetString(buf, 0, read);
// The engine's OUT OF MEMORY full-memory dump suspends every thread for minutes:
// the log goes silent and the main thread looks hung, but killing now would cut
// the dump short. Hold off both kills below while it is being written
// (DumpInProgressRule); the restart for the box that follows is unchanged.
DateTime holdNow = DateTime.UtcNow;
DateTime? heldSince = _dumpHoldSinceUtc.TryGetValue(pid, out DateTime hs) ? hs : null;
var hold = RynthCore.Install.DumpInProgressRule.Decide(tail, fi.LastWriteTimeUtc, NewestOomDumpWriteUtc(pid), heldSince, holdNow);
if (hold == RynthCore.Install.DumpInProgressRule.Hold.Holding)
{
if (heldSince == null)
{
_dumpHoldSinceUtc[pid] = holdNow;
LauncherDiag.Info($"WEDGE: PID {pid} is writing a full-memory dump - kill held off until it ends (at most {RynthCore.Install.DumpInProgressRule.MaxHold.TotalMinutes:0} min).");
}
continue;
}
if (hold == RynthCore.Install.DumpInProgressRule.Hold.Expired)
{
if (heldSince is DateTime heldAt && heldAt != DateTime.MinValue)
{
_dumpHoldSinceUtc[pid] = DateTime.MinValue; // logged; stays expired until the signs clear
LauncherDiag.Info($"WEDGE: PID {pid} dump hold expired after {RynthCore.Install.DumpInProgressRule.MaxHold.TotalMinutes:0} min - kill checks resume.");
}
}
else
{
_dumpHoldSinceUtc.Remove(pid);
}
if (hbStale)
{
KillWedgedClient(process, pid, activeContexts, activeSessions,

View file

@ -63,6 +63,26 @@ internal static class Program
LauncherDiag.Info($"DECALBRIDGE: install per-user (installer): {report}");
return ok ? 0 : 1;
}
// Recovery Actions > Fix folder permissions, the elevated step (MainWindow.FolderAccess.cs):
// --fix-folder-permissions <user SID> [--report "<file>"] "<folder>" ["<folder>"...]. Never
// falls through to the window: a malformed command exits with 2.
if (Array.Exists(args, a => string.Equals(a, RynthCore.App.FolderAccess.RepairArgument, StringComparison.OrdinalIgnoreCase)))
{
if (!RynthCore.App.FolderAccess.TryParseRepairArguments(args, out string sid, out var roots, out string? reportPath))
{
LauncherDiag.Info("FOLDERS: fix folder permissions (elevated step): malformed command line; nothing changed.");
return 2;
}
var report = RynthCore.App.FolderAccess.Repair(roots, new System.Security.Principal.SecurityIdentifier(sid));
LauncherDiag.Info("FOLDERS: fix folder permissions (elevated step): " + report.ToString().Replace(Environment.NewLine, " | "));
// The report goes back to the launcher that asked, only as a new file of the expected name.
if (reportPath != null && System.IO.Path.GetFileName(reportPath).StartsWith("rynthcore-folderfix-", StringComparison.OrdinalIgnoreCase)
&& reportPath.EndsWith(".txt", StringComparison.OrdinalIgnoreCase) && !System.IO.File.Exists(reportPath))
{
try { System.IO.File.WriteAllText(reportPath, report.ToString()); } catch { }
}
return report.Ok ? 0 : 1;
}
if (Array.Exists(args, a => string.Equals(a, "--decal-bridge-status", StringComparison.OrdinalIgnoreCase)))
{
LauncherDiag.Info($"DECALBRIDGE: status (command line): {RynthCore.App.DecalBridgeRegistration.GetStatus()}");

View file

@ -1,6 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Launcher assembly version (bump when changing launcher-only behavior). Previous: 0.1.4.
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>
<OutputType>WinExe</OutputType>
<TargetFramework>net10.0-windows7.0</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
@ -11,6 +17,8 @@
<RootNamespace>RynthCore.App.Avalonia</RootNamespace>
<AssemblyName>RynthCore.App.Avalonia</AssemblyName>
<RuntimeIdentifiers>win-x86</RuntimeIdentifiers>
<!-- Build-Installer.ps1 publishes self-contained so RynthCore.exe does not require a machine-wide
.NET 10 Desktop Runtime. Local dotnet build or dotnet run still use the SDK. -->
<ApplicationIcon>LogoCore.ico</ApplicationIcon>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
@ -25,10 +33,14 @@
<PackageReference Include="Avalonia.Desktop" Version="11.2.3" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.3" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.3" />
<!-- Avalonia pulls Tmds.DBus.Protocol 0.20.0 (GHSA-xrw6-gwf8-vvr9; D-Bus is Linux-only, but pin the fixed version). -->
<!-- Direct reference overrides Avalonia's transitive 0.20.x (NU1903 / GHSA-xrw6-gwf8-vvr9). -->
<PackageReference Include="Tmds.DBus.Protocol" Version="0.21.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RynthCore.DesktopLog\RynthCore.DesktopLog.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\RynthCore.App\LaunchServerProfile.cs" Link="Shared\LaunchServerProfile.cs" />
<Compile Include="..\RynthCore.App\LaunchAccountProfile.cs" Link="Shared\LaunchAccountProfile.cs" />
@ -36,6 +48,7 @@
<Compile Include="..\RynthCore.App\InjectionMode.cs" Link="Shared\InjectionMode.cs" />
<Compile Include="..\RynthCore.App\DecalLocator.cs" Link="Shared\DecalLocator.cs" />
<Compile Include="..\RynthCore.App\DecalBridgeRegistration.cs" Link="Shared\DecalBridgeRegistration.cs" />
<Compile Include="..\RynthCore.App\FolderAccess.cs" Link="Shared\FolderAccess.cs" />
<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" />
@ -58,6 +71,7 @@
<ItemGroup>
<!-- Install-folder resolver (env, HKCU, HKLM, default C:\Games). Read only; same file in RynthSuite Plugins\Shared. -->
<Compile Include="..\Shared\RynthInstallPaths.cs" Link="Shared\RynthInstallPaths.cs" />
<Compile Include="..\Shared\DumpInProgressRule.cs" Link="Shared\DumpInProgressRule.cs" />
</ItemGroup>
</Project>

View file

@ -22,7 +22,8 @@ namespace RynthCore.App.Avalonia;
/// - the RynthCore version;
/// - the enabled plugins the update feed ships (RynthSuite), with their versions; other plugins
/// only as a count, never by name (a private plugin's name could identify its author);
/// - how many crash_*.dmp files the engine wrote since the last report (a count only);
/// - how many crash dumps were written since the last report (a count only): the engine's
/// Logs\dumps\crash_*.dmp and CoreCLR's Logs\dumps\clr_*.dmp;
/// - the Windows major version ("10" or "11").
/// Never: character, account or server names, file paths, or anything else identifying.
///
@ -221,18 +222,30 @@ internal sealed class UsageStats
return "other";
}
/// <summary>crash_*.dmp files written after <paramref name="sinceUtc"/> (hang dumps are not crashes).</summary>
/// <summary>
/// Crash dump names counted: the engine's crash_*.dmp and the CoreCLR fatal-error dumps the
/// loader asks for in the same folder (clr_*.dmp, Loader.c ConfigureCrashDumps).
/// </summary>
private static readonly string[] CrashDumpPatterns = { "crash_*.dmp", "clr_*.dmp" };
/// <summary>
/// Crash dumps (crash_*.dmp, clr_*.dmp) written after <paramref name="sinceUtc"/>. Hang dumps
/// and the OUT OF MEMORY dumps are not crashes.
/// </summary>
public static int CountCrashDumps(string dir, DateTime sinceUtc, DateTime utcNow)
{
try
{
if (!Directory.Exists(dir)) return 0;
int n = 0;
foreach (string f in Directory.EnumerateFiles(dir, "crash_*.dmp"))
foreach (string pattern in CrashDumpPatterns)
{
DateTime t = File.GetLastWriteTimeUtc(f);
if (t > sinceUtc && t <= utcNow.AddMinutes(5)) n++;
if (n >= MaxCrashes) break;
foreach (string f in Directory.EnumerateFiles(dir, pattern))
{
DateTime t = File.GetLastWriteTimeUtc(f);
if (t > sinceUtc && t <= utcNow.AddMinutes(5)) n++;
if (n >= MaxCrashes) return n;
}
}
return n;
}