[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) { while (node != null) {
Level lvl = LevelInfo.FindExact(node.MapName); Level lvl = LevelInfo.FindExact(node.MapName);
if (lvl != p.level) continue; if (lvl != p.level) { node = node.Prev; continue; }
List<UndoCacheItem> items = node.Items; List<UndoCacheItem> items = node.Items;
for (int i = items.Count - 1; i >= 0; i--) { for (int i = items.Count - 1; i >= 0; i--) {

View File

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

View File

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

View File

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

View File

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