Makes admins not count towards the playercount cap (#33424)

* Makes admins not count towards the playercount cap

* Update Content.Shared/CCVar/CCVars.Admin.cs (thx Aeshus

Co-authored-by: Thomas <87614336+Aeshus@users.noreply.github.com>

* Actually fixes whitespace on the comments
Thanks VScode very good IDE

---------

Co-authored-by: Thomas <87614336+Aeshus@users.noreply.github.com>
This commit is contained in:
deathride58
2024-12-16 09:19:15 -05:00
committed by GitHub
parent 1368092d43
commit d8afcdcdf0
2 changed files with 20 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using Content.Server.Administration.Managers;
using Content.Server.Chat.Managers;
using Content.Server.Database;
using Content.Server.GameTicking;
@@ -56,6 +57,7 @@ namespace Content.Server.Connection
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IAdminManager _adminManager = default!;
private ISawmill _sawmill = default!;
private readonly Dictionary<NetUserId, TimeSpan> _temporaryBypasses = [];
@@ -270,7 +272,14 @@ namespace Content.Server.Connection
ticker.PlayerGameStatuses.TryGetValue(userId, out var status) &&
status == PlayerGameStatus.JoinedGame;
var adminBypass = _cfg.GetCVar(CCVars.AdminBypassMaxPlayers) && adminData != null;
if ((_plyMgr.PlayerCount >= _cfg.GetCVar(CCVars.SoftMaxPlayers) && !adminBypass) && !wasInGame)
var softPlayerCount = _plyMgr.PlayerCount;
if (!_cfg.GetCVar(CCVars.AdminsCountForMaxPlayers))
{
softPlayerCount -= _adminManager.ActiveAdmins.Count();
}
if ((softPlayerCount >= _cfg.GetCVar(CCVars.SoftMaxPlayers) && !adminBypass) && !wasInGame)
{
return (ConnectionDenyReason.Full, Loc.GetString("soft-player-cap-full"), null);
}
@@ -287,7 +296,7 @@ namespace Content.Server.Connection
foreach (var whitelist in _whitelists)
{
if (!IsValid(whitelist, _plyMgr.PlayerCount))
if (!IsValid(whitelist, softPlayerCount))
{
// Not valid for current player count.
continue;