diff --git a/src/config/configfile.cpp b/src/config/configfile.cpp index dc5d2510..7c210fdd 100644 --- a/src/config/configfile.cpp +++ b/src/config/configfile.cpp @@ -312,6 +312,8 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly) configList.push_back(ConfigInfo("DBServerEncryptionKey", CONFIG_TYPE_STRING, "")); configList.push_back(ConfigInfo("GameNameBadWordList", CONFIG_TYPE_STRING_LIST, "Regex")); configList.push_back(ConfigInfo("ServerRestrictGuestLogin", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("ServerLimitRankNum", CONFIG_TYPE_INT, "4")); + configList.push_back(ConfigInfo("ServerLimitRankPeriod", CONFIG_TYPE_INT, "60")); //fill tempList firstTime configBufferList = configList; diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index a97a5fe6..4a0c3b47 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -1379,7 +1379,7 @@ ServerLobbyThread::HandleNetPacketCreateGame(boost::shared_ptr sess SendJoinGameFailed(session, gameId, NTF_NET_JOIN_GUEST_FORBIDDEN); } else if (!ServerGame::CheckSettings(tmpData, password, GetServerMode())) { SendJoinGameFailed(session, gameId, NTF_NET_JOIN_INVALID_SETTINGS); - } else if (!session->GetPlayerData()->IsPlayerAllowedToJoinCreateLimitRank() + } else if (!session->GetPlayerData()->IsPlayerAllowedToJoinCreateLimitRank(m_serverConfig.readConfigString("ServerLimitRankNum"), ), m_serverConfig.readConfigString("ServerLimitRankPeriod"))) // @TODO: uncomment in productive /*&& tmpData.gameType != GAME_TYPE_RANKING*/ ) { LOG_ERROR("not allowed due to ranklimit"); diff --git a/src/playerdata.cpp b/src/playerdata.cpp index 83349b0a..22818d45 100644 --- a/src/playerdata.cpp +++ b/src/playerdata.cpp @@ -271,7 +271,7 @@ PlayerData::GetPlayerLastGames() } bool -PlayerData::IsPlayerAllowedToJoinCreateLimitRank() +PlayerData::IsPlayerAllowedToJoinCreateLimitRank(int num, int period) { bool retVal = false; LOG_ERROR("checking IsPlayerAllowedToJoinCreateLimitRank() "); @@ -280,7 +280,7 @@ LOG_ERROR("checking IsPlayerAllowedToJoinCreateLimitRank() "); boost::mutex::scoped_lock lock(m_dataMutex); - long then = (long)time(NULL) - (long)(SERVER_ALLOWED_RANKING_GAMES_MINUTES * 10); + long then = (long)time(NULL) - (long)(period * 10); int count = 0; int i=0; @@ -298,7 +298,7 @@ LOG_ERROR("checking IsPlayerAllowedToJoinCreateLimitRank() "); i++; } - if(count < SERVER_ALLOWED_RANKING_GAMES_PER_MINUTES) + if(count < num) retVal = true; return retVal;