Skip to content

Commit a826640

Browse files
authored
Preview 1.82.6 Release (#623)
# What's new? - 1.82.6 - **[Fix]** Download corruption due to download chunk size being too small, by @neon-nyan - **[Fix]** Double taskbar entry if console is enabled, by @bagusnl - **[Fix]** Repair function for GI/SR/HI3 detected updated plugin as corrupted, by @bagusnl - **[Imp]** Update 7z dll to 24.09, by @neon-nyan - **[Imp]** Http downloader module improvements, by @neon-nyan - Bypass drive write cache - Use multi threaded file writer - **[Imp]** ``IniFile`` parser improvements, by @neon-nyan + Improving implicit casting on IniValue to numbers This to allow maintainers to directly assign the IniValue to variable types. + Reduce memory allocation on loading and saving IniFile + Improving saving performance to file or a stream. + More safety bound check to IniSection + Reduce overhead on checking Section Keys and Value Keys + Add more checks on loading values + Splitting class and structs into their own files ## ```IniFile``` benchmark (Old vs. New) ### Note There might be some minor performance degradation on Loading mechanism due to additional check overhead. More work will be implemented later to fix this. | Method | Mean Time | Ratio | Time Imp (%) | Allocated Mem. | Ratio | Mem. Imp (%) | |----------------- |-----------:|-----------:|----------------------:|------------:|------------:|-----------------------:| | Load_Old | 77.85 µs | 1.000 | - | 217.3 KB | 1.000 | - | | Load_New | 80.80 µs | 1.038 | -3.8% | 138.3 KB | 0.637 | +36.4% | | Load_OrderedNew | 79.73 µs | 1.024 | -2.4% | 138.3 KB | 0.637 | +36.4% | | Save_Old | 0.10 µs | 1.000 | - | 2.2 KB | 1.000 | - | | Save_New | 0.06 µs | 0.630 | +37.0% | 0.4 KB | 0.181 | +81.8% | | Save_OrderedNew | 0.06 µs | 0.665 | +33.5% | 0.4 KB | 0.181 | +81.8% | ### Templates <details> <summary>Changelog Prefixes</summary> ``` **[New]** **[Imp]** **[Fix]** **[Loc]** **[Doc]** ``` </details>
2 parents 626989f + c7e6bfe commit a826640

32 files changed

+1025
-1129
lines changed

CollapseLauncher.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
<s:Boolean x:Key="/Default/UserDictionary/Words/=Shcore/@EntryIndexedValue">True</s:Boolean>
7979
<s:Boolean x:Key="/Default/UserDictionary/Words/=starrail/@EntryIndexedValue">True</s:Boolean>
8080
<s:Boolean x:Key="/Default/UserDictionary/Words/=transcoded/@EntryIndexedValue">True</s:Boolean>
81+
<s:Boolean x:Key="/Default/UserDictionary/Words/=velopack/@EntryIndexedValue">True</s:Boolean>
8182
<s:Boolean x:Key="/Default/UserDictionary/Words/=yoverse/@EntryIndexedValue">True</s:Boolean>
8283
<s:Boolean x:Key="/Default/UserDictionary/Words/=zenless/@EntryIndexedValue">True</s:Boolean>
8384
</wpf:ResourceDictionary>

CollapseLauncher/Classes/GameManagement/GameVersion/BaseClass/GameVersionBase.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -831,9 +831,9 @@ protected virtual bool IsGameConfigIdValid()
831831
|| !isCps)
832832
return false;
833833

834-
string? channelIdCurrent = GameIniVersion[_defaultIniVersionSection][ChannelIdKeyName].ToString();
835-
string? subChannelIdCurrent = GameIniVersion[_defaultIniVersionSection][SubChannelIdKeyName].ToString();
836-
string? cpsCurrent = GameIniVersion[_defaultIniVersionSection][CpsKeyName].ToString();
834+
string? channelIdCurrent = GameIniVersion[_defaultIniVersionSection][ChannelIdKeyName];
835+
string? subChannelIdCurrent = GameIniVersion[_defaultIniVersionSection][SubChannelIdKeyName];
836+
string? cpsCurrent = GameIniVersion[_defaultIniVersionSection][CpsKeyName];
837837

838838
if (!int.TryParse(channelIdCurrent, null, out int channelIdCurrentInt)
839839
|| !int.TryParse(subChannelIdCurrent, null, out int subChannelIdCurrentInt)
@@ -1183,7 +1183,7 @@ private void InitializeIniProp(string iniFilePath, in IniFile ini, IniSection de
11831183
// Load the INI file.
11841184
if (IsDiskReady)
11851185
{
1186-
ini.Load(iniFilePath, false, true);
1186+
ini.Load(iniFilePath);
11871187
}
11881188

11891189
// Initialize and ensure the non-existed values to their defaults.
@@ -1196,7 +1196,7 @@ private void InitializeIniProp(string iniFilePath, in IniFile ini, IniSection de
11961196
private void InitializeIniDefaults(in IniFile ini, IniSection defaults, string section, bool allowOverwriteUnmatchValues)
11971197
{
11981198
// If the section doesn't exist, then add the section.
1199-
if (!ini.ContainsSection(section))
1199+
if (!ini.ContainsKey(section))
12001200
{
12011201
ini.Add(section);
12021202
}

CollapseLauncher/Classes/Helper/Database/DBConfig.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections.Generic;
55
using System.Diagnostics;
66
using System.IO;
7+
using System.Threading;
78

89
namespace CollapseLauncher.Helper.Database
910
{
@@ -26,7 +27,7 @@ public static void Init()
2627
{
2728
EnsureConfigExist();
2829
Load();
29-
if (!_config.ContainsSection(DbSectionName))
30+
if (!_config.ContainsKey(DbSectionName))
3031
_config.Add(DbSectionName, DbSettingsTemplate);
3132

3233
DefaultChecker();
@@ -45,15 +46,15 @@ private static void DefaultChecker()
4546
foreach (KeyValuePair<string, IniValue> Entry in DbSettingsTemplate)
4647
{
4748
if (!_config[DbSectionName].ContainsKey(Entry.Key) ||
48-
string.IsNullOrEmpty(_config[DbSectionName][Entry.Key].Value))
49+
string.IsNullOrEmpty(_config[DbSectionName][Entry.Key]))
4950
{
5051
SetValue(Entry.Key, Entry.Value);
5152
}
5253
}
5354
}
5455

55-
private static void Load() => _config.Load(_configPath);
56-
private static void Save() => _config.Save(_configPath);
56+
private static void Load(CancellationToken token = default) => _config.Load(_configPath);
57+
private static void Save(CancellationToken token = default) => _config.Save(_configPath);
5758

5859
public static IniValue GetConfig(string key) => _config[DbSectionName][key];
5960

@@ -77,23 +78,23 @@ public static void SetAndSaveValue(string key, IniValue value)
7778

7879
public static bool DbEnabled
7980
{
80-
get => GetConfig("enabled").ToBool();
81+
get => GetConfig("enabled");
8182
set => SetAndSaveValue("enabled", value);
8283
}
8384

8485
[DebuggerHidden]
8586
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
8687
public static string DbUrl
8788
{
88-
get => GetConfig("url").ToString();
89+
get => GetConfig("url");
8990
set => SetAndSaveValue("url", value);
9091
}
9192

9293
[DebuggerHidden]
9394
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
9495
public static string DbToken
9596
{
96-
get => GetConfig("token").ToString();
97+
get => GetConfig("token");
9798
set => SetAndSaveValue("token", value);
9899
}
99100

@@ -103,7 +104,7 @@ public static string UserGuid
103104
{
104105
get
105106
{
106-
var c = GetConfig("userGuid").ToString();
107+
var c = GetConfig("userGuid");
107108

108109
if (!string.IsNullOrEmpty(c)) return c; // Return early if config is set
109110

CollapseLauncher/Classes/RegionManagement/FallbackCDNUtil.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ public static async Task DownloadCDNFallbackContent(DownloadClient downloadClien
172172
{
173173
// Get the preferred CDN first and try get the content
174174
CDNURLProperty preferredCDN = GetPreferredCDN();
175-
SentryHelper.AppCdnOption = preferredCDN.Name;
176175
bool isSuccess = await TryGetCDNContent(preferredCDN, downloadClient, outputPath, relativeURL, parallelThread, token);
177176

178177
// If successful, then return
@@ -352,7 +351,8 @@ private static async ValueTask<bool> TryGetCDNContent(CDNURLProperty cdnProp, Do
352351

353352
try
354353
{
355-
// Get the URL Status then return boolean and and URLStatus
354+
SentryHelper.AppCdnOption = cdnProp.URLPrefix;
355+
// Get the URL Status then return boolean and URLStatus
356356
(bool, string) urlStatus = await TryGetURLStatus(cdnProp, downloadClient, relativeURL, token);
357357

358358
// If URL status is false, then return false

CollapseLauncher/Classes/RepairManagement/Genshin/Fetch.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,23 @@ private async ValueTask<List<PkgVersionProperties>> Fetch(List<PkgVersionPropert
7272

7373
private void EliminatePluginAssetIndex(List<PkgVersionProperties> assetIndex)
7474
{
75-
_gameVersionManager.GameAPIProp.data?.plugins?.ForEach(plugin =>
76-
{
77-
assetIndex.RemoveAll(asset =>
78-
{
79-
return plugin.package?.validate?.Exists(validate => validate.path == asset.remoteName) ?? false;
80-
});
81-
});
75+
_gameVersionManager.GameAPIProp.data!.plugins?.ForEach(plugin =>
76+
{
77+
if (plugin.package?.validate == null) return;
78+
79+
assetIndex.RemoveAll(asset =>
80+
{
81+
var r = plugin.package.validate.Any(validate => validate.path != null &&
82+
asset.localName
83+
.Contains(validate.path));
84+
if (r)
85+
{
86+
LogWriteLine($"[EliminatePluginAssetIndex] Removed: {asset.localName}", LogType.Warning,
87+
true);
88+
}
89+
return r;
90+
});
91+
});
8292
}
8393

8494
private List<PkgVersionProperties> EliminateUnnecessaryAssetIndex(IEnumerable<PkgVersionProperties> assetIndex)

CollapseLauncher/Classes/RepairManagement/Honkai/Fetch.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,20 @@ private async ValueTask ThrowIfFileIsNotSenadina(Stream stream, CancellationToke
226226

227227
private void EliminatePluginAssetIndex(List<FilePropertiesRemote> assetIndex)
228228
{
229-
_gameVersionManager!.GameAPIProp?.data?.plugins?.ForEach(plugin =>
230-
{
231-
assetIndex!.RemoveAll(asset =>
232-
{
233-
return plugin!.package!.validate?.Exists(validate => validate!.path == asset!.N) ?? false;
234-
});
235-
});
229+
_gameVersionManager.GameAPIProp.data!.plugins?.ForEach(plugin =>
230+
{
231+
if (plugin.package?.validate == null) return;
232+
233+
assetIndex.RemoveAll(asset =>
234+
{
235+
var r = plugin.package.validate.Any(validate => validate.path != null && asset.N.Contains(validate.path));
236+
if (r)
237+
{
238+
LogWriteLine($"[EliminatePluginAssetIndex] Removed: {asset.N}", LogType.Warning, true);
239+
}
240+
return r;
241+
});
242+
});
236243
}
237244

238245
#region Registry Utils

CollapseLauncher/Classes/RepairManagement/StarRail/Check.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Hi3Helper.SentryHelper;
44
using Hi3Helper.Shared.ClassStruct;
55
using Hi3Helper.Win32.Native.LibraryImport;
6-
using HtmlAgilityPack;
76
using System;
87
using System.Collections.Generic;
98
using System.IO;

CollapseLauncher/Classes/RepairManagement/StarRail/Fetch.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,20 @@ await Task.WhenAll(
147147

148148
private void EliminatePluginAssetIndex(List<FilePropertiesRemote> assetIndex)
149149
{
150-
_gameVersionManager.GameAPIProp.data?.plugins?.ForEach(plugin =>
151-
{
152-
assetIndex.RemoveAll(asset =>
153-
{
154-
return plugin.package?.validate?.Exists(validate => validate.path == asset.N) ?? false;
155-
});
156-
});
150+
_gameVersionManager.GameAPIProp.data!.plugins?.ForEach(plugin =>
151+
{
152+
if (plugin.package?.validate == null) return;
153+
154+
assetIndex.RemoveAll(asset =>
155+
{
156+
var r = plugin.package.validate.Any(validate => validate.path != null && asset.N.Contains(validate.path));
157+
if (r)
158+
{
159+
LogWriteLine($"[EliminatePluginAssetIndex] Removed: {asset.N}", LogType.Warning, true);
160+
}
161+
return r;
162+
});
163+
});
157164
}
158165

159166
#region PrimaryManifest

CollapseLauncher/CollapseLauncher.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<Authors>$(Company). neon-nyan, Cry0, bagusnl, shatyuka, gablm.</Authors>
1717
<Copyright>Copyright 2022-2024 $(Company)</Copyright>
1818
<!-- Versioning -->
19-
<Version>1.82.5</Version>
19+
<Version>1.82.6</Version>
2020
<LangVersion>preview</LangVersion>
2121
<!-- Target Settings -->
2222
<Platforms>x64</Platforms>
@@ -157,8 +157,8 @@
157157
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
158158
<PackageReference Include="Velopack" Version="0.0.942" Condition="$(DefineConstants.Contains('USEVELOPACK'))" />
159159

160-
<PackageReference Include="CommunityToolkit.Common" Version="8.4.0-preview3" />
161-
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0-preview3" />
160+
<PackageReference Include="CommunityToolkit.Common" Version="8.4.0" />
161+
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
162162
<PackageReference Include="CommunityToolkit.WinUI.Behaviors" Version="8.2.241112-preview1" />
163163
<PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.2.241112-preview1" />
164164
<PackageReference Include="CommunityToolkit.WinUI.Media" Version="8.2.241112-preview1" />

CollapseLauncher/Program.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ public static void Main(params string[] args)
7474
AppIconLarge = largeIcons[0];
7575
AppIconSmall = smallIcons[0];
7676
}
77+
78+
// Set AUMID
79+
PInvoke.SetProcessAumid("velopack.CollapseLauncher");
7780

7881
WindowUtility.CurrentScreenProp = new Hi3Helper.Win32.Screen.ScreenProp();
7982
InitAppPreset(WindowUtility.CurrentScreenProp);
@@ -88,13 +91,15 @@ public static void Main(params string[] args)
8891
LogType.Warning, true);
8992
Directory.SetCurrentDirectory(AppFolder);
9093
}
91-
92-
94+
95+
InitializeAppSettings();
96+
9397
SentryHelper.IsPreview = IsPreview;
9498
#pragma warning disable CS0618 // Type or member is obsolete
9599
SentryHelper.AppBuildCommit = ThisAssembly.Git.Sha;
96100
SentryHelper.AppBuildBranch = ThisAssembly.Git.Branch;
97101
SentryHelper.AppBuildRepo = ThisAssembly.Git.RepositoryUrl;
102+
SentryHelper.AppCdnOption = FallbackCDNUtil.GetPreferredCDN().URLPrefix;
98103
#pragma warning restore CS0618 // Type or member is obsolete
99104
if (SentryHelper.IsEnabled)
100105
{
@@ -137,7 +142,6 @@ public static void Main(params string[] args)
137142
Process.GetCurrentProcess().PriorityBoostEnabled = true;
138143

139144
ParseArguments(args);
140-
InitializeAppSettings();
141145

142146
// Initiate InnoSetupHelper's log event
143147
InnoSetupLogUpdate.LoggerEvent += InnoSetupLogUpdate_LoggerEvent;

0 commit comments

Comments
 (0)