Fix session modified overflowing after 2 billion (Thanks rdebath, addresses #663)

This commit is contained in:
UnknownShadow200 2021-11-21 22:25:43 +11:00
parent 9f12f21b87
commit 4efa528cc2
8 changed files with 17 additions and 8 deletions

1
.gitignore vendored
View File

@ -18,6 +18,7 @@ bld/
[Bb]in/
[Oo]bj/
.vs/
*.sdps
# Roslyn cache directories
*.ide/

View File

@ -91,7 +91,7 @@ namespace MCGalaxy.Commands.Maintenance {
MessageDataChanged(p, args[0], args[1], args[2]);
} else if (opt == "modified") {
SetInteger(p, args, PlayerData.ColumnBlocks, int.MaxValue, who,
v => who.TotalModified = v, type_lo);
v => who.SetBaseTotalModified(v), type_lo);
} else if (opt == "drawn") {
SetInteger(p, args, PlayerData.ColumnDrawn, int.MaxValue, who,
v => who.TotalDrawn = v, type_lo);

View File

@ -85,7 +85,7 @@ namespace MCGalaxy.DB {
if (col.Length == 0) col = p.group.Color;
p.SetColor(col);
p.TotalModified = TotalModified;
p.SetBaseTotalModified(TotalModified);
p.TotalDrawn = TotalDrawn;
p.TotalPlaced = TotalPlaced;
p.TotalDeleted = TotalDeleted;

View File

@ -136,6 +136,7 @@ namespace MCGalaxy.DB {
public static void EntityLine(Player p, Player who) {
bool hasSkin = !who.SkinName.CaselessEq(who.truename);
// TODO remove hardcoding
bool hasModel = !(who.Model.CaselessEq("humanoid") || who.Model.CaselessEq("human"));
if (hasSkin && hasModel) {

View File

@ -189,7 +189,7 @@ namespace MCGalaxy.Drawing.Ops
}
lvl.BlockDB.Cache.Add(p, b.X, b.Y, b.Z, op.Flags, old, b.Block);
p.SessionModified++; p.TotalModified++; p.TotalDrawn++; // increment block stats inline
p.TotalModified++; p.TotalDrawn++; // increment block stats inline
// Potentially buffer the block change
if (op.TotalModified == reloadThreshold) {

View File

@ -325,9 +325,7 @@ namespace MCGalaxy {
OtherPhysics.DoSpongeRemoved(this, PosToInt(x, y, z), true);
}
p.SessionModified++;
p.TotalModified++;
p.TotalModified++;
if (drawn) p.TotalDrawn++;
else if (block == Block.Air) p.TotalDeleted++;
else p.TotalPlaced++;

View File

@ -118,10 +118,12 @@ namespace MCGalaxy {
public int money;
public long TotalModified, TotalDrawn, TotalPlaced, TotalDeleted;
public int SessionModified;
public int TimesVisited, TimesBeenKicked, TimesDied;
public int TotalMessagesSent;
long startModified;
public long SessionModified { get { return TotalModified - startModified; } }
DateTime startTime;
public TimeSpan TotalTime {
get { return DateTime.UtcNow - startTime; }

View File

@ -411,7 +411,14 @@ namespace MCGalaxy {
public void CheckForMessageSpam() {
if (spamChecker != null) spamChecker.CheckChatSpam();
}
}
internal void SetBaseTotalModified(long modified) {
long adjust = modified - TotalModified;
TotalModified = modified;
// adjustment so that SessionModified is unaffected
startModified += adjust;
}
string selTitle;
readonly object selLock = new object();