示例#1
0
        private void ReadSurf(byte[] d, ref int pos) // todo change to ref
        {
            Surface surf = Surface.Read(d, ref pos);

            int bits_beg = pos + (int)surf.bits_start - Surface.SIZE;
            int bits_end = pos + (int)surf.bits_end - Surface.SIZE;

            bool done = false;

            do
            {
                THeader th = THeader.Read(d, ref pos);
                for (int i = 0; i < th.th_TriangleCount; i++)
                {
                    Triangle tri = Triangle.Read(d, ref pos);
                }
                done = (th.th_VertArrayOffset == (THeader.SIZE + Triangle.SIZE * th.th_TriangleCount));
            } while (!done);

            while (pos < bits_beg)
            {
                Vertex vert = Vertex.Read(d, ref pos);
            }

            while (pos < bits_end)
            {
                BitHeader bh = BitHeader.Read(d, ref pos);
            }
        }
示例#2
0
        private void LHFDP_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Effect != DragDropEffects.Copy)
            {
                return;
            }

            string ourFile = ((string[])e.Data.GetData(DataFormats.FileDrop))[0];

            try
            {
                THeader      TH = TM.LoadFromFile(ourFile);
                DialogResult DR = MessageBox.Show("Are you sure you want to load the headers from this file?", "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (DR == DialogResult.Yes)
                {
                    TM.UpdateHeadersFromFile(TH);
                }
                else
                {
                    return;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error Loading Headers File", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#3
0
文件: TM.cs 项目: lSergi/TanjiMimic
        public static void UpdateHeadersFromFile(THeader TH)
        {
            var D = Data.Default;

            #region Incoming Headers
            D.PlayerDataLoaded  = TH.PlayerDataLoaded;
            D.PlayerChangeData  = TH.PlayerChangeData;
            D.PlayerGesture     = TH.PlayerGesture;
            D.PlayerDance       = TH.PlayerDance;
            D.PlayerSay         = TH.PlayerSay;
            D.PlayerShout       = TH.PlayerShout;
            D.PlayerWhisper     = TH.PlayerWhisper;
            D.PlayerSign        = TH.PlayerSign;
            D.PlayerSendMessage = TH.PlayerSendMessage;
            #endregion
            #region Outcoming Headers
            D.HostGesture       = TH.HostGesture;
            D.HostDance         = TH.HostDance;
            D.HostSay           = TH.HostSay;
            D.HostShout         = TH.HostShout;
            D.HostWhisper       = TH.HostWhisper;
            D.HostSign          = TH.HostSign;
            D.HostSendMessage   = TH.HostSendMessage;
            D.HostChangeClothes = TH.HostChangeClothes;
            #endregion
            UpdateData();
        }
示例#4
0
        public int HandlePacket(ConnInfo Conn, List <byte> buf)
        {
            THeader h = new THeader();

            if (buf.Count < Marshal.SizeOf(h))
            {
                return(-1);
            }
            h = (THeader)D2DBS.core.BytesToStruct(buf.ToArray(), Marshal.SizeOf(h), h.GetType());
            if (buf.Count != h.size)
            {
                return(-1);
            }
            switch ((EPacketType)h.type)
            {
            case EPacketType.GSGetDataRequest:
                return(HandleGetDataRequest(Conn, buf));

            case EPacketType.GSCloseSignal:
                return(HandleCloseSignal(Conn, buf));

            case EPacketType.GSCharLock:
                return(HandleCharLock(Conn, buf));

            case EPacketType.GSKickReply:
                return(HandleKickReply(Conn, buf));

            case EPacketType.GSSaveCharInfoRequest:
                return(HandleSaveCharInfo(Conn, buf));

            case EPacketType.GSSaveCharSaveRequest:
                return(HandleSaveCharSave(Conn, buf));

            case EPacketType.GSUpdateLadder:
                return(HandleUpdateLadder(Conn, buf));

            case EPacketType.GSPerformanceCounter:
                return(HandlePerformanceCounter(Conn, buf));

            case EPacketType.GSRateExceeded:
                return(HandleRateExceeded(Conn, buf));

            case EPacketType.GSEmergency:
                return(HandleEmergency(Conn, buf));

            case EPacketType.GSSOJCounterUpdate:
                return(HandleSOJCounterUpdate(Conn, buf));

            case EPacketType.GSEchoReply:
                return(0);

            default:
                return(-1);
            }
        }
示例#5
0
            public static THeader Read(byte[] d, ref int pos)
            {
                var o = new THeader();

                o.th_VertArrayOffset = FLMsgType.GetUInt32(d, ref pos);
                o.th_MeshID          = FLMsgType.GetUInt32(d, ref pos);
                o.th_Type            = FLMsgType.GetUInt8(d, ref pos);
                o.th_QtyRefVerts     = FLMsgType.GetUInt24(d, ref pos);
                o.th_TriangleCount   = (short)FLMsgType.GetUInt16(d, ref pos);
                pos += 2; //padding
                return(o);
            }
示例#6
0
        public float GetLastFrameTime()
        {
            var lastPosition = ReplayPointer.GetLastStartingPositionIndex;

            THeader.SetPointerPosition(ReplayReader, lastPosition);
            ReadDeltaFrameCount();
            var time = ReadFrameTime();

            // first Snapshot is always at frametime = 0
            FrameTime = 0;
            return(time);
        }
示例#7
0
        private void LHFFBtn_Click(object sender, EventArgs e)
        {
            DialogResult Dr = LoadHeadersFromFile.ShowDialog();

            if (Dr == DialogResult.OK)
            {
                string fileName = LoadHeadersFromFile.FileName;
                try
                {
                    THeader TH = TM.LoadFromFile(fileName);
                    TM.UpdateHeadersFromFile(TH);
                }
                catch (Exception)
                {
                    MessageBox.Show("Error Loading Headers from this file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        public override float ReadFrame(int currentFrame, int deltaFrames, float deltaTime)
        {
            var time = 0f;

            if (CurrentFrame + 1 == currentFrame)
            {
                CurrentFrame = currentFrame;
                time         = ReadFrameTime();
                ReadObjectsIdsAndNames();
                ReadObservableEntitiesInit(deltaTime);
                ReadObservableEntities(true, deltaTime);
            }
            else
            {
                deltaTime    = 1f / Hz;
                CurrentFrame = currentFrame;
                // Read BaseFrame
                THeader.SetPointerPosition(ReplayReader, currentFrame - deltaFrames);
                BaseFrame.ReadDeltaFrameCount();
                BaseFrame.ReadFrameTime();
                BaseFrame.ReadObjectsIdsAndNames();
                // Only construct once
                BaseFrame.ReadObservableEntitiesInit(deltaTime);
                BaseFrame.ReadObservableEntities(false, deltaTime);
                // Read all deltas until currentFrame
                for (var i = deltaFrames - 1; i >= 0; i--)
                {
                    THeader.SetPointerPosition(ReplayReader, currentFrame - i);
                    ReadDeltaFrameCount();
                    time = ReadFrameTime();
                    ReadObjectsIdsAndNames();
                    ReadObservableEntities(i == 0, deltaTime);
                }
            }


            return(time);
        }
示例#9
0
        public override float ReadFrame(int currentFrame, int deltaFrames, float deltaTime)
        {
            var time = 0f;

            if (CurrentFrame + 1 == currentFrame)
            {
                CurrentFrame = currentFrame;
                time         = ReadFrameTime();
                ReadObjectsIdsAndNames();
                // Only construct once, because delta compression method unpacks n deltaFrameCount frames
                ReadObservableEntitiesInit(deltaTime);
                ReadObservableEntities(true, deltaTime);
            }
            else
            {
                deltaTime    = 1f / Hz;
                CurrentFrame = currentFrame;
                // Read BaseFrame
                THeader.SetPointerPosition(ReplayReader, currentFrame - deltaFrames);
                BaseFrame.ReadDeltaFrameCount();
                BaseFrame.ReadFrameTime();
                BaseFrame.ReadObjectsIdsAndNames();
                // Only construct once, because delta compression method unpacks n deltaFrameCount frames
                BaseFrame.ReadObservableEntitiesInit(deltaTime);
                BaseFrame.ReadObservableEntities(false, deltaTime);

                THeader.SetPointerPosition(ReplayReader, currentFrame);
                ReadDeltaFrameCount();
                time = ReadFrameTime();
                ReadObjectsIdsAndNames();
                ReadObservableEntities(true, deltaTime);
            }


            return(time);
        }
示例#10
0
        static void Main(string[] args)
        {
            agentboj.OnHandShake += delegate(IntPtr connid)
            {
                Console.WriteLine("{0}:HandShake Is ok!Send Up Grade", connid);

                THeader[] Header = new THeader[4];
                Header[0].Name  = "Sec-WebSocket-Version";
                Header[0].Value = "13";

                Header[1].Name  = "User-Agent";
                Header[1].Value = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36";

                Header[2].Name  = "Upgrade";
                Header[2].Value = "websocket";

                Header[3].Name  = "Connection";
                Header[3].Value = "Upgrade";

                agentboj.SendRequest(connid, HttpMethod.Get, "/", Header, null, 0);

                return(0);
            };
            agentboj.OnUpgrade += delegate(IntPtr connid, HttpUpgradeType upgradeType) {
                Console.WriteLine("{0}:Upgrade Is {1},Send WSMessage", connid, upgradeType);

                if (upgradeType == HttpUpgradeType.WebSocket)
                {
                    string body = "halo~";

                    agentboj.SendWSMessage(connid, true, 0, 1, new byte[] { 1, 2, 3, 4 }, Encoding.UTF8.GetBytes(body), 0);
                }

                return(0);
            };

            agentboj.OnWSMessageBody += delegate(IntPtr connid, byte[] data)
            {
                Console.WriteLine("{0}:WSMessageBody! body:{1}", connid, Encoding.UTF8.GetString(data));

                return(0);
            };


            agentboj.Start("0.0.0.0", !true);

            if (agentboj.Connect("118.25.40.163", 8088, ref m_connid))
            {
                Console.WriteLine("{0}:Connect Ok", m_connid);
            }
            else
            {
                Console.WriteLine("{0}:Connect fail! Info:{1}", m_connid, agentboj.ErrorMessage);
            }

            while (true)
            {
                string sendbody = Console.ReadLine();
                if (sendbody == "")
                {
                    break;
                }
                agentboj.SendWSMessage(m_connid, true, 0, 1, new byte[] { 1, 2, 3, 4 }, Encoding.UTF8.GetBytes(sendbody), 0);
            }
            agentboj.Disconnect(m_connid);
            agentboj.Stop();
            agentboj.Destroy();
        }