From 95fac5a4f523223a0558459a6ccb23aa38da0a0b Mon Sep 17 00:00:00 2001 From: Kai Philipp Date: Thu, 3 Oct 2019 13:49:59 +0200 Subject: [PATCH] switched to rank only games --- src/net/common/servergame.cpp | 6 ++---- src/net/common/serverlobbythread.cpp | 19 +++++++++---------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/net/common/servergame.cpp b/src/net/common/servergame.cpp index 3f696141..a1483d92 100644 --- a/src/net/common/servergame.cpp +++ b/src/net/common/servergame.cpp @@ -300,8 +300,7 @@ ServerGame::InternalStartGame() if (playerData.size() >= 2) { // Set DB Backend. // @TODO: check for wec or bbc game with bbcbot as creator - //if (GetGameData().gameType == GAME_TYPE_RANKING) - if (true) + if (GetGameData().gameType == GAME_TYPE_RANKING) m_database = GetLobbyThread().GetDatabase(); else m_database.reset(new ServerDBNoAction); @@ -352,8 +351,7 @@ ServerGame::InternalStartGame() // @TODO: here to save last_games with mysql per player - //if (GetGameData().gameType == GAME_TYPE_RANKING) - if(true) + if (GetGameData().gameType == GAME_TYPE_RANKING) StoreLastGames(playerData); } diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index 289a2f83..1ab3de92 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -1380,8 +1380,7 @@ ServerLobbyThread::HandleNetPacketCreateGame(boost::shared_ptr sess } else if (!ServerGame::CheckSettings(tmpData, password, GetServerMode())) { SendJoinGameFailed(session, gameId, NTF_NET_JOIN_INVALID_SETTINGS); } else if (!session->GetPlayerData()->IsPlayerAllowedToJoinCreateLimitRank(m_serverConfig.readConfigString("ServerLimitRankNum"), m_serverConfig.readConfigString("ServerLimitRankPeriod")) - // @TODO: uncomment in productive - /*&& tmpData.gameType != GAME_TYPE_RANKING*/ ) { + && tmpData.gameType != GAME_TYPE_RANKING*/ ) { LOG_ERROR("not allowed due to ranklimit"); SendJoinGameFailed(session, gameId, NTF_NET_JOIN_IP_BLOCKED); } else { @@ -1435,15 +1434,15 @@ ServerLobbyThread::HandleNetPacketJoinGame(boost::shared_ptr sessio SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_NOT_INVITED); } else if (!game->CheckPassword(password)) { SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_INVALID_PASSWORD); - } else if (/*tmpData.gameType == GAME_TYPE_RANKING &&*/ !session->GetPlayerData()->IsPlayerAllowedToJoinCreateLimitRank(m_serverConfig.readConfigString("ServerLimitRankNum"), m_serverConfig.readConfigString("ServerLimitRankPeriod"))) { + } else if (tmpData.gameType == GAME_TYPE_RANKING && !session->GetPlayerData()->IsPlayerAllowedToJoinCreateLimitRank(m_serverConfig.readConfigString("ServerLimitRankNum"), m_serverConfig.readConfigString("ServerLimitRankPeriod"))) { SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED); - // } else if (tmpData.gameType == GAME_TYPE_RANKING && !joinGame.spectateonly() - // && session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR - // && session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4V6 - // && session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4 - // && game->IsClientAddressConnected(session->GetClientAddr())) { - // ){ - // SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED); + } else if (tmpData.gameType == GAME_TYPE_RANKING && !joinGame.spectateonly() + && session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR + && session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4V6 + && session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4 + && game->IsClientAddressConnected(session->GetClientAddr())) { + ){ + SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED); } else { MoveSessionToGame(game, session, joinGame.autoleave(), false); }