static void LoadFile(List <HistoryNode> l, string path) { string username = Path.GetFileName(path); if (File.Exists(path)) { using (FileStream f = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { while (f.Position < f.Length) { try { byte[] b = ProtocolParser.ReadBytes(f); LogStream ls = LogStream.Deserialize(b); if (ls.Digging != null && ls.Digging.Status != PlayerDigging.StatusEnum.FinishedDigging) { continue; } if (ls.PlaceBlock != null) { if (ls.PlaceBlock.Item == null) { continue; } if (ls.PlaceBlock.Item.ItemID <= 0) { continue; } } HistoryNode n = HistoryNode.FromLog(ls, username); if (n == null) { continue; } if (Math.Abs(n.Position.X) < 2 || Math.Abs(n.Position.Z) < 2) { continue; } l.Add(n); } catch (Exception) { } } } } return; }
public static HistoryNode FromLog (LogStream l, string username) { if(l.Position == null) return null; HistoryNode n = new HistoryNode (); n.Username = username; n.Dimension = l.Position.Dimension; n.Timestamp = l.Timestamp; if (l.Digging != null) { if (l.Digging.Status != PlayerDigging.StatusEnum.FinishedDigging) return null; n.Position = l.Digging.Position.CloneDouble (); n.Color = Color.Red; return n; } if (l.PlaceBlock != null) { n.Position = l.PlaceBlock.BlockPosition.CloneDouble (); if (l.PlaceBlock.Item == null || l.PlaceBlock.Item.ItemID <= 0) { n.Color = Color.Transparent; return n; } n.Color = Color.GreenYellow; //All other blocks n.Item = l.PlaceBlock.Item; if (l.PlaceBlock.Item.ItemID == BlockID.Waterbucket) n.Color = Color.Blue; if (l.PlaceBlock.Item.ItemID == BlockID.FlintandSteel) n.Color = Color.Orange; if (l.PlaceBlock.Item.ItemID == BlockID.Lavabucket) n.Color = Color.Orange; if (l.PlaceBlock.Item.ItemID == BlockID.TNT) n.Color = Color.Red; return n; } if (l.Window != null && l.Window.WindowID >= 0) { n.Position = l.Position.Position; n.Color = Color.Yellow; n.Item = l.Window.Item; return n; } return null; }
public static HistoryNode FromLog(LogStream l, string username) { if (l.Position == null) { return(null); } HistoryNode n = new HistoryNode(); n.Username = username; n.Dimension = l.Position.Dimension; n.Timestamp = l.Timestamp; if (l.Digging != null) { if (l.Digging.Status != PlayerDigging.StatusEnum.FinishedDigging) { return(null); } n.Position = l.Digging.Position.CloneDouble(); n.Color = Color.Red; return(n); } if (l.PlaceBlock != null) { n.Position = l.PlaceBlock.BlockPosition.CloneDouble(); if (l.PlaceBlock.Item == null || l.PlaceBlock.Item.ItemID <= 0) { n.Color = Color.Transparent; return(n); } n.Color = Color.GreenYellow; //All other blocks n.Item = l.PlaceBlock.Item; if (l.PlaceBlock.Item.ItemID == BlockID.Waterbucket) { n.Color = Color.Blue; } if (l.PlaceBlock.Item.ItemID == BlockID.FlintandSteel) { n.Color = Color.Orange; } if (l.PlaceBlock.Item.ItemID == BlockID.Lavabucket) { n.Color = Color.Orange; } if (l.PlaceBlock.Item.ItemID == BlockID.TNT) { n.Color = Color.Red; } return(n); } if (l.Window != null && l.Window.WindowID >= 0) { n.Position = l.Position.Position; n.Color = Color.Yellow; n.Item = l.Window.Item; return(n); } return(null); }