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
|
|
@ -6,10 +6,11 @@ using Server.Utilities;
|
|||
|
||||
namespace Server.Engines.Stealables;
|
||||
|
||||
public static class StealableArtifacts
|
||||
public class StealableArtifacts : GenericPersistence
|
||||
{
|
||||
private static readonly ILogger logger = LogFactory.GetLogger(typeof(StealableArtifacts));
|
||||
|
||||
private static StealableArtifacts _stealableArtifactsPersistence;
|
||||
private static bool _enabled;
|
||||
private static Type[] _typesOfEntries;
|
||||
private static StealableInstance[] _artifacts;
|
||||
|
|
@ -19,7 +20,11 @@ public static class StealableArtifacts
|
|||
|
||||
public static void Configure()
|
||||
{
|
||||
GenericPersistence.Register("StealableArtifacts", Serialize, Deserialize);
|
||||
_stealableArtifactsPersistence = new StealableArtifacts();
|
||||
}
|
||||
|
||||
public StealableArtifacts() : base("StealableArtifacts", 10)
|
||||
{
|
||||
}
|
||||
|
||||
private static void RemoveStealableArtifacts()
|
||||
|
|
@ -242,7 +247,7 @@ public static class StealableArtifacts
|
|||
}
|
||||
}
|
||||
|
||||
private static void Serialize(IGenericWriter writer)
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt(1); // version
|
||||
|
||||
|
|
@ -262,7 +267,7 @@ public static class StealableArtifacts
|
|||
}
|
||||
}
|
||||
|
||||
private static void Deserialize(IGenericReader reader)
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
var version = reader.ReadEncodedInt();
|
||||
|
||||
|
|
@ -441,7 +446,7 @@ public static class StealableArtifacts
|
|||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
StealableArtifacts.Deserialize(reader);
|
||||
_stealableArtifactsPersistence.Deserialize(reader);
|
||||
|
||||
Timer.DelayCall(Delete);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue