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:
@@ -1,10 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Content.Server.Administration.Managers;
|
||||||
using Content.Server.Database;
|
using Content.Server.Database;
|
||||||
using Content.Server.Preferences.Managers;
|
using Content.Server.Preferences.Managers;
|
||||||
using Content.Shared;
|
using Content.Shared;
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Configuration;
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Network;
|
using Robust.Shared.Network;
|
||||||
@@ -22,6 +24,8 @@ namespace Content.Server.Connection
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class ConnectionManager : IConnectionManager
|
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 IServerNetManager _netMgr = default!;
|
||||||
[Dependency] private readonly IServerDbManager _db = default!;
|
[Dependency] private readonly IServerDbManager _db = default!;
|
||||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||||
@@ -70,6 +74,12 @@ The ban reason is: ""{ban.Reason}""
|
|||||||
hwId = null;
|
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);
|
var ban = await _db.GetServerBanAsync(addr, userId, hwId);
|
||||||
if (ban != null)
|
if (ban != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -99,12 +99,15 @@ namespace Content.Shared.CCVar
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// When enabled, guests will be assigned permanent UIDs and will have their preferences stored.
|
/// When enabled, guests will be assigned permanent UIDs and will have their preferences stored.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly CVarDef<bool>
|
public static readonly CVarDef<bool> GamePersistGuests =
|
||||||
GamePersistGuests = CVarDef.Create("game.persistguests", true, CVar.ARCHIVE | CVar.SERVERONLY);
|
CVarDef.Create("game.persistguests", true, CVar.ARCHIVE | CVar.SERVERONLY);
|
||||||
|
|
||||||
public static readonly CVarDef<bool> GameDiagonalMovement =
|
public static readonly CVarDef<bool> GameDiagonalMovement =
|
||||||
CVarDef.Create("game.diagonalmovement", true, CVar.ARCHIVE);
|
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
|
* Suspicion
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user