mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-10-03 02:21:53 -04:00
[Highly experimental, may still have bugs] - minimised memory usage of storing online player undo data.
This commit is contained in:
parent
f8e83786c2
commit
dd9c2a4158
@ -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--) {
|
||||||
|
@ -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--) {
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user