Make MakeAntag() log errors instead of throwing exceptions (#28771)
Make `MakeAntag()` log errors instead of throw
This commit is contained in:
@@ -264,7 +264,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
|
||||
/// </summary>
|
||||
public void MakeAntag(Entity<AntagSelectionComponent> 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 sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
|
||||
{
|
||||
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 sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
|
||||
if (!TryComp<GhostRoleAntagSpawnerComponent>(player, out var spawnerComp))
|
||||
{
|
||||
Log.Error($"Antag spawner {player} does not have a GhostRoleAntagSpawnerComponent.");
|
||||
if (session != null)
|
||||
ent.Comp.SelectedSessions.Remove(session);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user