fix: Fixes stabled, abilities targeting self, and unsummon memory leak (#1418)

## **MAJOR CHANGE**
* `Stabled` has been moved to `PlayerMobile`.
* New methods added, `PlayerMobile.AddStabled` and `PlayerMobile.RemoveStabled`.
* Added `PlayerMobile.AddFollower` and `PlayerMobile.RemoveFollower`.
* `Stabled`, `AutoStabled`, and `AllFollowers` are now `HashSet` and **_CAN BE NULL_**.

### Summary
* Fixes monster abilities causing harm to the monster through reflect
* Adds `CanTriggerAgainstSelf` to override this for healing or some other self-affecting ability
* Fixes a major memory leak where `UnsummonTimer` from animated dead spell lasts up-to 24hrs and therefore holds onto references of dead/deleted mobs.
* Fixes another minor leak where a mob is not unregistered from the animated dead spell list until the next spell cast.
This commit is contained in:
Kamron Batman 2023-07-03 09:45:22 -07:00 committed by GitHub
parent d99e72db8f
commit 3b97e8d39c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 391 additions and 280 deletions

View file

@ -48,10 +48,18 @@ public static class SerializationExtensions
return entity?.Created <= reader.LastSerialized ? entity : null;
}
public static List<T> ReadEntityList<T>(this IGenericReader reader) where T : class, ISerializable
public static List<T> ReadEntityList<T>(
this IGenericReader reader,
bool nullIfEmpty = false
) where T : class, ISerializable
{
var count = reader.ReadInt();
if (count == 0 && nullIfEmpty)
{
return null;
}
var list = new List<T>(count);
for (var i = 0; i < count; ++i)
@ -66,10 +74,18 @@ public static class SerializationExtensions
return list;
}
public static HashSet<T> ReadEntitySet<T>(this IGenericReader reader) where T : class, ISerializable
public static HashSet<T> ReadEntitySet<T>(
this IGenericReader reader,
bool nullIfEmpty = false
) where T : class, ISerializable
{
var count = reader.ReadInt();
if (count == 0 && nullIfEmpty)
{
return null;
}
var set = new HashSet<T>(count);
for (var i = 0; i < count; ++i)