示例#1
0
        public static void Initialize()
        {
            cl_maxpackets = ConVar.Register("cl_maxpackets", 33, "", ConVarFlags.Archived);

            // FIXME: interpolation only works at server frame time
            cl_snapDelay = ConVar.Register("cl_snapDelay", 50, "Amount of time to delay the rendering by", ConVarFlags.Archived);

            _serverChannel = new NetChannel(NetChannelType.ClientToServer, NetAddress.Loopback);

            //_entities = new Entity[4096];
            InitializeConnection();

            State = ClientState.Idle;
        }
示例#2
0
        private static void ProcessOutOfBand(NetAddress from, byte[] packet)
        {
            var message = Encoding.UTF8.GetString(packet, 4, packet.Length - 4);
            var args    = Command.Tokenize(message);

            if (args.Length == 0)
            {
                return;
            }

            switch (args[0])
            {
            case "challengeResponse":
                if (State != ClientState.Challenging)
                {
                    return;
                }

                _lastConnectPacketTime = -999999;
                _lastMessageReceivedAt = _clientTime;

                _challenge = int.Parse(args[1]);
                State      = ClientState.Connecting;
                break;

            case "connectResponse":
                if (State != ClientState.Connecting)
                {
                    return;
                }

                _clientNum = int.Parse(args[1]);

                if (!ConVar.GetValue <bool>("sv_running"))
                {
                    Server.CreatePhysicsWorld();
                    MapManager.Load(string.Format("Maps/{0}.gmp", args[2]));
                }

                _lastConnectPacketTime = -999999;
                _lastMessageReceivedAt = _clientTime;

                _serverChannel = new NetChannel(NetChannelType.ClientToServer, from);
                InitializeConnection();

                State = ClientState.Connected;
                break;
            }
        }