protected override void SaveUndoData(UndoCache buffer, string path) { using (FileStream fs = File.Create(path)) { BinaryWriter w = new BinaryWriter(fs); long entriesPos = 0; ChunkHeader last = default(ChunkHeader); UndoCacheNode node = buffer.Tail; while (node != null) { List <UndoCacheItem> items = node.Items; for (int i = 0; i < items.Count; i++) { UndoCacheItem uP = items[i]; DateTime time = node.BaseTime.AddSeconds(uP.TimeDelta); int timeDiff = (int)(time - last.BaseTime).TotalSeconds; if (last.LevelName != node.MapName || timeDiff > (65535 >> 2) || last.Entries == ushort.MaxValue) { WriteChunkEntries(w, last.Entries, entriesPos); last = WriteEmptyChunk(w, node, time, ref entriesPos); } int flags = (uP.Flags & 0xC000) | timeDiff; w.Write((ushort)flags); w.Write(uP.Index); w.Write(uP.Type); w.Write(uP.NewType); last.Entries++; } if (last.Entries > 0) { WriteChunkEntries(w, last.Entries, entriesPos); } node = node.Prev; } } }
protected abstract void SaveUndoData(UndoCache buffer, string path);
protected override void SaveUndoData(UndoCache buffer, string path) { throw new NotSupportedException("Non-optimised binary undo files have been deprecated"); }