From 56c40fffbd12f92884df1cc902593b1934323525 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sat, 29 Jul 2023 15:44:23 -0700 Subject: [PATCH] fix: Fixes RemoveFollowers called twice (#1437) --- Projects/UOContent/Mobiles/BaseCreature.cs | 36 ++++++---------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/Projects/UOContent/Mobiles/BaseCreature.cs b/Projects/UOContent/Mobiles/BaseCreature.cs index 4dc4c9303..18a62c945 100644 --- a/Projects/UOContent/Mobiles/BaseCreature.cs +++ b/Projects/UOContent/Mobiles/BaseCreature.cs @@ -2260,39 +2260,25 @@ namespace Server.Mobiles public void RemoveFollowers() { - if (m_ControlMaster != null) + var master = m_ControlMaster ?? m_SummonMaster; + if (master != null) { - m_ControlMaster.Followers -= Math.Min(ControlSlots, m_ControlMaster.Followers); - if (m_ControlMaster is PlayerMobile mobile) + master.Followers -= Math.Min(ControlSlots, master.Followers); + if (master is PlayerMobile pm) { - mobile.AllFollowers?.Remove(this); - mobile.AutoStabled?.Remove(this); + pm.RemoveFollower(this); + pm.AutoStabled?.Remove(this); } } - else if (m_SummonMaster != null) - { - m_SummonMaster.Followers -= Math.Min(ControlSlots, m_SummonMaster.Followers); - (m_SummonMaster as PlayerMobile)?.AllFollowers?.Remove(this); - } } public void AddFollowers() { - if (m_ControlMaster != null) + var master = m_ControlMaster ?? m_SummonMaster; + if (master != null) { - m_ControlMaster.Followers += ControlSlots; - if (m_ControlMaster is PlayerMobile pm) - { - pm.AddFollower(this); - } - } - else if (m_SummonMaster != null) - { - m_SummonMaster.Followers += ControlSlots; - if (m_SummonMaster is PlayerMobile pm) - { - pm.AddFollower(this); - } + master.Followers += ControlSlots; + (master as PlayerMobile)?.AddFollower(this); } } @@ -3416,8 +3402,6 @@ namespace Server.Mobiles } } - RemoveFollowers(); - base.OnDeath(c); if (DeleteCorpseOnDeath)