fix: Adds Created, LastSerialized, and BeforeSerialize for all entities. (#775)

* Adds `BeforeSerialized` for entities to handle cleanup.
* Adds `Created` and `LastSerialized` fields to all entities. While this is a big bloat, this will be necessary for identifying dangling references to other invalid entities.
* Changes formula for determining a valid reference to be _not null, not deleted, and reference's created date must be at or before the entities last serialized date_.
* Adds versioning to idx file and serializes `Created` and `LastSerialized`.
* Fixes Save Stats and also disables it by default.
This commit is contained in:
Kamron Batman 2021-09-26 01:09:45 -07:00 • committed by GitHub
parent 3f6a87483b
commit fa5eafdaff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 325 additions and 88 deletions

View file

@ -87,7 +87,7 @@ namespace Server.Misc
if (Required != null && version < Required && (m_OldClientResponse == OldClientResponse.Kick ||
m_OldClientResponse == OldClientResponse.LenientKick &&
Core.Now - state.Mobile.CreationTime > m_AgeLeniency &&
Core.Now - state.Mobile.Created > m_AgeLeniency &&
state.Mobile is PlayerMobile mobile &&
mobile.GameTime > m_GameTimeLeniency))
{

View file

@ -1156,6 +1156,10 @@ namespace Server.Guilds
list.TrimExcess();
}
public override void BeforeSerialize()
{
}
public override void Serialize(IGenericWriter writer)
{
if (LastFealty + TimeSpan.FromDays(1.0) < Core.Now)

View file

@ -69,24 +69,24 @@ namespace Server.Misc
return "";
}
var ts = Core.Now - a.Created;
var age = a.AccountAge;
if (Format(ts.TotalDays, "This account is {0} day{1} old.", out var v))
if (Format(age.TotalDays, "This account is {0} day{1} old.", out var v))
{
return v;
}
if (Format(ts.TotalHours, "This account is {0} hour{1} old.", out v))
if (Format(age.TotalHours, "This account is {0} hour{1} old.", out v))
{
return v;
}
if (Format(ts.TotalMinutes, "This account is {0} minute{1} old.", out v))
if (Format(age.TotalMinutes, "This account is {0} minute{1} old.", out v))
{
return v;
}
if (Format(ts.TotalSeconds, "This account is {0} second{1} old.", out v))
if (Format(age.TotalSeconds, "This account is {0} second{1} old.", out v))
{
return v;
}