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
|
|
@ -4,16 +4,21 @@ using Server.Mobiles;
|
|||
|
||||
namespace Server.Items;
|
||||
|
||||
public static class DisguisePersistence
|
||||
public class DisguisePersistence : GenericPersistence
|
||||
{
|
||||
private static DisguisePersistence _disguisePersistence;
|
||||
public static Dictionary<Mobile, Timer> Timers { get; } = new();
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
GenericPersistence.Register("Disguises", Serialize, Deserialize);
|
||||
_disguisePersistence = new DisguisePersistence();
|
||||
}
|
||||
|
||||
private static void Deserialize(IGenericReader reader)
|
||||
public DisguisePersistence() : base("Disguises", 10)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
var count = reader.ReadEncodedInt();
|
||||
for (var i = 0; i < count; ++i)
|
||||
|
|
@ -24,7 +29,7 @@ public static class DisguisePersistence
|
|||
}
|
||||
}
|
||||
|
||||
private static void Serialize(IGenericWriter writer)
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt(Timers.Count);
|
||||
foreach (var (m, timer) in Timers)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue