[Highly experimental, may still have bugs] - minimised memory usage of storing online player undo data.

This commit is contained in:
UnknownShadow200 2016-02-25 23:13:01 +11:00
parent f8e83786c2
commit dd9c2a4158
5 changed files with 7 additions and 9 deletions

View File

@ -71,7 +71,7 @@ namespace MCGalaxy.Commands {
while (node != null) {
Level lvl = LevelInfo.FindExact(node.MapName);
if (lvl != p.level) continue;
if (lvl != p.level) { node = node.Prev; continue; }
List<UndoCacheItem> items = node.Items;
for (int i = items.Count - 1; i >= 0; i--) {

View File

@ -42,7 +42,7 @@ namespace MCGalaxy.Commands {
while (node != null) {
Level lvl = LevelInfo.FindExact(node.MapName);
if (lvl == null) continue;
if (lvl == null) { node = node.Prev; continue; }
List<UndoCacheItem> items = node.Items;
for (int i = items.Count - 1; i >= 0; i--) {

View File

@ -159,7 +159,7 @@ namespace MCGalaxy.Commands
while (node != null) {
Level lvl = LevelInfo.FindExact(node.MapName);
if (lvl == null) continue;
if (lvl == null) { node = node.Prev; continue; }
saveLvl = lvl;
List<UndoCacheItem> items = node.Items;

View File

@ -402,7 +402,7 @@ namespace MCGalaxy {
Server.ErrorLog(e);
}
try {
SaveUndo();
SaveUndo(this);
} catch (Exception e) {
Server.s.Log("Error saving undo data.");
Server.ErrorLog(e);
@ -559,7 +559,7 @@ namespace MCGalaxy {
if (name == "") {
if (socket != null) CloseSocket();
connections.Remove(this);
SaveUndo();
SaveUndo(this);
disconnected = true;
return;
}
@ -637,8 +637,6 @@ namespace MCGalaxy {
}
}
public void SaveUndo() { SaveUndo(this); }
public static void SaveUndo(Player p) {
try {
UndoFile.SaveUndo(p);

View File

@ -41,7 +41,7 @@ namespace MCGalaxy.Util {
protected abstract string Extension { get; }
public static void SaveUndo(Player p) {
if( p == null || p.UndoBuffer.Count < 1) return;
if (p == null || p.UndoBuffer.Count < 1) return;
CreateDefaultDirectories();
if (Directory.GetDirectories(undoDir).Length >= Server.totalUndo) {