Skip to content

Commit

Permalink
Preview 1.82.6 Release (#623)
Browse files Browse the repository at this point in the history
# 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>
  • Loading branch information
Cryotechnic authored Dec 16, 2024
2 parents 626989f + c7e6bfe commit a826640
Show file tree
Hide file tree
Showing 32 changed files with 1,025 additions and 1,129 deletions.
1 change: 1 addition & 0 deletions CollapseLauncher.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Shcore/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=starrail/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=transcoded/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=velopack/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=yoverse/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=zenless/@EntryIndexedValue">True</s:Boolean>
</wpf:ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -831,9 +831,9 @@ protected virtual bool IsGameConfigIdValid()
|| !isCps)
return false;

string? channelIdCurrent = GameIniVersion[_defaultIniVersionSection][ChannelIdKeyName].ToString();
string? subChannelIdCurrent = GameIniVersion[_defaultIniVersionSection][SubChannelIdKeyName].ToString();
string? cpsCurrent = GameIniVersion[_defaultIniVersionSection][CpsKeyName].ToString();
string? channelIdCurrent = GameIniVersion[_defaultIniVersionSection][ChannelIdKeyName];
string? subChannelIdCurrent = GameIniVersion[_defaultIniVersionSection][SubChannelIdKeyName];
string? cpsCurrent = GameIniVersion[_defaultIniVersionSection][CpsKeyName];

if (!int.TryParse(channelIdCurrent, null, out int channelIdCurrentInt)
|| !int.TryParse(subChannelIdCurrent, null, out int subChannelIdCurrentInt)
Expand Down Expand Up @@ -1183,7 +1183,7 @@ private void InitializeIniProp(string iniFilePath, in IniFile ini, IniSection de
// Load the INI file.
if (IsDiskReady)
{
ini.Load(iniFilePath, false, true);
ini.Load(iniFilePath);
}

// Initialize and ensure the non-existed values to their defaults.
Expand All @@ -1196,7 +1196,7 @@ private void InitializeIniProp(string iniFilePath, in IniFile ini, IniSection de
private void InitializeIniDefaults(in IniFile ini, IniSection defaults, string section, bool allowOverwriteUnmatchValues)
{
// If the section doesn't exist, then add the section.
if (!ini.ContainsSection(section))
if (!ini.ContainsKey(section))
{
ini.Add(section);
}
Expand Down
17 changes: 9 additions & 8 deletions CollapseLauncher/Classes/Helper/Database/DBConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading;

namespace CollapseLauncher.Helper.Database
{
Expand All @@ -26,7 +27,7 @@ public static void Init()
{
EnsureConfigExist();
Load();
if (!_config.ContainsSection(DbSectionName))
if (!_config.ContainsKey(DbSectionName))
_config.Add(DbSectionName, DbSettingsTemplate);

DefaultChecker();
Expand All @@ -45,15 +46,15 @@ private static void DefaultChecker()
foreach (KeyValuePair<string, IniValue> Entry in DbSettingsTemplate)
{
if (!_config[DbSectionName].ContainsKey(Entry.Key) ||
string.IsNullOrEmpty(_config[DbSectionName][Entry.Key].Value))
string.IsNullOrEmpty(_config[DbSectionName][Entry.Key]))
{
SetValue(Entry.Key, Entry.Value);
}
}
}

private static void Load() => _config.Load(_configPath);
private static void Save() => _config.Save(_configPath);
private static void Load(CancellationToken token = default) => _config.Load(_configPath);
private static void Save(CancellationToken token = default) => _config.Save(_configPath);

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

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

public static bool DbEnabled
{
get => GetConfig("enabled").ToBool();
get => GetConfig("enabled");
set => SetAndSaveValue("enabled", value);
}

[DebuggerHidden]
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public static string DbUrl
{
get => GetConfig("url").ToString();
get => GetConfig("url");
set => SetAndSaveValue("url", value);
}

[DebuggerHidden]
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public static string DbToken
{
get => GetConfig("token").ToString();
get => GetConfig("token");
set => SetAndSaveValue("token", value);
}

Expand All @@ -103,7 +104,7 @@ public static string UserGuid
{
get
{
var c = GetConfig("userGuid").ToString();
var c = GetConfig("userGuid");

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

Expand Down
4 changes: 2 additions & 2 deletions CollapseLauncher/Classes/RegionManagement/FallbackCDNUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ public static async Task DownloadCDNFallbackContent(DownloadClient downloadClien
{
// Get the preferred CDN first and try get the content
CDNURLProperty preferredCDN = GetPreferredCDN();
SentryHelper.AppCdnOption = preferredCDN.Name;
bool isSuccess = await TryGetCDNContent(preferredCDN, downloadClient, outputPath, relativeURL, parallelThread, token);

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

try
{
// Get the URL Status then return boolean and and URLStatus
SentryHelper.AppCdnOption = cdnProp.URLPrefix;
// Get the URL Status then return boolean and URLStatus
(bool, string) urlStatus = await TryGetURLStatus(cdnProp, downloadClient, relativeURL, token);

// If URL status is false, then return false
Expand Down
24 changes: 17 additions & 7 deletions CollapseLauncher/Classes/RepairManagement/Genshin/Fetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,23 @@ private async ValueTask<List<PkgVersionProperties>> Fetch(List<PkgVersionPropert

private void EliminatePluginAssetIndex(List<PkgVersionProperties> assetIndex)
{
_gameVersionManager.GameAPIProp.data?.plugins?.ForEach(plugin =>
{
assetIndex.RemoveAll(asset =>
{
return plugin.package?.validate?.Exists(validate => validate.path == asset.remoteName) ?? false;
});
});
_gameVersionManager.GameAPIProp.data!.plugins?.ForEach(plugin =>
{
if (plugin.package?.validate == null) return;

assetIndex.RemoveAll(asset =>
{
var r = plugin.package.validate.Any(validate => validate.path != null &&
asset.localName
.Contains(validate.path));
if (r)
{
LogWriteLine($"[EliminatePluginAssetIndex] Removed: {asset.localName}", LogType.Warning,
true);
}
return r;
});
});
}

private List<PkgVersionProperties> EliminateUnnecessaryAssetIndex(IEnumerable<PkgVersionProperties> assetIndex)
Expand Down
21 changes: 14 additions & 7 deletions CollapseLauncher/Classes/RepairManagement/Honkai/Fetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,20 @@ private async ValueTask ThrowIfFileIsNotSenadina(Stream stream, CancellationToke

private void EliminatePluginAssetIndex(List<FilePropertiesRemote> assetIndex)
{
_gameVersionManager!.GameAPIProp?.data?.plugins?.ForEach(plugin =>
{
assetIndex!.RemoveAll(asset =>
{
return plugin!.package!.validate?.Exists(validate => validate!.path == asset!.N) ?? false;
});
});
_gameVersionManager.GameAPIProp.data!.plugins?.ForEach(plugin =>
{
if (plugin.package?.validate == null) return;

assetIndex.RemoveAll(asset =>
{
var r = plugin.package.validate.Any(validate => validate.path != null && asset.N.Contains(validate.path));
if (r)
{
LogWriteLine($"[EliminatePluginAssetIndex] Removed: {asset.N}", LogType.Warning, true);
}
return r;
});
});
}

#region Registry Utils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Hi3Helper.SentryHelper;
using Hi3Helper.Shared.ClassStruct;
using Hi3Helper.Win32.Native.LibraryImport;
using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down
21 changes: 14 additions & 7 deletions CollapseLauncher/Classes/RepairManagement/StarRail/Fetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,20 @@ await Task.WhenAll(

private void EliminatePluginAssetIndex(List<FilePropertiesRemote> assetIndex)
{
_gameVersionManager.GameAPIProp.data?.plugins?.ForEach(plugin =>
{
assetIndex.RemoveAll(asset =>
{
return plugin.package?.validate?.Exists(validate => validate.path == asset.N) ?? false;
});
});
_gameVersionManager.GameAPIProp.data!.plugins?.ForEach(plugin =>
{
if (plugin.package?.validate == null) return;

assetIndex.RemoveAll(asset =>
{
var r = plugin.package.validate.Any(validate => validate.path != null && asset.N.Contains(validate.path));
if (r)
{
LogWriteLine($"[EliminatePluginAssetIndex] Removed: {asset.N}", LogType.Warning, true);
}
return r;
});
});
}

#region PrimaryManifest
Expand Down
6 changes: 3 additions & 3 deletions CollapseLauncher/CollapseLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<Authors>$(Company). neon-nyan, Cry0, bagusnl, shatyuka, gablm.</Authors>
<Copyright>Copyright 2022-2024 $(Company)</Copyright>
<!-- Versioning -->
<Version>1.82.5</Version>
<Version>1.82.6</Version>
<LangVersion>preview</LangVersion>
<!-- Target Settings -->
<Platforms>x64</Platforms>
Expand Down Expand Up @@ -157,8 +157,8 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
<PackageReference Include="Velopack" Version="0.0.942" Condition="$(DefineConstants.Contains('USEVELOPACK'))" />

<PackageReference Include="CommunityToolkit.Common" Version="8.4.0-preview3" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0-preview3" />
<PackageReference Include="CommunityToolkit.Common" Version="8.4.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageReference Include="CommunityToolkit.WinUI.Behaviors" Version="8.2.241112-preview1" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.2.241112-preview1" />
<PackageReference Include="CommunityToolkit.WinUI.Media" Version="8.2.241112-preview1" />
Expand Down
10 changes: 7 additions & 3 deletions CollapseLauncher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public static void Main(params string[] args)
AppIconLarge = largeIcons[0];
AppIconSmall = smallIcons[0];
}

// Set AUMID
PInvoke.SetProcessAumid("velopack.CollapseLauncher");

WindowUtility.CurrentScreenProp = new Hi3Helper.Win32.Screen.ScreenProp();
InitAppPreset(WindowUtility.CurrentScreenProp);
Expand All @@ -88,13 +91,15 @@ public static void Main(params string[] args)
LogType.Warning, true);
Directory.SetCurrentDirectory(AppFolder);
}



InitializeAppSettings();

SentryHelper.IsPreview = IsPreview;
#pragma warning disable CS0618 // Type or member is obsolete
SentryHelper.AppBuildCommit = ThisAssembly.Git.Sha;
SentryHelper.AppBuildBranch = ThisAssembly.Git.Branch;
SentryHelper.AppBuildRepo = ThisAssembly.Git.RepositoryUrl;
SentryHelper.AppCdnOption = FallbackCDNUtil.GetPreferredCDN().URLPrefix;
#pragma warning restore CS0618 // Type or member is obsolete
if (SentryHelper.IsEnabled)
{
Expand Down Expand Up @@ -137,7 +142,6 @@ public static void Main(params string[] args)
Process.GetCurrentProcess().PriorityBoostEnabled = true;

ParseArguments(args);
InitializeAppSettings();

// Initiate InnoSetupHelper's log event
InnoSetupLogUpdate.LoggerEvent += InnoSetupLogUpdate_LoggerEvent;
Expand Down
6 changes: 3 additions & 3 deletions CollapseLauncher/XAMLs/MainApp/DisconnectedPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public DisconnectedPage()
private void InitializeRegionComboBox()
{
ComboBoxGameCategory.ItemsSource = InnerLauncherConfig.BuildGameTitleListUI();
string gameName = LauncherConfig.GetAppConfigValue("GameCategory").ToString();

#nullable enable
string? gameName = LauncherConfig.GetAppConfigValue("GameCategory");

List<string>? gameCollection = LauncherMetadataHelper.GetGameNameCollection()!;
List<string>? regionCollection = LauncherMetadataHelper.GetGameRegionCollection(gameName)!;
List<string?>? regionCollection = LauncherMetadataHelper.GetGameRegionCollection(gameName ?? "");

if (regionCollection == null)
gameName = LauncherMetadataHelper.LauncherGameNameRegionCollection?.Keys.FirstOrDefault();
Expand Down
18 changes: 9 additions & 9 deletions CollapseLauncher/XAMLs/MainApp/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,18 +1135,18 @@ private async void ForceShowNotificationPanel()
{
ComboBoxGameCategory.ItemsSource = BuildGameTitleListUI();

string gameName = GetAppConfigValue("GameCategory").ToString();
string gameName = GetAppConfigValue("GameCategory")!;

#nullable enable
List<string>? gameCollection = LauncherMetadataHelper.GetGameNameCollection()!;
List<string>? regionCollection = LauncherMetadataHelper.GetGameRegionCollection(gameName)!;
List<string>? gameCollection = LauncherMetadataHelper.GetGameNameCollection();
List<string?>? regionCollection = LauncherMetadataHelper.GetGameRegionCollection(gameName);

if (regionCollection == null)
gameName = LauncherMetadataHelper.LauncherGameNameRegionCollection?.Keys.FirstOrDefault();

ComboBoxGameRegion.ItemsSource = BuildGameRegionListUI(gameName);

var indexCategory = gameCollection.IndexOf(gameName!);
var indexCategory = gameCollection?.IndexOf(gameName!) ?? -1;
if (indexCategory < 0) indexCategory = 0;

var indexRegion = LauncherMetadataHelper.GetPreviousGameRegion(gameName);
Expand Down Expand Up @@ -1931,12 +1931,12 @@ private async void DisableKbShortcuts(int time = 500)

private void RestoreCurrentRegion()
{
var gameName = GetAppConfigValue("GameCategory").ToString();
string gameName = GetAppConfigValue("GameCategory")!;
#nullable enable
List<string>? gameNameCollection = LauncherMetadataHelper.GetGameNameCollection()!;
_ = LauncherMetadataHelper.GetGameRegionCollection(gameName)!;
List<string>? gameNameCollection = LauncherMetadataHelper.GetGameNameCollection();
_ = LauncherMetadataHelper.GetGameRegionCollection(gameName);

var indexCategory = gameNameCollection.IndexOf(gameName!);
var indexCategory = gameNameCollection?.IndexOf(gameName!) ?? -1;
if (indexCategory < 0) indexCategory = 0;

var indexRegion = LauncherMetadataHelper.GetPreviousGameRegion(gameName);
Expand Down Expand Up @@ -2205,7 +2205,7 @@ private bool SetActivatedRegion()
var args = m_arguments.StartGame;
if (args == null) return true;

string oldGameCategory = GetAppConfigValue("GameCategory").ToString();
string? oldGameCategory = GetAppConfigValue("GameCategory");

string gameName = args.Game;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ internal bool IsSourceGameExist(PresetConfig Profile)
SourceIniVersionFile.Load(SourceINIVersionPath);

// Check if the version value exist and matches
if (!(SourceIniVersionFile.ContainsSection("General") && SourceIniVersionFile["General"].ContainsKey("game_version"))) return false;
if (!(SourceIniVersionFile.ContainsKey("General") && SourceIniVersionFile["General"].ContainsKey("game_version"))) return false;
string localVersionString = SourceIniVersionFile["General"]["game_version"].ToString();
if (string.IsNullOrEmpty(localVersionString)) return false;
GameVersion localVersion = new GameVersion(localVersionString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ private int SelectedWindowSizeProfile

private static int GetInitialTheme()
{
string themeValue = GetAppConfigValue("ThemeMode").ToString();
string? themeValue = GetAppConfigValue("ThemeMode").ToString();
if (Enum.TryParse(themeValue, true, out CurrentAppTheme)) return (int)CurrentAppTheme;

CurrentAppTheme = !PInvoke.ShouldAppsUseDarkMode() ? AppThemeMode.Light : AppThemeMode.Dark;
Expand Down Expand Up @@ -779,7 +779,7 @@ private int SelectedLangIndex
{
if (value < 0) return;
var langID = LanguageIDIndex[value].ToLower();
if (langID == GetAppConfigValue("AppLanguage").ToString().ToLower()) return;
if (langID == GetAppConfigValue("AppLanguage").ToString()?.ToLower()) return;
SetAppConfigValue("AppLanguage", langID);
LoadLocale(langID);
PrintCDNList();
Expand Down
Loading

0 comments on commit a826640

Please sign in to comment.