This commit is contained in:
JustArchi 2017-12-29 03:40:44 +01:00
parent 96b7920b9b
commit 209188a29b
7 changed files with 44 additions and 39 deletions

View file

@ -26,7 +26,7 @@ env:
- CONFIGURATION: Release
- DOTNET_CLI_TELEMETRY_OPTOUT: 1
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
- VARIANTS="generic win-x64 linux-x64 linux-arm osx-x64" # NOTE: When modifying variants, don't forget to update ASF_VARIANT definitions in ASF.cs!
- VARIANTS="generic win-x64 linux-x64 linux-arm osx-x64" # NOTE: When modifying variants, don't forget to update ASF_VARIANT definitions in SharedInfo.cs!
before_script:
- |

View file

@ -33,22 +33,6 @@ using ArchiSteamFarm.Localization;
namespace ArchiSteamFarm {
internal static class ASF {
private const string SourceVariant = "source";
#if ASF_VARIANT_GENERIC
private const string Variant = "generic";
#elif ASF_VARIANT_LINUX_ARM
private const string Variant = "linux-arm";
#elif ASF_VARIANT_LINUX_X64
private const string Variant = "linux-x64";
#elif ASF_VARIANT_OSX_X64
private const string Variant = "osx-x64";
#elif ASF_VARIANT_WIN_X64
private const string Variant = "win-x64";
#else
private const string Variant = SourceVariant;
#endif
internal static readonly ArchiLogger ArchiLogger = new ArchiLogger(SharedInfo.ASF);
private static readonly ConcurrentDictionary<string, DateTime> LastWriteTimes = new ConcurrentDictionary<string, DateTime>();
@ -57,7 +41,7 @@ namespace ArchiSteamFarm {
private static FileSystemWatcher FileSystemWatcher;
internal static async Task<Version> CheckAndUpdateProgram(bool updateOverride = false) {
if (Variant.Equals(SourceVariant) || (Program.GlobalConfig.UpdateChannel == GlobalConfig.EUpdateChannel.None)) {
if (SharedInfo.IsCustomBuild || (Program.GlobalConfig.UpdateChannel == GlobalConfig.EUpdateChannel.None)) {
return null;
}
@ -153,7 +137,7 @@ namespace ArchiSteamFarm {
return null;
}
const string targetFile = SharedInfo.ASF + "-" + Variant + ".zip";
const string targetFile = SharedInfo.ASF + "-" + SharedInfo.Variant + ".zip";
GitHub.ReleaseResponse.Asset binaryAsset = releaseResponse.Assets.FirstOrDefault(asset => asset.Name.Equals(targetFile, StringComparison.OrdinalIgnoreCase));
if (binaryAsset == null) {
@ -182,7 +166,7 @@ namespace ArchiSteamFarm {
return null;
}
if (IsUnixVariant(Variant)) {
if (IsUnixVariant(SharedInfo.Variant)) {
string executable = Path.Combine(targetDirectory, SharedInfo.AssemblyName);
if (File.Exists(executable)) {
OS.UnixSetFileAccessExecutable(executable);

View file

@ -349,7 +349,7 @@ namespace ArchiSteamFarm {
return null;
}
internal async Task<(uint PlayableAppID, DateTime IgnoredUntil)> GetAppDataForIdling(uint appID, float hoursPlayed, bool allowRecursiveDiscovery = true) {
internal async Task<(uint PlayableAppID, DateTime IgnoredUntil)> GetAppDataForIdling(uint appID, float hoursPlayed, bool allowRecursiveDiscovery = true, bool optimisticDiscovery = true) {
if ((appID == 0) || (hoursPlayed < 0)) {
ArchiLogger.LogNullError(nameof(appID) + " || " + nameof(hoursPlayed));
return (0, DateTime.MaxValue);
@ -373,7 +373,7 @@ namespace ArchiSteamFarm {
}
}
if (mostRecent != DateTime.MinValue) {
if (mostRecent > DateTime.MinValue) {
DateTime playableIn = mostRecent.AddDays(CardsFarmer.DaysForRefund);
if (playableIn > DateTime.UtcNow) {
return (0, playableIn);
@ -386,7 +386,7 @@ namespace ArchiSteamFarm {
for (byte i = 0; (i < WebBrowser.MaxTries) && (productInfoResultSet == null); i++) {
if (!IsConnectedAndLoggedOn) {
return (0, DateTime.MaxValue);
return (optimisticDiscovery ? appID : 0, DateTime.MinValue);
}
await PICSSemaphore.WaitAsync().ConfigureAwait(false);
@ -401,7 +401,7 @@ namespace ArchiSteamFarm {
}
if (productInfoResultSet == null) {
return (0, DateTime.MaxValue);
return (optimisticDiscovery ? appID : 0, DateTime.MinValue);
}
foreach (Dictionary<uint, SteamApps.PICSProductInfoCallback.PICSProductInfo> productInfoApps in productInfoResultSet.Results.Select(result => result.Apps)) {
@ -466,7 +466,7 @@ namespace ArchiSteamFarm {
}
if (!allowRecursiveDiscovery) {
return (0, DateTime.MaxValue);
return (0, DateTime.MinValue);
}
string listOfDlc = productInfo["extended"]["listofdlc"].Value;
@ -481,7 +481,7 @@ namespace ArchiSteamFarm {
break;
}
(uint playableAppID, _) = await GetAppDataForIdling(dlcAppID, hoursPlayed, false).ConfigureAwait(false);
(uint playableAppID, _) = await GetAppDataForIdling(dlcAppID, hoursPlayed, false, false).ConfigureAwait(false);
if (playableAppID != 0) {
return (playableAppID, DateTime.MinValue);
}
@ -491,7 +491,7 @@ namespace ArchiSteamFarm {
}
if (!productInfoResultSet.Complete || productInfoResultSet.Failed) {
return (0, DateTime.MaxValue);
return (optimisticDiscovery ? appID : 0, DateTime.MinValue);
}
return (appID, DateTime.MinValue);

View file

@ -895,14 +895,14 @@ namespace ArchiSteamFarm {
private async Task<bool> IsPlayableGame(Game game) {
(uint playableAppID, DateTime ignoredUntil) = await Bot.GetAppDataForIdling(game.AppID, game.HoursPlayed).ConfigureAwait(false);
if (playableAppID != 0) {
game.PlayableAppID = playableAppID;
return true;
if (playableAppID == 0) {
IgnoredAppIDs[game.AppID] = ignoredUntil < DateTime.MaxValue ? ignoredUntil : DateTime.UtcNow.AddHours(HoursToIgnore);
Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.IdlingGameNotPossible, game.AppID, game.GameName));
return false;
}
IgnoredAppIDs[game.AppID] = ignoredUntil != DateTime.MaxValue ? ignoredUntil : DateTime.UtcNow.AddHours(HoursToIgnore);
Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.IdlingGameNotPossible, game.AppID, game.GameName));
return false;
game.PlayableAppID = playableAppID;
return true;
}
private async Task<bool?> ShouldFarm(Game game) {

View file

@ -20,14 +20,29 @@
// limitations under the License.
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
namespace ArchiSteamFarm {
internal static class SharedInfo {
#if ASF_VARIANT_GENERIC
internal const string Variant = "generic";
#elif ASF_VARIANT_LINUX_ARM
internal const string Variant = "linux-arm";
#elif ASF_VARIANT_LINUX_X64
internal const string Variant = "linux-x64";
#elif ASF_VARIANT_OSX_X64
internal const string Variant = "osx-x64";
#elif ASF_VARIANT_WIN_X64
internal const string Variant = "win-x64";
#else
internal const string Variant = SourceVariant;
#endif
internal const ulong ArchiSteamID = 76561198006963719;
internal const string ASF = "ASF";
internal const string ASF = nameof(ASF);
internal const ulong ASFGroupSteamID = 103582791440160998;
internal const string AssemblyName = "ArchiSteamFarm";
internal const string AssemblyName = nameof(ArchiSteamFarm);
internal const string ConfigDirectory = "config";
internal const string DebugDirectory = "debug";
internal const string GithubReleaseURL = "https://api.github.com/repos/" + GithubRepo + "/releases"; // GitHub API is HTTPS only
@ -38,7 +53,13 @@ namespace ArchiSteamFarm {
internal const string StatisticsServer = "asf.justarchi.net";
internal const string UpdateDirectory = "_old";
internal static Guid ModuleVersion => Assembly.GetEntryAssembly().ManifestModule.ModuleVersionId;
internal static Version Version => Assembly.GetEntryAssembly().GetName().Version;
private const string SourceVariant = "source";
[SuppressMessage("ReSharper", "ConvertToConstant.Global")]
internal static readonly bool IsCustomBuild = Variant == SourceVariant;
internal static readonly Guid ModuleVersion = Assembly.GetEntryAssembly().ManifestModule.ModuleVersionId;
internal static readonly string PublicIdentifier = AssemblyName + (IsCustomBuild ? "-custom" : "");
internal static readonly Version Version = Assembly.GetEntryAssembly().GetName().Version;
}
}

View file

@ -58,7 +58,7 @@ namespace ArchiSteamFarm {
HttpClient = new HttpClient(httpClientHandler) { Timeout = TimeSpan.FromSeconds(extendedTimeout ? ExtendedTimeoutMultiplier * Program.GlobalConfig.ConnectionTimeout : Program.GlobalConfig.ConnectionTimeout) };
// Most web services expect that UserAgent is set, so we declare it globally
HttpClient.DefaultRequestHeaders.UserAgent.ParseAdd(SharedInfo.AssemblyName + "/" + SharedInfo.Version);
HttpClient.DefaultRequestHeaders.UserAgent.ParseAdd(SharedInfo.PublicIdentifier + "/" + SharedInfo.Version);
}
public void Dispose() => HttpClient.Dispose();

View file

@ -12,7 +12,7 @@ clone_depth: 10
environment:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
VARIANTS: generic win-x64 linux-x64 linux-arm osx-x64 # NOTE: When modifying variants, don't forget to update ASF_VARIANT definitions in ASF.cs!
VARIANTS: generic win-x64 linux-x64 linux-arm osx-x64 # NOTE: When modifying variants, don't forget to update ASF_VARIANT definitions in SharedInfo.cs!
matrix:
fast_finish: true
before_build: