示例#1
0
        private void ParseGamestate(Q3HuffmanStream stream)
        {
            this.gameState.Clear();
            this.incomingCommandSequence = stream.ReadInt32();
            EntityState nullstate = new EntityState();

            ServerCommandType cmd;

            entityBaselinesEvent.WaitOne();

            while (ServerCommandType.EOF != (cmd = ( ServerCommandType )stream.ReadByte()))
            {
                switch (cmd)
                {
                case ServerCommandType.ConfigString:
                    int i = stream.ReadInt16();
                    gameState [i] = stream.ReadString();
                    break;

                case ServerCommandType.BaseLine:
                    int newnum = stream.ReadBits(10);

                    ReadDeltaEntity(stream, nullstate, ref entityBaselines [newnum], newnum);
                    break;

                default:
                    // Unknown command
                    break;
                }
            }

            entityBaselinesEvent.Set();

            this.clientNum    = stream.ReadInt32();
            this.checksumFeed = stream.ReadInt32();

            SystemInfoChanged();
            this.connState = ConnectionState.Primed;

            //SendPureChecksums ();
        }
示例#2
0
        private void ParseCommandString(Q3HuffmanStream stream)
        {
            this.incomingCommandSequence = stream.ReadInt32();
            string cmdStr = stream.ReadString();
            int    index  = this.incomingCommandSequence & (MAX_RELIABLE_COMMANDS - 1);

            this.incomingReliableCommands [index] = cmdStr;

            if (cmdStr.StartsWith("cs "))
            {
                string [] parts = cmdStr.Split(' ');

                int csId;

                if (parts.Length >= 2)
                {
                    try {
                        csId = Convert.ToInt32(parts [1]);
                    } catch {
                        csId = 0;
                    }

                    this.gameState [csId] = string.Join(" ", parts, 2, parts.Length - 2);

                    if (csId == 1)
                    {
                        SystemInfoChanged();
                    }
                }
            }

            if (this.ServerCommandReceived != null)
            {
                this.ServerCommandReceived(this, cmdStr);
            }
        }