Пример #1
0
        public static void Stop()
        {
            if (m_Recording)
            {
                byte[] hash;

                // the final timestamp
                m_GZOut.Compressed.Write((int)((DateTime.UtcNow - m_LastTime).TotalMilliseconds));
                m_GZOut.Compressed.Write((byte)0xFF);

                m_GZOut.ForceFlush();
                m_GZOut.BufferAll = true;

                m_GZOut.RawStream.Seek(1 + 16 + 8, SeekOrigin.Begin);
                m_GZOut.Raw.Write((int)((DateTime.UtcNow - m_StartTime).TotalMilliseconds));

                m_GZOut.RawStream.Seek(1 + 16, SeekOrigin.Begin);
                using (MD5 md5 = MD5.Create())
                    hash = md5.ComputeHash(m_GZOut.RawStream);

                m_GZOut.RawStream.Seek(1, SeekOrigin.Begin);
                m_GZOut.Raw.Write(hash);

                m_GZOut.RawStream.Flush();
                m_GZOut.Close();
                m_GZOut = null;

                m_Recording     = false;
                btnRec.Text     = "Record PacketVideo";
                btnPlay.Enabled = btnStop.Enabled = true;
            }
            else if (Playing)
            {
                //ClientCommunication.SetDeathMsg( Language.GetString( LocString.PacketPlayerStop + Utility.Random( 10 ) ) );
                ClientCommunication.ForceSendToClient(new DeathStatus(true));

                RemoveAll();

                if (m_PlayTimer != null && m_PlayTimer.Running)
                {
                    m_PlayTimer.Stop();
                }

                if (m_ScrollTimer != null)
                {
                    m_ScrollTimer.Stop();
                }

                m_PlayTimer = Timer.DelayedCallback(FadeDelay, m_EndPlay);
                m_PlayTimer.Start();

                btnPlay.Text     = "Play";
                btnClose.Enabled = tbPos.Enabled = btnPlay.Enabled = btnStop.Enabled = false;
            }
        }
Пример #2
0
        public static void Stop()
        {
            if ( m_Recording )
            {
                byte[] hash;

                // the final timestamp
                m_GZOut.Compressed.Write( (int)((DateTime.Now-m_LastTime).TotalMilliseconds) );
                m_GZOut.Compressed.Write( (byte)0xFF );

                m_GZOut.ForceFlush();
                m_GZOut.BufferAll = true;

                m_GZOut.RawStream.Seek( 1+16+8, SeekOrigin.Begin );
                m_GZOut.Raw.Write( (int)((DateTime.Now-m_StartTime).TotalMilliseconds) );

                m_GZOut.RawStream.Seek( 1+16, SeekOrigin.Begin );
                using ( MD5 md5 = MD5.Create() )
                    hash = md5.ComputeHash( m_GZOut.RawStream );

                m_GZOut.RawStream.Seek( 1, SeekOrigin.Begin );
                m_GZOut.Raw.Write( hash );

                m_GZOut.RawStream.Flush();
                m_GZOut.Close();
                m_GZOut = null;

                m_Recording = false;
                btnRec.Text = "Record PacketVideo";
                btnPlay.Enabled = btnStop.Enabled = true;
            }
            else if ( Playing )
            {
                //ClientCommunication.SetDeathMsg( Language.GetString( LocString.PacketPlayerStop + Utility.Random( 10 ) ) );
                ClientCommunication.ForceSendToClient( new DeathStatus( true ) );

                RemoveAll();

                if ( m_PlayTimer != null && m_PlayTimer.Running )
                    m_PlayTimer.Stop();

                if ( m_ScrollTimer != null )
                    m_ScrollTimer.Stop();

                m_PlayTimer = Timer.DelayedCallback( FadeDelay, m_EndPlay );
                m_PlayTimer.Start();

                btnPlay.Text = "Play";
                btnClose.Enabled = tbPos.Enabled = btnPlay.Enabled = btnStop.Enabled = false;
            }
        }
Пример #3
0
        public static void Record()
        {
            if ( m_Recording || Playing || World.Player == null )
                return;

            btnRec.Text = "Stop Recording (PV)";
            btnPlay.Enabled = btnStop.Enabled = false;

            m_HouseDataWritten.Clear();

            string filename;
            string name = "Unknown";
            string path = Config.GetString( "RecFolder" );

            if ( World.Player != null )
                name = World.Player.Name;
            if ( name == null || name.Trim() == "" || name.IndexOfAny( Path.GetInvalidPathChars() ) != -1 )
                name = "Unknown";

            name = String.Format( "{0}_{1}", name, DateTime.Now.ToString( "M-d_HH.mm" ) );
            try
            {
                Engine.EnsureDirectory( path );
            }
            catch
            {
                try
                {
                    path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RazorScreenShots");
                    Config.SetProperty( "RecFolder", path );
                }
                catch
                {
                    path = "";
                }
            }
            int count  = 0;
            do
            {
                filename = Path.Combine( path, String.Format( "{0}{1}.rpv", name, count != 0 ? count.ToString() : ""  ) );
                count--; // cause a - to be put in front of the number
            }
            while ( File.Exists( filename ) );

            m_Recording = true;
            m_StartTime = m_LastTime = DateTime.Now;

            try
            {
                //m_OutStream = new BinaryWriter( new FileStream( filename, FileMode.Create, FileAccess.ReadWrite, FileShare.None ) );
                m_GZOut = new GZBlockOut( filename, 2048 );

                m_GZOut.Raw.Write( (byte) PlayerVersion );
                m_GZOut.Raw.Seek( 16, SeekOrigin.Current ); // md5
                m_GZOut.Raw.Write( (long)m_StartTime.ToFileTime() );
                m_GZOut.Raw.Write( (int)(0) ); // length

                m_GZOut.BufferAll = true;
                m_GZOut.Compressed.Write( World.Player.Name );
                m_GZOut.Compressed.Write( World.ShardName );
                byte[] addr;
                try
                {
                    addr = ClientCommunication.LastConnection.GetAddressBytes();
                }
                catch
                {
                    addr = new byte[4]{0,0,0,0};
                }
                m_GZOut.Compressed.Write( addr, 0, 4 );
                SaveWorldState();
                m_GZOut.BufferAll = false;
                m_GZOut.Flush();
            }
            catch  ( Exception e )
            {
                MessageBox.Show( Engine.MainWindow, Language.GetString( LocString.RecError ), "Rec Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
                Engine.LogCrash( e );
            }
        }
Пример #4
0
        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();
        }
Пример #5
0
        public static void Record()
        {
            if (m_Recording || Playing || World.Player == null)
            {
                return;
            }

            btnRec.Text     = "Stop Recording (PV)";
            btnPlay.Enabled = btnStop.Enabled = false;

            m_HouseDataWritten.Clear();

            string filename;
            string name = "Unknown";
            string path = Config.GetString("RecFolder");

            if (World.Player != null)
            {
                name = World.Player.Name;
            }
            if (name == null || name.Trim() == "" || name.IndexOfAny(Path.GetInvalidPathChars()) != -1)
            {
                name = "Unknown";
            }

            name = String.Format("{0}_{1}", name, Engine.MistedDateTime.ToString("M-d_HH.mm"));
            try
            {
                Engine.EnsureDirectory(path);
            }
            catch
            {
                try
                {
                    path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RazorScreenShots");
                    Config.SetProperty("RecFolder", path);
                }
                catch
                {
                    path = "";
                }
            }
            int count = 0;

            do
            {
                filename = Path.Combine(path, String.Format("{0}{1}.rpv", name, count != 0 ? count.ToString() : ""));
                count--;                 // cause a - to be put in front of the number
            }while (File.Exists(filename));

            m_Recording = true;
            m_StartTime = m_LastTime = DateTime.UtcNow;

            try
            {
                //m_OutStream = new BinaryWriter( new FileStream( filename, FileMode.Create, FileAccess.ReadWrite, FileShare.None ) );
                m_GZOut = new GZBlockOut(filename, 2048);

                m_GZOut.Raw.Write((byte)PlayerVersion);
                m_GZOut.Raw.Seek(16, SeekOrigin.Current);      // md5
                m_GZOut.Raw.Write((long)m_StartTime.ToFileTime());
                m_GZOut.Raw.Write((int)(0));                   // length

                m_GZOut.BufferAll = true;
                m_GZOut.Compressed.Write(World.Player.Name);
                m_GZOut.Compressed.Write(World.ShardName);
                byte[] addr;
                try
                {
                    addr = ClientCommunication.LastConnection.GetAddressBytes();
                }
                catch
                {
                    addr = new byte[4] {
                        0, 0, 0, 0
                    };
                }
                m_GZOut.Compressed.Write(addr, 0, 4);
                SaveWorldState();
                m_GZOut.BufferAll = false;
                m_GZOut.Flush();
            }
            catch (Exception e)
            {
                MessageBox.Show(Engine.MainWindow, Language.GetString(LocString.RecError), "Rec Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Engine.LogCrash(e);
            }
        }