From 97c1a7a1a6fdb7515b0bb80d846a2998723819be Mon Sep 17 00:00:00 2001 From: JustArchi Date: Fri, 1 Dec 2017 01:01:02 +0100 Subject: [PATCH] Improve error routine This way we avoid slow reflection-based Enum.IsDefined() while covering out-of-range values. --- ArchiSteamFarm/ArchiHandler.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ArchiSteamFarm/ArchiHandler.cs b/ArchiSteamFarm/ArchiHandler.cs index 7aa35e2f9..6777062a4 100644 --- a/ArchiSteamFarm/ArchiHandler.cs +++ b/ArchiSteamFarm/ArchiHandler.cs @@ -273,9 +273,21 @@ namespace ArchiSteamFarm { foreach (CMsgClientUserNotifications.Notification notification in msg.notifications) { ENotification type = (ENotification) notification.user_notification_type; - if (type == ENotification.Unknown) { - ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(type), type)); - continue; + switch (type) { + case ENotification.AccountAlerts: + case ENotification.Chat: + case ENotification.Comments: + case ENotification.GameTurns: + case ENotification.Gifts: + case ENotification.HelpRequestReplies: + case ENotification.Invites: + case ENotification.Items: + case ENotification.ModeratorMessages: + case ENotification.Trading: + break; + default: + ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(type), type)); + continue; } Notifications[type] = notification.count;