]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add debug logs to baby jail and fix playtime logic (#30158)
authorChief-Engineer <119664036+Chief-Engineer@users.noreply.github.com>
Sat, 20 Jul 2024 23:28:43 +0000 (18:28 -0500)
committerGitHub <noreply@github.com>
Sat, 20 Jul 2024 23:28:43 +0000 (01:28 +0200)
* add debug logs

* Update Model.cs

* fix playtime logic for null playtime

* remove unnecessary condition

* either me or the compiler is having a C# skill issue

Content.Server.Database/Model.cs
Content.Server/Connection/ConnectionManager.cs

index dea8f9558abdd9c74341c2f057bd8b654fe5c657..d195201c29cd1a46d1f1082efa58f2978b4a02af 100644 (file)
@@ -903,6 +903,9 @@ namespace Content.Server.Database
         Panic = 3,
         /*
          * TODO: Remove baby jail code once a more mature gateway process is established. This code is only being issued as a stopgap to help with potential tiding in the immediate future.
+         * 
+         * If baby jail is removed, please reserve this value for as long as can reasonably be done to prevent causing ambiguity in connection denial reasons.
+         * Reservation by commenting out the value is likely sufficient for this purpose, but may impact projects which depend on SS14 like SS14.Admin.
          */
         BabyJail = 4,
     }
index cf7581aa4e654db07797b3dd4325c531aa5d5f55..1d675842c76eeb5f8fd94851062aeec49013573c 100644 (file)
@@ -308,6 +308,12 @@ namespace Content.Server.Connection
                 return (false, "");
 
             var isAccountAgeInvalid = record.FirstSeenTime.CompareTo(DateTimeOffset.Now - TimeSpan.FromMinutes(maxAccountAgeMinutes)) <= 0;
+
+            if (isAccountAgeInvalid)
+            {
+                _sawmill.Debug($"Baby jail will deny {userId} for account age {record.FirstSeenTime}"); // Remove on or after 2024-09
+            }
+
             if (isAccountAgeInvalid && showReason)
             {
                 var locAccountReason = reason != string.Empty
@@ -322,7 +328,12 @@ namespace Content.Server.Connection
             }
 
             var overallTime = ( await _db.GetPlayTimes(e.UserId)).Find(p => p.Tracker == PlayTimeTrackingShared.TrackerOverall);
-            var isTotalPlaytimeInvalid = overallTime == null || overallTime.TimeSpent.TotalMinutes >= maxPlaytimeMinutes;
+            var isTotalPlaytimeInvalid = overallTime != null && overallTime.TimeSpent.TotalMinutes >= maxPlaytimeMinutes;
+
+            if (isTotalPlaytimeInvalid)
+            {
+                _sawmill.Debug($"Baby jail will deny {userId} for playtime {overallTime!.TimeSpent}"); // Remove on or after 2024-09
+            }
 
             if (isTotalPlaytimeInvalid && showReason)
             {