fix: Cleans up entity persistence. Generalizes Mobiles/Items/Guilds (#1528)
### Summary - [X] Fixed a bug where entity persistence was serialized out of order, causing world corruption. - [X] Fixed LastSerialized not being utilized properly and dangling references still becoming an issue. - [X] Added a new `GenericEntityPersistence<T>` type to encapsulate `ISerializable` serialization. - [X] Removing the custom logic and moved Items, Mobiles, Guilds, and Accounts to GenericEntityPersistence. - [X] Changed serialization to use the singleton pattern to reduce calling methods from stored variables.
This commit is contained in:
parent
e0225c6e59
commit
f2de2fbb77
34 changed files with 721 additions and 970 deletions
|
|
@ -2702,7 +2702,7 @@ public abstract class BaseAI
|
|||
}
|
||||
|
||||
// Ignore players with activated honor
|
||||
if (m_Mobile.Combatant != m && pm?.GetVirtues()?.HonorActive == true)
|
||||
if (m_Mobile.Combatant != m && VirtueSystem.GetVirtues(pm)?.HonorActive == true)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1288,7 +1288,7 @@ namespace Server.Mobiles
|
|||
return false;
|
||||
}
|
||||
|
||||
if ((m as PlayerMobile)?.GetVirtues()?.HonorActive == true)
|
||||
if (VirtueSystem.GetVirtues(m as PlayerMobile)?.HonorActive == true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -697,30 +697,32 @@ namespace Server.Mobiles
|
|||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
|
||||
public ChampionTitleContext ChampionTitles => this.GetOrCreateChampionTitleContext();
|
||||
public ChampionTitleContext ChampionTitles => ChampionTitleSystem.GetOrCreateChampionTitleContext(this);
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int ShortTermMurders
|
||||
{
|
||||
get => this.GetMurderContext(out var context) ? context.ShortTermMurders : 0;
|
||||
get => PlayerMurderSystem.GetMurderContext(this, out var context) ? context.ShortTermMurders : 0;
|
||||
set => PlayerMurderSystem.ManuallySetShortTermMurders(this, value);
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime ShortTermMurderExpiration => this.GetMurderContext(out var context) && context.ShortTermMurders > 0
|
||||
? Core.Now + (context.ShortTermElapse - GameTime)
|
||||
: DateTime.MinValue;
|
||||
public DateTime ShortTermMurderExpiration
|
||||
=> PlayerMurderSystem.GetMurderContext(this, out var context) && context.ShortTermMurders > 0
|
||||
? Core.Now + (context.ShortTermElapse - GameTime)
|
||||
: DateTime.MinValue;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime LongTermMurderExpiration => Kills > 0 && this.GetMurderContext(out var context)
|
||||
? Core.Now + (context.LongTermElapse - GameTime)
|
||||
: DateTime.MinValue;
|
||||
public DateTime LongTermMurderExpiration
|
||||
=> Kills > 0 && PlayerMurderSystem.GetMurderContext(this, out var context)
|
||||
? Core.Now + (context.LongTermElapse - GameTime)
|
||||
: DateTime.MinValue;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int KnownRecipes => m_AcquiredRecipes?.Count ?? 0;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, canModify: true)]
|
||||
public VirtueContext Virtues => this.GetOrCreateVirtues();
|
||||
public VirtueContext Virtues => VirtueSystem.GetOrCreateVirtues(this);
|
||||
|
||||
public HonorContext ReceivedHonorContext { get; set; }
|
||||
|
||||
|
|
@ -1255,7 +1257,7 @@ namespace Server.Mobiles
|
|||
|
||||
if (from is PlayerMobile mobile)
|
||||
{
|
||||
mobile.CheckAtrophies();
|
||||
VirtueSystem.CheckAtrophies(mobile);
|
||||
mobile.ClaimAutoStabledPets();
|
||||
}
|
||||
}
|
||||
|
|
@ -3426,7 +3428,7 @@ namespace Server.Mobiles
|
|||
// https://uo.com/wiki/ultima-online-wiki/player/skill-titles-order/
|
||||
if (DisplayChampionTitle)
|
||||
{
|
||||
var titleLabel = this.GetChampionTitleLabel();
|
||||
var titleLabel = ChampionTitleSystem.GetChampionTitleLabel(this);
|
||||
if (titleLabel > 0)
|
||||
{
|
||||
list.Add(titleLabel);
|
||||
|
|
|
|||
|
|
@ -643,7 +643,7 @@ public partial class BaseEscortable : BaseCreature
|
|||
|
||||
if (escorter is PlayerMobile pm)
|
||||
{
|
||||
var virtues = pm.GetOrCreateVirtues();
|
||||
var virtues = VirtueSystem.GetOrCreateVirtues(pm);
|
||||
if (virtues.CompassionGains > 0 && Core.Now > virtues.NextCompassionDay)
|
||||
{
|
||||
virtues.NextCompassionDay = DateTime.MinValue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue