From 6a7d1f144c0a15ec0674d7a0f62efcd25d8bcd8c Mon Sep 17 00:00:00 2001 From: Cinka Date: Thu, 1 May 2025 20:58:43 +0300 Subject: [PATCH] - fix: fix runner path --- .../ViewModels/ServerEntryModelView.cs | 4 +- .../Services/ConfigurationService.cs | 41 +++++++++++++------ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/Nebula.Launcher/ViewModels/ServerEntryModelView.cs b/Nebula.Launcher/ViewModels/ServerEntryModelView.cs index d5c319a..63d0d63 100644 --- a/Nebula.Launcher/ViewModels/ServerEntryModelView.cs +++ b/Nebula.Launcher/ViewModels/ServerEntryModelView.cs @@ -179,10 +179,12 @@ public partial class ServerEntryModelView : ViewModelBase await RunnerService.PrepareRun(buildInfo, loadingContext, CancellationService.Token); + var path = Path.GetDirectoryName(Environment.ProcessPath); + Process = Process.Start(new ProcessStartInfo { FileName = "dotnet.exe", - Arguments = "./Nebula.Runner.dll", + Arguments = Path.Join(path, "Nebula.Runner.dll"), Environment = { { "ROBUST_AUTH_USERID", authProv?.UserId.ToString() }, diff --git a/Nebula.Shared/Services/ConfigurationService.cs b/Nebula.Shared/Services/ConfigurationService.cs index 4cda5fa..cdea71a 100644 --- a/Nebula.Shared/Services/ConfigurationService.cs +++ b/Nebula.Shared/Services/ConfigurationService.cs @@ -64,6 +64,34 @@ public class ConfigurationService _debugService.Log($"Using default value for config: {conVar.Name}"); return conVar.DefaultValue; } + + public bool TryGetConfigValue(ConVar conVar, + [NotNullWhen(true)] out T? value) + { + ArgumentNullException.ThrowIfNull(conVar); + value = default; + try + { + if (_fileService.ConfigurationApi.TryOpen(GetFileName(conVar), out var stream)) + using (stream) + { + var obj = JsonSerializer.Deserialize(stream); + if (obj != null) + { + _debugService.Log($"Successfully loaded config: {conVar.Name}"); + value = obj; + return true; + } + } + } + catch (Exception e) + { + _debugService.Error($"Error loading config for {conVar.Name}: {e.Message}"); + } + + _debugService.Log($"Using default value for config: {conVar.Name}"); + return false; + } public void SetConfigValue(ConVar conVar, T value) { @@ -100,17 +128,4 @@ public class ConfigurationService { return $"{conVar.Name}.json"; } -} - -public static class ConfigExtensions -{ - public static bool TryGetConfigValue(this ConfigurationService configurationService, ConVar conVar, - [NotNullWhen(true)] out T? value) - { - ArgumentNullException.ThrowIfNull(configurationService); - ArgumentNullException.ThrowIfNull(conVar); - - value = configurationService.GetConfigValue(conVar); - return value != null; - } } \ No newline at end of file