Cvar to allow whitelisted players to bypass panic bunker (#23885)

Among us
This commit is contained in:
Vasilis
2024-01-14 06:27:32 +01:00
committed by GitHub
parent 7ac76838ed
commit 22c0b4425d
2 changed files with 13 additions and 6 deletions

View File

@@ -114,15 +114,16 @@ namespace Content.Server.Connection
var minMinutesAge = _cfg.GetCVar(CCVars.PanicBunkerMinAccountAge); var minMinutesAge = _cfg.GetCVar(CCVars.PanicBunkerMinAccountAge);
var record = await _dbManager.GetPlayerRecordByUserId(userId); var record = await _dbManager.GetPlayerRecordByUserId(userId);
var validAccountAge = record != null && var validAccountAge = record != null &&
record.FirstSeenTime.CompareTo(DateTimeOffset.Now - TimeSpan.FromMinutes(minMinutesAge)) <= 0; record.FirstSeenTime.CompareTo(DateTimeOffset.Now - TimeSpan.FromMinutes(minMinutesAge)) <= 0;
var bypassAllowed = _cfg.GetCVar(CCVars.BypassBunkerWhitelist) && await _db.GetWhitelistStatusAsync(userId);
// Use the custom reason if it exists & they don't have the minimum account age // Use the custom reason if it exists & they don't have the minimum account age
if (customReason != string.Empty && !validAccountAge) if (customReason != string.Empty && !validAccountAge && !bypassAllowed)
{ {
return (ConnectionDenyReason.Panic, customReason, null); return (ConnectionDenyReason.Panic, customReason, null);
} }
if (showReason && !validAccountAge) if (showReason && !validAccountAge && !bypassAllowed)
{ {
return (ConnectionDenyReason.Panic, return (ConnectionDenyReason.Panic,
Loc.GetString("panic-bunker-account-denied-reason", Loc.GetString("panic-bunker-account-denied-reason",
@@ -134,19 +135,19 @@ namespace Content.Server.Connection
var haveMinOverallTime = overallTime != null && overallTime.TimeSpent.TotalHours > minOverallHours; var haveMinOverallTime = overallTime != null && overallTime.TimeSpent.TotalHours > minOverallHours;
// Use the custom reason if it exists & they don't have the minimum time // Use the custom reason if it exists & they don't have the minimum time
if (customReason != string.Empty && !haveMinOverallTime) if (customReason != string.Empty && !haveMinOverallTime && !bypassAllowed)
{ {
return (ConnectionDenyReason.Panic, customReason, null); return (ConnectionDenyReason.Panic, customReason, null);
} }
if (showReason && !haveMinOverallTime) if (showReason && !haveMinOverallTime && !bypassAllowed)
{ {
return (ConnectionDenyReason.Panic, return (ConnectionDenyReason.Panic,
Loc.GetString("panic-bunker-account-denied-reason", Loc.GetString("panic-bunker-account-denied-reason",
("reason", Loc.GetString("panic-bunker-account-reason-overall", ("hours", minOverallHours)))), null); ("reason", Loc.GetString("panic-bunker-account-reason-overall", ("hours", minOverallHours)))), null);
} }
if (!validAccountAge || !haveMinOverallTime) if (!validAccountAge || !haveMinOverallTime && !bypassAllowed)
{ {
return (ConnectionDenyReason.Panic, Loc.GetString("panic-bunker-account-denied"), null); return (ConnectionDenyReason.Panic, Loc.GetString("panic-bunker-account-denied"), null);
} }

View File

@@ -305,6 +305,12 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<string> PanicBunkerCustomReason = public static readonly CVarDef<string> PanicBunkerCustomReason =
CVarDef.Create("game.panic_bunker.custom_reason", string.Empty, CVar.SERVERONLY); CVarDef.Create("game.panic_bunker.custom_reason", string.Empty, CVar.SERVERONLY);
/// <summary>
/// Allow bypassing the panic bunker if the user is whitelisted.
/// </summary>
public static readonly CVarDef<bool> BypassBunkerWhitelist =
CVarDef.Create("game.panic_bunker.whitelisted_can_bypass", true, CVar.SERVERONLY);
/// <summary> /// <summary>
/// Make people bonk when trying to climb certain objects like tables. /// Make people bonk when trying to climb certain objects like tables.
/// </summary> /// </summary>