Soft player cap that lets in only admins. (#5227)

* Soft player cap that lets in only admins.

* Update Content.Server/Connection/ConnectionManager.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>

* Update Content.Server/Connection/ConnectionManager.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
This commit is contained in:
moonheart08
2021-11-09 03:44:39 -06:00
committed by GitHub
parent fe6590bbe6
commit 40c3261665
2 changed files with 15 additions and 2 deletions

View File

@@ -1,10 +1,12 @@
using System;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Content.Server.Administration.Managers;
using Content.Server.Database;
using Content.Server.Preferences.Managers;
using Content.Shared;
using Content.Shared.CCVar;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Network;
@@ -22,6 +24,8 @@ namespace Content.Server.Connection
/// </summary>
public sealed class ConnectionManager : IConnectionManager
{
[Dependency] private readonly IServerDbManager _dbManager = default!;
[Dependency] private readonly IPlayerManager _plyMgr = default!;
[Dependency] private readonly IServerNetManager _netMgr = default!;
[Dependency] private readonly IServerDbManager _db = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
@@ -70,6 +74,12 @@ The ban reason is: ""{ban.Reason}""
hwId = null;
}
if (_plyMgr.PlayerCount >= _cfg.GetCVar(CCVars.SoftMaxPlayers) && await _dbManager.GetAdminDataForAsync(e.UserId) is null)
{
e.Deny("The server is full!");
return;
}
var ban = await _db.GetServerBanAsync(addr, userId, hwId);
if (ban != null)
{

View File

@@ -99,12 +99,15 @@ namespace Content.Shared.CCVar
/// <summary>
/// When enabled, guests will be assigned permanent UIDs and will have their preferences stored.
/// </summary>
public static readonly CVarDef<bool>
GamePersistGuests = CVarDef.Create("game.persistguests", true, CVar.ARCHIVE | CVar.SERVERONLY);
public static readonly CVarDef<bool> GamePersistGuests =
CVarDef.Create("game.persistguests", true, CVar.ARCHIVE | CVar.SERVERONLY);
public static readonly CVarDef<bool> GameDiagonalMovement =
CVarDef.Create("game.diagonalmovement", true, CVar.ARCHIVE);
public static readonly CVarDef<int> SoftMaxPlayers =
CVarDef.Create("game.soft_max_players", 30, CVar.SERVERONLY | CVar.ARCHIVE);
/*
* Suspicion
*/