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:
parent
d99e72db8f
commit
3b97e8d39c
13 changed files with 391 additions and 280 deletions
|
|
@ -287,37 +287,34 @@ namespace Server.Commands
|
|||
{
|
||||
var pets = pm.AllFollowers;
|
||||
|
||||
if (pets.Count > 0)
|
||||
if (!(pets?.Count > 0))
|
||||
{
|
||||
CommandLogging.WriteLine(
|
||||
from,
|
||||
$"{from.AccessLevel} {CommandLogging.Format(from)} getting all followers of {CommandLogging.Format(pm)}"
|
||||
);
|
||||
from.SendMessage("There were no pets found for that player.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (pets.Count == 1)
|
||||
{
|
||||
from.SendMessage($"That player has {pets.Count} pet.");
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage($"That player has {pets.Count} pets.");
|
||||
}
|
||||
CommandLogging.WriteLine(
|
||||
from,
|
||||
$"{from.AccessLevel} {CommandLogging.Format(from)} getting all followers of {CommandLogging.Format(pm)}"
|
||||
);
|
||||
|
||||
for (var i = 0; i < pets.Count; ++i)
|
||||
{
|
||||
var pet = pets[i];
|
||||
|
||||
if (pet is IMount mount)
|
||||
{
|
||||
mount.Rider = null; // make sure it's dismounted
|
||||
}
|
||||
|
||||
pet.MoveToWorld(from.Location, from.Map);
|
||||
}
|
||||
if (pets.Count == 1)
|
||||
{
|
||||
from.SendMessage($"That player has {pets.Count} pet.");
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage("There were no pets found for that player.");
|
||||
from.SendMessage($"That player has {pets.Count} pets.");
|
||||
}
|
||||
|
||||
foreach (var pet in pets)
|
||||
{
|
||||
if (pet is IMount mount)
|
||||
{
|
||||
mount.Rider = null; // make sure it's dismounted
|
||||
}
|
||||
|
||||
pet.MoveToWorld(from.Location, from.Map);
|
||||
}
|
||||
}
|
||||
else if (obj is Mobile master && master.Player)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue