]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
add cvar for custom panic bunker reason (#23267)
authorLankLTE <135308300+LankLTE@users.noreply.github.com>
Mon, 1 Jan 2024 02:53:49 +0000 (18:53 -0800)
committerGitHub <noreply@github.com>
Mon, 1 Jan 2024 02:53:49 +0000 (21:53 -0500)
Panic bunker cvar

Content.Server/Connection/ConnectionManager.cs
Content.Shared/CCVar/CCVars.cs

index c5f1dd119dd412bdbba4ea6829822b07f21c0c9e..af25a709ddbcc41d85bc0ceb6f644955a10f5e1c 100644 (file)
@@ -1,4 +1,4 @@
-using System.Collections.Immutable;
+using System.Collections.Immutable;
 using System.Threading.Tasks;
 using Content.Server.Database;
 using Content.Server.GameTicking;
@@ -109,12 +109,19 @@ namespace Content.Server.Connection
             if (_cfg.GetCVar(CCVars.PanicBunkerEnabled))
             {
                 var showReason = _cfg.GetCVar(CCVars.PanicBunkerShowReason);
+                var customReason = _cfg.GetCVar(CCVars.PanicBunkerCustomReason);
 
                 var minMinutesAge = _cfg.GetCVar(CCVars.PanicBunkerMinAccountAge);
                 var record = await _dbManager.GetPlayerRecordByUserId(userId);
                 var validAccountAge = record != null &&
                                         record.FirstSeenTime.CompareTo(DateTimeOffset.Now - TimeSpan.FromMinutes(minMinutesAge)) <= 0;
 
+                // Use the custom reason if it exists & they don't have the minimum account age
+                if (customReason != string.Empty && !validAccountAge)
+                {
+                    return (ConnectionDenyReason.Panic, customReason, null);
+                }
+
                 if (showReason && !validAccountAge)
                 {
                     return (ConnectionDenyReason.Panic,
@@ -126,6 +133,12 @@ namespace Content.Server.Connection
                 var overallTime = ( await _db.GetPlayTimes(e.UserId)).Find(p => p.Tracker == PlayTimeTrackingShared.TrackerOverall);
                 var haveMinOverallTime = overallTime != null && overallTime.TimeSpent.TotalHours > minOverallHours;
 
+                // Use the custom reason if it exists & they don't have the minimum time
+                if (customReason != string.Empty && !haveMinOverallTime)
+                {
+                    return (ConnectionDenyReason.Panic, customReason, null);
+                }
+
                 if (showReason && !haveMinOverallTime)
                 {
                     return (ConnectionDenyReason.Panic,
index e23df3d936bb7022798bbdaa9ec1555fd2940d79..192923e0014d6e3d604bda18d52102a31c2785cb 100644 (file)
@@ -298,6 +298,13 @@ namespace Content.Shared.CCVar
         public static readonly CVarDef<int> PanicBunkerMinOverallHours =
             CVarDef.Create("game.panic_bunker.min_overall_hours", 10, CVar.SERVERONLY);
 
+        /// <summary>
+        /// A custom message that will be used for connections denied to the panic bunker
+        /// If not empty, then will overwrite <see cref="PanicBunkerShowReason"/>
+        /// </summary>
+        public static readonly CVarDef<string> PanicBunkerCustomReason =
+            CVarDef.Create("game.panic_bunker.custom_reason", string.Empty, CVar.SERVERONLY);
+
         /// <summary>
         /// Make people bonk when trying to climb certain objects like tables.
         /// </summary>