From 2090d6301bdd890da49df123b45722f85c3de083 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Tue, 19 Jun 2018 20:02:11 +0200 Subject: [PATCH] Move DismissInventoryNotifications to BotBehaviour Also stage 2 of all deprecated properties until now. --- ArchiSteamFarm/Bot.cs | 2 +- ArchiSteamFarm/BotConfig.cs | 18 +++++----- ArchiSteamFarm/GlobalConfig.cs | 3 -- ArchiSteamFarm/Hacks.cs | 56 ------------------------------ ArchiSteamFarm/Program.cs | 5 --- ArchiSteamFarm/config/example.json | 1 - 6 files changed, 9 insertions(+), 76 deletions(-) delete mode 100644 ArchiSteamFarm/Hacks.cs diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index c57ab9ab7..79f3d43d0 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -2367,7 +2367,7 @@ namespace ArchiSteamFarm { if (newItems) { Utilities.InBackground(CardsFarmer.OnNewItemsNotification); - if (BotConfig.DismissInventoryNotifications) { + if (BotConfig.BotBehaviour.HasFlag(BotConfig.EBotBehaviour.DismissInventoryNotifications)) { Utilities.InBackground(ArchiWebHandler.MarkInventory); } } diff --git a/ArchiSteamFarm/BotConfig.cs b/ArchiSteamFarm/BotConfig.cs index 6ad7476ab..29f94abf8 100644 --- a/ArchiSteamFarm/BotConfig.cs +++ b/ArchiSteamFarm/BotConfig.cs @@ -42,18 +42,12 @@ namespace ArchiSteamFarm { [JsonProperty(Required = Required.DisallowNull)] internal readonly bool AutoSteamSaleEvent; - [JsonProperty(Required = Required.DisallowNull)] - internal readonly EBotBehaviour BotBehaviour = EBotBehaviour.None; - [JsonProperty] internal readonly string CustomGamePlayedWhileFarming; [JsonProperty] internal readonly string CustomGamePlayedWhileIdle; - [JsonProperty(Required = Required.DisallowNull)] - internal readonly bool DismissInventoryNotifications; - [JsonProperty(Required = Required.DisallowNull)] internal readonly bool Enabled; @@ -115,6 +109,9 @@ namespace ArchiSteamFarm { [JsonProperty(Required = Required.DisallowNull)] internal readonly bool UseLoginKeys = true; + [JsonProperty(Required = Required.DisallowNull)] + internal EBotBehaviour BotBehaviour { get; private set; } = EBotBehaviour.None; + [JsonProperty(Required = Required.DisallowNull)] internal EPersonaState OnlineStatus { get; private set; } = EPersonaState.Online; @@ -133,12 +130,12 @@ namespace ArchiSteamFarm { private bool ShouldSerializeSensitiveDetails = true; [JsonProperty(Required = Required.DisallowNull)] - private bool FarmOffline { + private bool DismissInventoryNotifications { set { - ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningDeprecated, nameof(FarmOffline), nameof(OnlineStatus))); + ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningDeprecated, nameof(DismissInventoryNotifications), nameof(BotBehaviour))); if (value) { - OnlineStatus = EPersonaState.Offline; + BotBehaviour |= EBotBehaviour.DismissInventoryNotifications; } } } @@ -244,7 +241,8 @@ namespace ArchiSteamFarm { None = 0, RejectInvalidFriendInvites = 1, RejectInvalidTrades = 2, - RejectInvalidGroupInvites = 4 + RejectInvalidGroupInvites = 4, + DismissInventoryNotifications = 8 } internal enum EFarmingOrder : byte { diff --git a/ArchiSteamFarm/GlobalConfig.cs b/ArchiSteamFarm/GlobalConfig.cs index 83da95e87..10ce93304 100644 --- a/ArchiSteamFarm/GlobalConfig.cs +++ b/ArchiSteamFarm/GlobalConfig.cs @@ -44,9 +44,6 @@ namespace ArchiSteamFarm { [JsonProperty(Required = Required.DisallowNull)] internal readonly bool AutoRestart = true; - [JsonProperty(Required = Required.DisallowNull)] - internal readonly byte BackgroundGCPeriod; - [JsonProperty(Required = Required.DisallowNull)] internal readonly HashSet Blacklist = new HashSet(); diff --git a/ArchiSteamFarm/Hacks.cs b/ArchiSteamFarm/Hacks.cs deleted file mode 100644 index f7d48aad5..000000000 --- a/ArchiSteamFarm/Hacks.cs +++ /dev/null @@ -1,56 +0,0 @@ -// _ _ _ ____ _ _____ -// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___ -// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \ -// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | | -// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_| -// -// Copyright 2015-2018 Łukasz "JustArchi" Domeradzki -// Contact: JustArchi@JustArchi.net -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Runtime; -using System.Threading; - -namespace ArchiSteamFarm { - internal static class Hacks { - private static Timer GarbageCollectionTimer; - private static Timer GarbageCompactionTimer; - - internal static void EnableBackgroundGC(byte period) { - if (period == 0) { - ASF.ArchiLogger.LogNullError(nameof(period)); - return; - } - - if (GarbageCollectionTimer == null) { - GarbageCollectionTimer = new Timer( - e => GC.Collect(), - null, - TimeSpan.FromSeconds(period), // Delay - TimeSpan.FromSeconds(period) // Period - ); - } - - if (GarbageCompactionTimer == null) { - GarbageCompactionTimer = new Timer( - e => GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce, - null, - TimeSpan.FromMinutes(period), // Delay - TimeSpan.FromMinutes(period) // Period - ); - } - } - } -} \ No newline at end of file diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index 367969cd9..6132321a1 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -254,11 +254,6 @@ namespace ArchiSteamFarm { ASF.ArchiLogger.LogGenericDebug(SharedInfo.GlobalConfigFileName + ": " + JsonConvert.SerializeObject(GlobalConfig, Formatting.Indented)); } - if (GlobalConfig.BackgroundGCPeriod > 0) { - ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningDeprecated, nameof(GlobalConfig.BackgroundGCPeriod), "COMPlus_GCLatencyLevel=0")); - Hacks.EnableBackgroundGC(GlobalConfig.BackgroundGCPeriod); - } - if (!string.IsNullOrEmpty(GlobalConfig.CurrentCulture)) { try { // GetCultureInfo() would be better but we can't use it for specifying neutral cultures such as "en" diff --git a/ArchiSteamFarm/config/example.json b/ArchiSteamFarm/config/example.json index 3058e722e..82e810266 100644 --- a/ArchiSteamFarm/config/example.json +++ b/ArchiSteamFarm/config/example.json @@ -4,7 +4,6 @@ "BotBehaviour": 0, "CustomGamePlayedWhileFarming": null, "CustomGamePlayedWhileIdle": null, - "DismissInventoryNotifications": false, "Enabled": false, "FarmingOrder": 0, "GamesPlayedWhileIdle": [],