mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix #930
This commit is contained in:
@@ -30,6 +30,36 @@ internal static partial class EnumerableExtension
|
|||||||
return (double)sum / span.Length;
|
return (double)sum / span.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static T? BinarySearch<T>(this List<T> list, Func<T, int> comparer)
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
list.BinarySearch
|
||||||
|
Span<T> span = CollectionsMarshal.AsSpan(list);
|
||||||
|
int left = 0;
|
||||||
|
int right = span.Length - 1;
|
||||||
|
|
||||||
|
while (left <= right)
|
||||||
|
{
|
||||||
|
int middle = (left + right) / 2;
|
||||||
|
ref T current = ref span[middle];
|
||||||
|
int compareResult = comparer(current);
|
||||||
|
if (compareResult == 0)
|
||||||
|
{
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
else if (compareResult < 0)
|
||||||
|
{
|
||||||
|
right = middle - 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
left = middle + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 如果传入列表不为空则原路返回,
|
/// 如果传入列表不为空则原路返回,
|
||||||
/// 如果传入列表为空返回一个空的列表
|
/// 如果传入列表为空返回一个空的列表
|
||||||
|
|||||||
@@ -1987,7 +1987,7 @@ namespace Snap.Hutao.Resource.Localization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 找不到游戏配置文件 {0} 的本地化字符串。
|
/// 查找类似 无法读取游戏配置文件 {0},可能是文件不存在 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ServiceGameSetMultiChannelConfigFileNotFound {
|
internal static string ServiceGameSetMultiChannelConfigFileNotFound {
|
||||||
get {
|
get {
|
||||||
@@ -2005,7 +2005,7 @@ namespace Snap.Hutao.Resource.Localization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 在查找必要的模块时遇到问题:无法读取任何模块,可能是保护驱动已经加载完成 的本地化字符串。
|
/// 查找类似 在查找必要的模块时遇到问题:无法读取任何模块,可能是保护驱动已经加载完成,请重试 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ServiceGameUnlockerFindModuleNoModuleFound {
|
internal static string ServiceGameUnlockerFindModuleNoModuleFound {
|
||||||
get {
|
get {
|
||||||
@@ -2014,7 +2014,7 @@ namespace Snap.Hutao.Resource.Localization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 在查找必要的模块时遇到问题:查找模块超时 的本地化字符串。
|
/// 查找类似 在查找必要的模块时遇到问题:查找模块超时,请重试 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ServiceGameUnlockerFindModuleTimeLimitExeeded {
|
internal static string ServiceGameUnlockerFindModuleTimeLimitExeeded {
|
||||||
get {
|
get {
|
||||||
@@ -3661,7 +3661,7 @@ namespace Snap.Hutao.Resource.Localization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 无法读取游戏配置文件: {0} 的本地化字符串。
|
/// 查找类似 无法读取游戏配置文件: {0},可能是文件不存在或权限不足 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ViewModelLaunchGameMultiChannelReadFail {
|
internal static string ViewModelLaunchGameMultiChannelReadFail {
|
||||||
get {
|
get {
|
||||||
|
|||||||
@@ -816,16 +816,16 @@
|
|||||||
<value>找不到 PowerShell 的安装目录</value>
|
<value>找不到 PowerShell 的安装目录</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ServiceGameSetMultiChannelConfigFileNotFound" xml:space="preserve">
|
<data name="ServiceGameSetMultiChannelConfigFileNotFound" xml:space="preserve">
|
||||||
<value>找不到游戏配置文件 {0}</value>
|
<value>无法读取游戏配置文件 {0},可能是文件不存在</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ServiceGameSetMultiChannelUnauthorizedAccess" xml:space="preserve">
|
<data name="ServiceGameSetMultiChannelUnauthorizedAccess" xml:space="preserve">
|
||||||
<value>无法读取或保存配置文件,请以管理员模式重试</value>
|
<value>无法读取或保存配置文件,请以管理员模式重试</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ServiceGameUnlockerFindModuleNoModuleFound" xml:space="preserve">
|
<data name="ServiceGameUnlockerFindModuleNoModuleFound" xml:space="preserve">
|
||||||
<value>在查找必要的模块时遇到问题:无法读取任何模块,可能是保护驱动已经加载完成</value>
|
<value>在查找必要的模块时遇到问题:无法读取任何模块,可能是保护驱动已经加载完成,请重试</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ServiceGameUnlockerFindModuleTimeLimitExeeded" xml:space="preserve">
|
<data name="ServiceGameUnlockerFindModuleTimeLimitExeeded" xml:space="preserve">
|
||||||
<value>在查找必要的模块时遇到问题:查找模块超时</value>
|
<value>在查找必要的模块时遇到问题:查找模块超时,请重试</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ServiceGameUnlockerInterestedPatternNotFound" xml:space="preserve">
|
<data name="ServiceGameUnlockerInterestedPatternNotFound" xml:space="preserve">
|
||||||
<value>在匹配内存时遇到问题:无法匹配到期望的内容</value>
|
<value>在匹配内存时遇到问题:无法匹配到期望的内容</value>
|
||||||
@@ -1374,7 +1374,7 @@
|
|||||||
<value>切换服务器失败</value>
|
<value>切换服务器失败</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ViewModelLaunchGameMultiChannelReadFail" xml:space="preserve">
|
<data name="ViewModelLaunchGameMultiChannelReadFail" xml:space="preserve">
|
||||||
<value>无法读取游戏配置文件: {0}</value>
|
<value>无法读取游戏配置文件: {0},可能是文件不存在或权限不足</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ViewModelLaunchGamePathInvalid" xml:space="preserve">
|
<data name="ViewModelLaunchGamePathInvalid" xml:space="preserve">
|
||||||
<value>游戏路径不正确,前往设置更改游戏路径</value>
|
<value>游戏路径不正确,前往设置更改游戏路径</value>
|
||||||
|
|||||||
@@ -69,9 +69,9 @@ internal sealed partial class GachaStatisticsFactory : IGachaStatisticsFactory
|
|||||||
// 'ref' is not allowed here because we have lambda below
|
// 'ref' is not allowed here because we have lambda below
|
||||||
foreach (Model.Entity.GachaItem item in CollectionsMarshal.AsSpan(items))
|
foreach (Model.Entity.GachaItem item in CollectionsMarshal.AsSpan(items))
|
||||||
{
|
{
|
||||||
// Find target history wish to operate.
|
// Find target history wish to operate. // w.From <= item.Time <= w.To
|
||||||
HistoryWishBuilder? targetHistoryWishBuilder = item.GachaType is not (GachaConfigType.StandardWish or GachaConfigType.NoviceWish)
|
HistoryWishBuilder? targetHistoryWishBuilder = item.GachaType is not (GachaConfigType.StandardWish or GachaConfigType.NoviceWish)
|
||||||
? historyWishBuilderMap[item.GachaType].FirstOrDefault(w => w.From <= item.Time && w.To >= item.Time)
|
? historyWishBuilderMap[item.GachaType].BinarySearch(w => item.Time < w.From ? -1 : item.Time > w.To ? 1 : 0)
|
||||||
: default;
|
: default;
|
||||||
|
|
||||||
switch (item.ItemId.StringLength())
|
switch (item.ItemId.StringLength())
|
||||||
|
|||||||
Reference in New Issue
Block a user