diff --git a/Content.Server/Antag/AntagSelectionSystem.cs b/Content.Server/Antag/AntagSelectionSystem.cs index 55c66e893341..d2bc26f20d34 100644 --- a/Content.Server/Antag/AntagSelectionSystem.cs +++ b/Content.Server/Antag/AntagSelectionSystem.cs @@ -264,7 +264,7 @@ public bool TryMakeAntag(Entity ent, ICommonSession? se /// public void MakeAntag(Entity ent, ICommonSession? session, AntagSelectionDefinition def, bool ignoreSpawner = false) { - var antagEnt = (EntityUid?) null; + EntityUid? antagEnt = null; var isSpawner = false; if (session != null) @@ -285,17 +285,16 @@ public void MakeAntag(Entity ent, ICommonSession? sessi { var getEntEv = new AntagSelectEntityEvent(session, ent); RaiseLocalEvent(ent, ref getEntEv, true); - - if (!getEntEv.Handled) - { - throw new InvalidOperationException($"Attempted to make {session} antagonist in gamerule {ToPrettyString(ent)} but there was no valid entity for player."); - } - antagEnt = getEntEv.Entity; } if (antagEnt is not { } player) + { + Log.Error($"Attempted to make {session} antagonist in gamerule {ToPrettyString(ent)} but there was no valid entity for player."); + if (session != null) + ent.Comp.SelectedSessions.Remove(session); return; + } var getPosEv = new AntagSelectLocationEvent(session, ent); RaiseLocalEvent(ent, ref getPosEv, true); @@ -313,6 +312,8 @@ public void MakeAntag(Entity ent, ICommonSession? sessi if (!TryComp(player, out var spawnerComp)) { Log.Error($"Antag spawner {player} does not have a GhostRoleAntagSpawnerComponent."); + if (session != null) + ent.Comp.SelectedSessions.Remove(session); return; }