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:
Kamron Batman 2022-06-30 12:07:08 -07:00 • committed by GitHub
parent 414ef8d8d6
commit cb474712f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 80 additions and 109 deletions

View file

@ -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();
}