fix: Removes side effect of setting skill mod when changing Owner (#1101)
## Breaking Change! Setting `mod.Owner` will no longer update a skill mod. **Please stick to the API and use `mobile.AddSkillMod(mod)` for all situations, including equipping.** ## Fixes - [X] Fixes memory leak in factions. - [X] Changes `List<SkillMod>` to `HashSet<SkillMod>`. - [X] Eliminates skill mods adding/removing twice.
This commit is contained in:
parent
414ef8d8d6
commit
cb474712f8
6 changed files with 80 additions and 109 deletions
|
|
@ -13,6 +13,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server;
|
||||
|
|
@ -50,21 +51,6 @@ public abstract partial class SkillMod : MobileMod
|
|||
}
|
||||
}
|
||||
|
||||
public override Mobile Owner
|
||||
{
|
||||
get => base.Owner;
|
||||
set
|
||||
{
|
||||
var owner = base.Owner;
|
||||
if (owner != value)
|
||||
{
|
||||
owner?.RemoveSkillMod(this);
|
||||
base.Owner = owner = value;
|
||||
owner?.AddSkillMod(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[SerializableField(1)]
|
||||
public SkillName Skill
|
||||
{
|
||||
|
|
@ -136,10 +122,8 @@ public abstract partial class SkillMod : MobileMod
|
|||
}
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
Owner = null;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Remove() => Owner?.RemoveSkillMod(this);
|
||||
|
||||
public abstract bool CheckCondition();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue