From 4c8965ac32fadf15806c0c0b4f80e4c2142b17b5 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Mon, 26 Jun 2023 05:01:30 +0200 Subject: [PATCH] CVar to promotehost automatically. (#17643) --- Content.Server/Administration/Managers/AdminManager.cs | 6 +++++- Content.Shared/CCVar/CCVars.cs | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Content.Server/Administration/Managers/AdminManager.cs b/Content.Server/Administration/Managers/AdminManager.cs index b79d1a7f20..950dffd1c8 100644 --- a/Content.Server/Administration/Managers/AdminManager.cs +++ b/Content.Server/Administration/Managers/AdminManager.cs @@ -292,7 +292,11 @@ namespace Content.Server.Administration.Managers private async Task<(AdminData dat, int? rankId, bool specialLogin)?> LoadAdminData(IPlayerSession session) { - if (IsLocal(session) && _cfg.GetCVar(CCVars.ConsoleLoginLocal) || _promotedPlayers.Contains(session.UserId)) + var promoteHost = IsLocal(session) && _cfg.GetCVar(CCVars.ConsoleLoginLocal) + || _promotedPlayers.Contains(session.UserId) + || session.Name == _cfg.GetCVar(CCVars.ConsoleLoginHostUser); + + if (promoteHost) { var data = new AdminData { diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 5318abce32..79d4b0a649 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -430,6 +430,12 @@ namespace Content.Shared.CCVar public static readonly CVarDef ConsoleLoginLocal = CVarDef.Create("console.loginlocal", true, CVar.ARCHIVE | CVar.SERVERONLY); + /// + /// Automatically log in the given user as host, equivalent to the promotehost command. + /// + public static readonly CVarDef ConsoleLoginHostUser = + CVarDef.Create("console.login_host_user", "", CVar.ARCHIVE | CVar.SERVERONLY); + /* * Database stuff