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
|
|
@ -59,15 +59,8 @@ namespace Server.Engines.VeteranRewards
|
|||
return false;
|
||||
}
|
||||
|
||||
public static bool HasAccess(Mobile mob, RewardEntry entry)
|
||||
{
|
||||
if (Core.Expansion < entry.RequiredExpansion)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return HasAccess(mob, entry.List, out var _);
|
||||
}
|
||||
public static bool HasAccess(Mobile mob, RewardEntry entry) =>
|
||||
Core.Expansion >= entry.RequiredExpansion && HasAccess(mob, entry.List, out var _);
|
||||
|
||||
public static bool HasAccess(Mobile mob, RewardList list, out TimeSpan ts)
|
||||
{
|
||||
|
|
@ -77,13 +70,13 @@ namespace Server.Engines.VeteranRewards
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!(mob.Account is Account acct))
|
||||
if (mob.Account is not Account acct)
|
||||
{
|
||||
ts = TimeSpan.Zero;
|
||||
return false;
|
||||
}
|
||||
|
||||
ts = list.Age - (Core.Now - acct.Created);
|
||||
ts = list.Age - acct.AccountAge;
|
||||
|
||||
return ts <= TimeSpan.Zero;
|
||||
}
|
||||
|
|
@ -98,12 +91,8 @@ namespace Server.Engines.VeteranRewards
|
|||
return GetRewardLevel(acct);
|
||||
}
|
||||
|
||||
public static int GetRewardLevel(Account acct)
|
||||
{
|
||||
var totalTime = Core.Now - acct.Created;
|
||||
|
||||
return Math.Max((int)(totalTime.TotalDays / RewardInterval.TotalDays), 0);
|
||||
}
|
||||
public static int GetRewardLevel(Account acct) =>
|
||||
Math.Max((int)(acct.AccountAge.TotalDays / RewardInterval.TotalDays), 0);
|
||||
|
||||
public static bool HasHalfLevel(Mobile mob)
|
||||
{
|
||||
|
|
@ -115,14 +104,7 @@ namespace Server.Engines.VeteranRewards
|
|||
return HasHalfLevel(acct);
|
||||
}
|
||||
|
||||
public static bool HasHalfLevel(Account acct)
|
||||
{
|
||||
var totalTime = Core.Now - acct.Created;
|
||||
|
||||
var level = totalTime.TotalDays / RewardInterval.TotalDays;
|
||||
|
||||
return level >= 0.5;
|
||||
}
|
||||
public static bool HasHalfLevel(Account acct) => acct.AccountAge.TotalDays / RewardInterval.TotalDays >= 0.5;
|
||||
|
||||
public static bool ConsumeRewardPoint(Mobile mob)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue