From d141ec23dc048a6e68f1879ca5aa2d6694779346 Mon Sep 17 00:00:00 2001 From: Timerix Date: Sun, 29 Dec 2024 01:26:41 +0500 Subject: [PATCH] bugfixes --- Mlaumcherb.Client.Avalonia/GameVersion.cs | 6 ++++-- .../классы/Пролетариат/GameArguments.cs | 2 +- .../классы/Пролетариат/JavaArguments.cs | 9 +++++++-- .../сеть/TaskFactories/AssetsDownloadTaskFactory.cs | 8 +++++++- ...adTaskFactory.cs => VersionJarDownloadTaskFactory.cs} | 12 ++++++------ Mlaumcherb.Client.Avalonia/холопы/PathHelper.cs | 2 +- 6 files changed, 26 insertions(+), 13 deletions(-) rename Mlaumcherb.Client.Avalonia/сеть/TaskFactories/{VersionFileDownloadTaskFactory.cs => VersionJarDownloadTaskFactory.cs} (79%) diff --git a/Mlaumcherb.Client.Avalonia/GameVersion.cs b/Mlaumcherb.Client.Avalonia/GameVersion.cs index 1ba1184..e684d4b 100644 --- a/Mlaumcherb.Client.Avalonia/GameVersion.cs +++ b/Mlaumcherb.Client.Avalonia/GameVersion.cs @@ -104,7 +104,7 @@ public class GameVersion [ new AssetsDownloadTaskFactory(_descriptor), new LibrariesDownloadTaskFactory(_descriptor, _libraries), - new VersionFileDownloadTaskFactory(_descriptor), + new VersionJarDownloadTaskFactory(_descriptor), ]; if (LauncherApp.Config.download_java) { @@ -176,7 +176,7 @@ public class GameVersion Dictionary placeholder_values = new() { { "resolution_width", "1600" }, { "resolution_height", "900" }, - { "xms", "2048" }, + { "xms", LauncherApp.Config.max_memory.ToString() }, { "xmx", LauncherApp.Config.max_memory.ToString() }, { "auth_player_name", LauncherApp.Config.player_name }, { "auth_access_token", uuid }, @@ -196,6 +196,8 @@ public class GameVersion { "game_assets", GetAssetsDir().ToString() }, { "game_directory", WorkingDirectory.ToString() }, { "natives_directory", GetNativeLibrariesDir(_descriptor.id).ToString() }, + { "library_directory", GetLibrariesDir().ToString() }, + { "classpath_separator", ";"}, { "path", GetLog4jConfigFilePath().ToString() }, { "version_name", _descriptor.id }, { "version_type", _descriptor.type }, diff --git a/Mlaumcherb.Client.Avalonia/классы/Пролетариат/GameArguments.cs b/Mlaumcherb.Client.Avalonia/классы/Пролетариат/GameArguments.cs index 7c0f243..0e01147 100644 --- a/Mlaumcherb.Client.Avalonia/классы/Пролетариат/GameArguments.cs +++ b/Mlaumcherb.Client.Avalonia/классы/Пролетариат/GameArguments.cs @@ -30,7 +30,7 @@ public class GameArguments : ArgumentsWithPlaceholders { foreach (var arg in av.value) { - if(!_raw_args.Contains(arg)) + // if(!_raw_args.Contains(arg)) _raw_args.Add(arg); } } diff --git a/Mlaumcherb.Client.Avalonia/классы/Пролетариат/JavaArguments.cs b/Mlaumcherb.Client.Avalonia/классы/Пролетариат/JavaArguments.cs index 060f8fa..242e4b7 100644 --- a/Mlaumcherb.Client.Avalonia/классы/Пролетариат/JavaArguments.cs +++ b/Mlaumcherb.Client.Avalonia/классы/Пролетариат/JavaArguments.cs @@ -21,7 +21,6 @@ public class JavaArguments : ArgumentsWithPlaceholders "-Dminecraft.client.jar=${client_jar}", "-Dminecraft.launcher.brand=${launcher_name}", "-Dminecraft.launcher.version=${launcher_version}", - "-cp", "${classpath}" ]; private static readonly string[] _enabled_features = @@ -39,11 +38,17 @@ public class JavaArguments : ArgumentsWithPlaceholders { foreach (var arg in av.value) { - if(!_raw_args.Contains(arg)) + // if(!_raw_args.Contains(arg)) _raw_args.Add(arg); } } } } + + if (!_raw_args.Contains("-cp")) + { + _raw_args.Add("-cp"); + _raw_args.Add("${classpath}"); + } } } diff --git a/Mlaumcherb.Client.Avalonia/сеть/TaskFactories/AssetsDownloadTaskFactory.cs b/Mlaumcherb.Client.Avalonia/сеть/TaskFactories/AssetsDownloadTaskFactory.cs index 5d5212f..aa512d8 100644 --- a/Mlaumcherb.Client.Avalonia/сеть/TaskFactories/AssetsDownloadTaskFactory.cs +++ b/Mlaumcherb.Client.Avalonia/сеть/TaskFactories/AssetsDownloadTaskFactory.cs @@ -37,7 +37,13 @@ public class AssetsDownloadTaskFactory : INetworkTaskFactory } private async Task CheckFilesAsync(bool checkHashes) { - if(!File.Exists(_indexFilePath)) + string assetIndexHash = ""; + if(checkHashes) + { + await using var fs = File.OpenRead(_indexFilePath); + assetIndexHash = _hasher.ComputeHash(fs).HashToString(); + } + if(!File.Exists(_indexFilePath) || (checkHashes && assetIndexHash != _descriptor.assetIndex.sha1)) { LauncherApp.Logger.LogInfo(nameof(NetworkHelper), $"started downloading asset index to '{_indexFilePath}'"); await DownloadFile(_descriptor.assetIndex.url, _indexFilePath); diff --git a/Mlaumcherb.Client.Avalonia/сеть/TaskFactories/VersionFileDownloadTaskFactory.cs b/Mlaumcherb.Client.Avalonia/сеть/TaskFactories/VersionJarDownloadTaskFactory.cs similarity index 79% rename from Mlaumcherb.Client.Avalonia/сеть/TaskFactories/VersionFileDownloadTaskFactory.cs rename to Mlaumcherb.Client.Avalonia/сеть/TaskFactories/VersionJarDownloadTaskFactory.cs index 31d8a09..bf614a8 100644 --- a/Mlaumcherb.Client.Avalonia/сеть/TaskFactories/VersionFileDownloadTaskFactory.cs +++ b/Mlaumcherb.Client.Avalonia/сеть/TaskFactories/VersionJarDownloadTaskFactory.cs @@ -7,13 +7,13 @@ using static Mlaumcherb.Client.Avalonia.сеть.NetworkHelper; namespace Mlaumcherb.Client.Avalonia.сеть.TaskFactories; -public class VersionFileDownloadTaskFactory : INetworkTaskFactory +public class VersionJarDownloadTaskFactory : INetworkTaskFactory { private GameVersionDescriptor _descriptor; private IOPath _filePath; private SHA1 _hasher; - public VersionFileDownloadTaskFactory(GameVersionDescriptor descriptor) + public VersionJarDownloadTaskFactory(GameVersionDescriptor descriptor) { _descriptor = descriptor; _filePath = PathHelper.GetVersionJarFilePath(_descriptor.id); @@ -25,7 +25,7 @@ public class VersionFileDownloadTaskFactory : INetworkTaskFactory NetworkTask? networkTask = null; if (!CheckFiles(checkHashes)) networkTask = new NetworkTask( - $"version file '{_descriptor.id}'", + $"version jar '{_descriptor.id}'", GetTotalSize(), Download ); @@ -58,10 +58,10 @@ public class VersionFileDownloadTaskFactory : INetworkTaskFactory private async Task Download(NetworkProgressReporter pr, CancellationToken ct) { if (_descriptor.downloads is null) - throw new Exception($"can't download version file '{_descriptor.id}' because it has no download url"); + throw new Exception($"can't download version jar '{_descriptor.id}' because it has no download url"); - LauncherApp.Logger.LogInfo(nameof(NetworkHelper), $"started downloading version file '{_descriptor.id}'"); + LauncherApp.Logger.LogInfo(nameof(NetworkHelper), $"started downloading version jar '{_descriptor.id}'"); await DownloadFile(_descriptor.downloads.client.url, _filePath, ct, pr.AddBytesCount); - LauncherApp.Logger.LogInfo(nameof(NetworkHelper), $"finished downloading version file '{_descriptor.id}'"); + LauncherApp.Logger.LogInfo(nameof(NetworkHelper), $"finished downloading version jar '{_descriptor.id}'"); } } \ No newline at end of file diff --git a/Mlaumcherb.Client.Avalonia/холопы/PathHelper.cs b/Mlaumcherb.Client.Avalonia/холопы/PathHelper.cs index 9f8ec45..c6f5dac 100644 --- a/Mlaumcherb.Client.Avalonia/холопы/PathHelper.cs +++ b/Mlaumcherb.Client.Avalonia/холопы/PathHelper.cs @@ -11,7 +11,7 @@ public static class PathHelper Path.Concat(GetRootFullPath(), "assets"); public static IOPath GetAssetIndexFilePath(string id) => - Path.Concat(GetAssetsDir(), $"assets/indexes/{id}.json"); + Path.Concat(GetAssetsDir(), $"indexes/{id}.json"); // this path is hardcoded in the game public static IOPath GetVersionDescriptorPath(string id) => Path.Concat(GetVersionDir(id), id + ".json");