fix: Fixes guild deserialization (#867)
* Fixes guilds being marked as deleted because the leader hasn't been deserialized yet. * Fixes LastSerialization issue.
This commit is contained in:
parent
1ac803e778
commit
aff2f15a6c
4 changed files with 12 additions and 20 deletions
|
|
@ -37,7 +37,7 @@ namespace Server
|
|||
_encoding = encoding ?? TextEncoding.UTF8;
|
||||
}
|
||||
|
||||
public BufferReader(byte[] buffer, DateTime LastSerialized) : this(buffer) => LastSerialized = LastSerialized;
|
||||
public BufferReader(byte[] buffer, DateTime lastSerialized) : this(buffer) => LastSerialized = lastSerialized;
|
||||
|
||||
public void Reset(byte[] newBuffer, out byte[] oldBuffer)
|
||||
{
|
||||
|
|
@ -47,7 +47,7 @@ namespace Server
|
|||
}
|
||||
|
||||
// Compatible with BinaryReader.ReadString()
|
||||
public DateTime LastSerialized { get; init; } = DateTime.MinValue;
|
||||
public DateTime LastSerialized { get; init; }
|
||||
|
||||
public string ReadString(bool intern = false)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -525,7 +525,7 @@ namespace Server
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static IEntity FindEntity(Serial serial, bool returnDeleted = false) => FindEntity<IEntity>(serial);
|
||||
public static IEntity FindEntity(Serial serial, bool returnDeleted = false) => FindEntity<IEntity>(serial, returnDeleted);
|
||||
|
||||
public static T FindEntity<T>(Serial serial, bool returnDeleted = false) where T : class, IEntity
|
||||
{
|
||||
|
|
@ -669,15 +669,17 @@ namespace Server
|
|||
if (typeof(BaseGuild).IsAssignableFrom(typeT))
|
||||
{
|
||||
entity = FindGuild(serial) as T;
|
||||
// If we check for `entity.Deleted` here during deserialization then all guilds are deleted because
|
||||
// Deleted -> Disbanded -> No leader, which is the case before deserialization.
|
||||
// TODO: Use a deleted flag instead, and actively check for dibanded guilds properly.
|
||||
}
|
||||
else
|
||||
{
|
||||
entity = FindEntity<IEntity>(serial) as T;
|
||||
}
|
||||
|
||||
if (entity?.Deleted == false)
|
||||
{
|
||||
return entity;
|
||||
if (entity?.Deleted == false)
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
return entity?.Created <= reader.LastSerialized ? entity : null;
|
||||
|
|
|
|||
|
|
@ -661,15 +661,7 @@ namespace Server.Guilds
|
|||
|
||||
public AllianceInfo Alliance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_AllianceInfo != null)
|
||||
{
|
||||
return m_AllianceInfo;
|
||||
}
|
||||
|
||||
return m_AllianceLeader?.m_AllianceInfo;
|
||||
}
|
||||
get => m_AllianceInfo ?? m_AllianceLeader?.m_AllianceInfo;
|
||||
set
|
||||
{
|
||||
var current = Alliance;
|
||||
|
|
|
|||
|
|
@ -790,9 +790,7 @@ namespace Server.Spells
|
|||
return false;
|
||||
}
|
||||
|
||||
public bool CheckBSequence(Mobile target) => CheckBSequence(target, false);
|
||||
|
||||
public bool CheckBSequence(Mobile target, bool allowDead)
|
||||
public bool CheckBSequence(Mobile target, bool allowDead = false)
|
||||
{
|
||||
if (!target.Alive && !allowDead)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue