private void ConnectClient(EndPoint addr, int protocol, int authProtocol, int challenge, string name, string password) { if (name == null || password == null) { return; } if (!CheckChallengeNr(addr, challenge)) { RejectConnecton(addr, "Bad challenge.\n"); return; } if (!CheckIPConnectionReuse(addr)) { RejectConnecton(addr, "Too many pending connections.\n"); return; } if (!CheckIPRestrictions(addr)) { RejectConnecton(addr, "LAN servers are resticted to local clients only (class C).\n"); return; } if (!CheckPassword(addr, password)) { Console.WriteLine("Client \"{0}\" [{1}]: password failed.\n", name, addr); RejectConnecton(addr, "Bad password.\n"); return; } if (Clients.Count + 1 > Program.SvMaxPlayers) { RejectConnecton(addr, "Server is full.\n"); return; } var client = new GameClient(GetFreeSlot(), this); var channel = Networking.CreateChannel(Socket, name, addr, client); if (channel == null) { RejectConnecton(addr, "Failed to create net channel!\n"); return; } // set channel challenge channel.SetChallengeNr(challenge); // make sure client is reset and clear client.Connect(name, channel); client.SnapshotInterval = 1.0f / 20.0f; client.NextMessageTime = Networking.NetTime + client.SnapshotInterval; // add client to global list Clients.Add(client); // tell client connection worked, now use netchannels Networking.OutOfBandPrintf(Socket, addr, "{0}00000000000000", (char)EConnectionType.ConnectionAccept); Out.MsgC(ConsoleColor.Yellow, "Client \"{0}\" has connected from [{1}]", client.GetClientName(), channel.GetRemoteAddress()); }