Skip to content

Commit

Permalink
fix: Fixes memory leak in virtual mounts and codegens specials (#1476)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Aug 26, 2023
1 parent 701deb5 commit fc3aa13
Show file tree
Hide file tree
Showing 38 changed files with 2,029 additions and 2,185 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using ModernUO.Serialization;
using Server.Factions.AI;
using Server.Items;
using Server.Mobiles;
Expand Down Expand Up @@ -485,45 +486,43 @@ public virtual void OnRiderDamaged(int amount, Mobile from, bool willKill)
}
}

public class VirtualMountItem : Item, IMountItem
[SerializationGenerator(0, false)]
public partial class VirtualMountItem : Item, IMountItem
{
private readonly VirtualMount m_Mount;
private VirtualMount _mount;

[SerializableField(0)]
private Mobile _rider;

public VirtualMountItem(Mobile mob) : base(0x3EA0)
{
Layer = Layer.Mount;

Rider = mob;
m_Mount = new VirtualMount(this);
_mount = new VirtualMount(this);
}

public VirtualMountItem(Serial serial) : base(serial) => m_Mount = new VirtualMount(this);

public Mobile Rider { get; private set; }

public IMount Mount => m_Mount;
public IMount Mount => _mount;

public override void Serialize(IGenericWriter writer)
[AfterDeserialization]
private void AfterDeserialization()
{
base.Serialize(writer);

writer.Write(0); // version

writer.Write(Rider);
if (_rider?.Deleted != false)
{
Delete();
}
else
{
_mount = new VirtualMount(this);
}
}

public override void Deserialize(IGenericReader reader)
public override DeathMoveResult OnParentDeath(Mobile parent)
{
base.Deserialize(reader);
_mount = null;
Delete();

var version = reader.ReadInt();

Rider = reader.ReadEntity<Mobile>();

if (Rider == null)
{
Delete();
}
return DeathMoveResult.RemainEquipped;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions Projects/UOContent/Migrations/Server.Mobiles.Harrower.v1.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Projects/UOContent/Migrations/Server.Mobiles.LordOaks.v0.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Projects/UOContent/Migrations/Server.Mobiles.Mephitis.v0.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Projects/UOContent/Migrations/Server.Mobiles.Neira.v1.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Projects/UOContent/Migrations/Server.Mobiles.Rikktor.v0.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Projects/UOContent/Migrations/Server.Mobiles.Semidar.v0.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Projects/UOContent/Migrations/Server.Mobiles.Serado.v0.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Projects/UOContent/Migrations/Server.Mobiles.Silvani.v0.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fc3aa13

Please sign in to comment.