private void SaveRPV(string filename) { int curTime = 0; int i = 0; while (i < m_Packets.Count) { Packet p = (Packet)m_Packets[i]; curTime = p.Time; if (curTime < begPos.Value) { PacketHandlers.ProcessPacket(p.Data); } else { break; } i++; } m_Date += TimeSpan.FromMilliseconds(curTime); GZBlockOut gzout; try { gzout = new GZBlockOut(filename, 2048); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error Saving RPV!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } gzout.Raw.Write((byte)PlayerVersion); gzout.Raw.Seek(16, SeekOrigin.Current); // md5 gzout.Raw.Write((long)m_Date.ToFileTime()); gzout.Raw.Write((int)(endPos.Value - begPos.Value)); // length gzout.BufferAll = true; gzout.Compressed.Write(World.Player.Name); gzout.Compressed.Write(World.ShardName); gzout.Compressed.Write(m_IP.GetAddressBytes(), 0, 4); long start = gzout.Position; gzout.Compressed.Write((int)0); // len World.Player.SaveState(gzout.Compressed); foreach (Mobile m in World.Mobiles.Values) { if (m != World.Player) { gzout.Compressed.Write((byte)1); m.SaveState(gzout.Compressed); } } foreach (Item item in World.Items.Values) { if (!(item.Container is Item)) { gzout.Compressed.Write((byte)0); item.SaveState(gzout.Compressed); } } long end = gzout.Position; gzout.Seek((int)start, SeekOrigin.Begin); gzout.Compressed.Write((int)(end - (start + 4))); gzout.Seek(0, SeekOrigin.End); gzout.BufferAll = false; gzout.Flush(); int lastTime = curTime; while (i < m_Packets.Count) { Packet p = (Packet)m_Packets[i++]; curTime = p.Time; if (curTime <= endPos.Value) { gzout.Compressed.Write((int)(p.Time - curTime)); gzout.Compressed.Write(p.Data); } else { break; } } gzout.Compressed.Write((int)(endPos.Value - curTime)); gzout.Compressed.Write((byte)0xFF); gzout.ForceFlush(); gzout.BufferAll = true; gzout.RawStream.Seek(1 + 16, SeekOrigin.Begin); byte[] hash; using (MD5 md5 = MD5.Create()) hash = md5.ComputeHash(gzout.RawStream); gzout.RawStream.Seek(1, SeekOrigin.Begin); gzout.Raw.Write(hash); gzout.RawStream.Flush(); gzout.Close(); gzout = null; NeedSave = false; CloseRPV(); }