/* Makes various checks to see if client is allowed to connect. * Returns null on success, otherwise return value contains * discription of error. */ private string OkToConnect(HelloPacket pkt) { string retMsg = null; ConnectedBuild = pkt.BuildVersion; // check client version if (!ConnectedBuild.StartsWith(clientVer)) { ConnectionFailed(retMsg = "Wrong build version."); } // has valid account? else if ((account = db.Verify(pkt.GUID, pkt.Password)) == null) { ConnectionFailed(retMsg = "Invalid account."); } // ip banned? else if (ip.Banned) { ConnectionFailed(retMsg = "IP banned."); } // account banned? else if (account.Banned) { ConnectionFailed(retMsg = "Account banned."); } // server full? else if (RealmManager.Clients.Count >= RealmManager.MAX_CLIENT) { ConnectionFailed(retMsg = "Server full."); } // valid gameId? else if (RealmManager.GetWorld(pkt.GameId) == null) { // invalid world... send to nexus instead pkt.GameId = World.NEXUS_ID; } // account already connected? disconnect if so else if (AccountConnected(account.AccountId)) { ConnectionFailed(retMsg = "Account in use... "); ClientProcessor target = RealmManager.Clients[account.AccountId]; target.Disconnect(); } return(retMsg); }
private bool ConnectedBuildStartsWith(string clientVer) { return(ConnectedBuild.StartsWith(clientVer)); }