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:
parent
3f6a87483b
commit
fa5eafdaff
23 changed files with 325 additions and 88 deletions
|
|
@ -39,14 +39,13 @@ namespace Server
|
|||
|
||||
void Write(DateTime value)
|
||||
{
|
||||
var ticks = (value.Kind switch
|
||||
// If DateTimeKind is Unspecified, we can't assume it needs to be converted.
|
||||
if (value.Kind == DateTimeKind.Local)
|
||||
{
|
||||
DateTimeKind.Local => value.ToUniversalTime(),
|
||||
DateTimeKind.Unspecified => value.ToLocalTime().ToUniversalTime(),
|
||||
_ => value
|
||||
}).Ticks;
|
||||
value = value.ToUniversalTime();
|
||||
}
|
||||
|
||||
Write(ticks);
|
||||
Write(value.Ticks);
|
||||
}
|
||||
void WriteDeltaTime(DateTime value)
|
||||
{
|
||||
|
|
@ -59,17 +58,16 @@ namespace Server
|
|||
if (value == DateTime.MaxValue)
|
||||
{
|
||||
Write(long.MaxValue);
|
||||
return;
|
||||
}
|
||||
|
||||
var ticks = (value.Kind switch
|
||||
if (value.Kind == DateTimeKind.Local)
|
||||
{
|
||||
DateTimeKind.Local => value.ToUniversalTime(),
|
||||
DateTimeKind.Unspecified => value.ToLocalTime().ToUniversalTime(),
|
||||
_ => value
|
||||
}).Ticks;
|
||||
value = value.ToUniversalTime();
|
||||
}
|
||||
|
||||
// Technically supports negative deltas for times in the past
|
||||
Write(ticks - DateTime.UtcNow.Ticks);
|
||||
Write(value.Ticks - DateTime.UtcNow.Ticks);
|
||||
}
|
||||
void Write(IPAddress value)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue