Skip to content

Commit

Permalink
Picking a ghostrole as an admin will now deadmin you. (space-wizards#…
Browse files Browse the repository at this point in the history
…29790)

* @Forcibly deadmins you

* Added checks for AdminDeadminOnJoin
  • Loading branch information
MFMessage authored Jul 11, 2024
1 parent 1ea7e3e commit 1a50760
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Content.Server/Ghost/Roles/GhostRoleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
using Content.Server.Popups;
using Content.Shared.Verbs;
using Robust.Shared.Collections;
using Content.Server.Administration.Managers;
using Content.Shared.CCVar;
using Robust.Shared.Configuration;

namespace Content.Server.Ghost.Roles
{
Expand All @@ -48,6 +51,8 @@ public sealed class GhostRoleSystem : EntitySystem
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IAdminManager _adminManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;

private uint _nextRoleIdentifier;
private bool _needsUpdateGhostRoleCount = true;
Expand Down Expand Up @@ -587,6 +592,14 @@ private void OnPlayerAttached(PlayerAttachedEvent message)
// forced into a ghost role.
LeaveAllRaffles(message.Player);
CloseEui(message.Player);

// The player is no longer a ghost, so they should not be adminned anymore. Deadmin them.
// Ensures that admins do not forget to deadmin themselves upon entering a ghost role.
var autoDeAdmin = _cfg.GetCVar(CCVars.AdminDeadminOnJoin);
if (autoDeAdmin && _adminManager.IsAdmin(message.Entity))
{
_adminManager.DeAdmin(message.Player);
}
}

private void OnMindAdded(EntityUid uid, GhostTakeoverAvailableComponent component, MindAddedMessage args)
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ public static readonly CVarDef<bool>
CVarDef.Create("admin.show_pii_onban", false, CVar.SERVERONLY);

/// <summary>
/// If an admin joins a round by reading up or using the late join button, automatically
/// If an admin joins a round by readying up or using the late join button, automatically
/// de-admin them.
/// </summary>
public static readonly CVarDef<bool> AdminDeadminOnJoin =
Expand Down

0 comments on commit 1a50760

Please sign in to comment.