mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 15:14:41 +00:00
Take into account extended_onlyallowrunincountries when deciding upon region locks
This commit is contained in:
parent
9898d47db4
commit
54a092a822
2 changed files with 19 additions and 4 deletions
|
@ -1180,14 +1180,14 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
|
|||
return (0, DateTime.MaxValue, true);
|
||||
}
|
||||
|
||||
if ((packageData.ProhibitRunInCountries == null) || packageData.ProhibitRunInCountries.IsEmpty) {
|
||||
if (((packageData.ProhibitRunInCountries == null) || packageData.ProhibitRunInCountries.IsEmpty) && ((packageData.OnlyAllowRunInCountries == null) || packageData.OnlyAllowRunInCountries.IsEmpty)) {
|
||||
// No restrictions, we're good to go
|
||||
regionRestrictedUntil = null;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (packageData.ProhibitRunInCountries.Contains(IPCountryCode)) {
|
||||
if ((packageData.ProhibitRunInCountries?.Contains(IPCountryCode) == true) || ((packageData.OnlyAllowRunInCountries?.Count > 0) && !packageData.OnlyAllowRunInCountries.Contains(IPCountryCode))) {
|
||||
// We are restricted by this package, we can only be saved by another package that is not restricted
|
||||
DateTime regionRestrictedUntilPackage = ownedPackageData.TimeCreated.AddMonths(RegionRestrictionPlayableBlockMonths);
|
||||
|
||||
|
@ -1404,6 +1404,14 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
|
|||
}
|
||||
}
|
||||
|
||||
string[]? onlyAllowRunInCountries = null;
|
||||
|
||||
string? onlyAllowRunInCountriesText = productInfo.KeyValues["extended"]["onlyallowrunincountries"].AsString();
|
||||
|
||||
if (!string.IsNullOrEmpty(onlyAllowRunInCountriesText)) {
|
||||
onlyAllowRunInCountries = onlyAllowRunInCountriesText.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
string[]? prohibitRunInCountries = null;
|
||||
|
||||
string? prohibitRunInCountriesText = productInfo.KeyValues["extended"]["prohibitrunincountries"].AsString();
|
||||
|
@ -1412,7 +1420,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
|
|||
prohibitRunInCountries = prohibitRunInCountriesText.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
result[productInfo.ID] = new PackageData(changeNumber, validUntil, appIDs?.ToImmutableHashSet(), prohibitRunInCountries?.ToImmutableHashSet(StringComparer.Ordinal));
|
||||
result[productInfo.ID] = new PackageData(changeNumber, validUntil, appIDs?.ToImmutableHashSet(), onlyAllowRunInCountries?.ToImmutableHashSet(StringComparer.Ordinal), prohibitRunInCountries?.ToImmutableHashSet(StringComparer.Ordinal));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -36,6 +36,9 @@ public sealed class PackageData {
|
|||
[JsonRequired]
|
||||
public uint ChangeNumber { get; private init; }
|
||||
|
||||
[JsonInclude]
|
||||
public ImmutableHashSet<string>? OnlyAllowRunInCountries { get; private init; }
|
||||
|
||||
[JsonInclude]
|
||||
public ImmutableHashSet<string>? ProhibitRunInCountries { get; private init; }
|
||||
|
||||
|
@ -43,13 +46,14 @@ public sealed class PackageData {
|
|||
[JsonRequired]
|
||||
public DateTime ValidUntil { get; private init; }
|
||||
|
||||
internal PackageData(uint changeNumber, DateTime validUntil, ImmutableHashSet<uint>? appIDs = null, ImmutableHashSet<string>? prohibitRunInCountries = null) {
|
||||
internal PackageData(uint changeNumber, DateTime validUntil, ImmutableHashSet<uint>? appIDs = null, ImmutableHashSet<string>? onlyAllowRunInCountries = null, ImmutableHashSet<string>? prohibitRunInCountries = null) {
|
||||
ArgumentOutOfRangeException.ThrowIfZero(changeNumber);
|
||||
ArgumentOutOfRangeException.ThrowIfEqual(validUntil, DateTime.MinValue);
|
||||
|
||||
ChangeNumber = changeNumber;
|
||||
ValidUntil = validUntil;
|
||||
AppIDs = appIDs;
|
||||
OnlyAllowRunInCountries = onlyAllowRunInCountries;
|
||||
ProhibitRunInCountries = prohibitRunInCountries;
|
||||
}
|
||||
|
||||
|
@ -59,6 +63,9 @@ public sealed class PackageData {
|
|||
[UsedImplicitly]
|
||||
public bool ShouldSerializeAppIDs() => AppIDs is { IsEmpty: false };
|
||||
|
||||
[UsedImplicitly]
|
||||
public bool ShouldSerializeOnlyAllowRunInCountries() => OnlyAllowRunInCountries is { IsEmpty: false };
|
||||
|
||||
[UsedImplicitly]
|
||||
public bool ShouldSerializeProhibitRunInCountries() => ProhibitRunInCountries is { IsEmpty: false };
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue