From 6d1511124f5ba8f3a2ecc5297600e0dd008cfb82 Mon Sep 17 00:00:00 2001 From: "Wrexbe (Josh)" <81056464+wrexbe@users.noreply.github.com> Date: Sun, 31 Mar 2024 13:49:51 -0700 Subject: [PATCH] Auto DeAdmin sooner (#26551) Co-authored-by: wrexbe --- .../GameTicking/GameTicker.RoundFlow.cs | 35 +++++++++++-------- .../GameTicking/GameTicker.Spawning.cs | 4 --- .../GameTicking/Rules/NukeopsRuleSystem.cs | 4 --- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Content.Server/GameTicking/GameTicker.RoundFlow.cs b/Content.Server/GameTicking/GameTicker.RoundFlow.cs index 004508ab91..202daf256d 100644 --- a/Content.Server/GameTicking/GameTicker.RoundFlow.cs +++ b/Content.Server/GameTicking/GameTicker.RoundFlow.cs @@ -4,6 +4,7 @@ using Content.Server.Discord; using Content.Server.GameTicking.Events; using Content.Server.Ghost; using Content.Server.Maps; +using Content.Shared.CCVar; using Content.Shared.Database; using Content.Shared.GameTicking; using Content.Shared.Mind; @@ -194,26 +195,18 @@ namespace Content.Server.GameTicking SendServerMessage(Loc.GetString("game-ticker-start-round")); - // Just in case it hasn't been loaded previously we'll try loading it. - LoadMaps(); - - // map has been selected so update the lobby info text - // applies to players who didn't ready up - UpdateInfoText(); - - StartGamePresetRules(); - - RoundLengthMetric.Set(0); - - var startingEvent = new RoundStartingEvent(RoundId); - RaiseLocalEvent(startingEvent); var readyPlayers = new List(); var readyPlayerProfiles = new Dictionary(); - + var autoDeAdmin = _cfg.GetCVar(CCVars.AdminDeadminOnJoin); foreach (var (userId, status) in _playerGameStatuses) { if (LobbyEnabled && status != PlayerGameStatus.ReadyToPlay) continue; if (!_playerManager.TryGetSessionById(userId, out var session)) continue; + + if (autoDeAdmin && _adminManager.IsAdmin(session)) + { + _adminManager.DeAdmin(session); + } #if DEBUG DebugTools.Assert(_userDb.IsLoadComplete(session), $"Player was readied up but didn't have user DB data loaded yet??"); #endif @@ -235,6 +228,20 @@ namespace Content.Server.GameTicking readyPlayerProfiles.Add(userId, profile); } + // Just in case it hasn't been loaded previously we'll try loading it. + LoadMaps(); + + // map has been selected so update the lobby info text + // applies to players who didn't ready up + UpdateInfoText(); + + StartGamePresetRules(); + + RoundLengthMetric.Set(0); + + var startingEvent = new RoundStartingEvent(RoundId); + RaiseLocalEvent(startingEvent); + var origReadyPlayers = readyPlayers.ToArray(); if (!StartPreset(origReadyPlayers, force)) diff --git a/Content.Server/GameTicking/GameTicker.Spawning.cs b/Content.Server/GameTicking/GameTicker.Spawning.cs index 52bab07ce8..5f4610744a 100644 --- a/Content.Server/GameTicking/GameTicker.Spawning.cs +++ b/Content.Server/GameTicking/GameTicker.Spawning.cs @@ -154,10 +154,6 @@ namespace Content.Server.GameTicking return; } - // Automatically de-admin players who are joining. - if (_cfg.GetCVar(CCVars.AdminDeadminOnJoin) && _adminManager.IsAdmin(player)) - _adminManager.DeAdmin(player); - // We raise this event to allow other systems to handle spawning this player themselves. (e.g. late-join wizard, etc) var bev = new PlayerBeforeSpawnEvent(player, character, jobId, lateJoin, station); RaiseLocalEvent(bev); diff --git a/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs b/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs index ea5ab9c2ab..886af60987 100644 --- a/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs @@ -763,10 +763,6 @@ public sealed class NukeopsRuleSystem : GameRuleSystem _mind.SetUserId(newMind, nukieSession.Session.UserId); _roles.MindAddRole(newMind, new NukeopsRoleComponent { PrototypeId = nukieSession.Type.AntagRoleProto }); - // Automatically de-admin players who are being made nukeops - if (_cfg.GetCVar(CCVars.AdminDeadminOnJoin) && _adminManager.IsAdmin(nukieSession.Session)) - _adminManager.DeAdmin(nukieSession.Session); - _mind.TransferTo(newMind, mob); } //Otherwise, spawn as a ghost role -- 2.51.2