From 27b6e4e4f396bdcae50e84eeac08b5fc8391c604 Mon Sep 17 00:00:00 2001 From: Mira <42539014+MiraHell@users.noreply.github.com> Date: Tue, 6 Aug 2024 22:59:03 +0300 Subject: [PATCH] AntagSelectionFix (#1531) * fix * autoformat * mark 220 * autoformat... * meh --- Content.Server/Antag/AntagSelectionSystem.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Content.Server/Antag/AntagSelectionSystem.cs b/Content.Server/Antag/AntagSelectionSystem.cs index 860e2b986529..e90e4ebab6bc 100644 --- a/Content.Server/Antag/AntagSelectionSystem.cs +++ b/Content.Server/Antag/AntagSelectionSystem.cs @@ -332,12 +332,19 @@ public void MakeAntag(Entity ent, ICommonSession? sessi if (session != null) { - var curMind = _mind.CreateMind(session.UserId, Name(antagEnt.Value)); - _mind.SetUserId(curMind, session.UserId); + // start 220 AntagSelectionFix + var curMind = session.GetMind(); - _mind.TransferTo(curMind, antagEnt, ghostCheckOverride: true); - _role.MindAddRoles(curMind, def.MindComponents, null, true); - ent.Comp.SelectedMinds.Add((curMind, Name(player))); + if (curMind == null || session.AttachedEntity != antagEnt) + { + curMind = _mind.CreateMind(session.UserId, Name(antagEnt.Value)); + _mind.SetUserId(curMind.Value, session.UserId); + } + + _mind.TransferTo(curMind.Value, antagEnt, ghostCheckOverride: true); + _role.MindAddRoles(curMind.Value, def.MindComponents, null, true); + ent.Comp.SelectedMinds.Add((curMind.Value, Name(player))); + // end 220 AntagSelectionFix SendBriefing(session, def.Briefing); }