diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index 850ad4b7..a358cf64 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -1434,12 +1434,9 @@ ServerLobbyThread::HandleNetPacketJoinGame(boost::shared_ptr sessio && session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4 && game->IsClientAddressConnected(session->GetClientAddr())) { SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED); - }else if (!session->IsPlayerAllowedToJoinLimitRank(session->GetPlayerData()->GetUniqueId())) { + }else if (!session->IsPlayerAllowedToJoinLimitRank()) { SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED); } - } - - } else { MoveSessionToGame(game, session, joinGame.autoleave(), false); } diff --git a/src/net/common/sessiondata.cpp b/src/net/common/sessiondata.cpp index 7e72275a..1548dd64 100644 --- a/src/net/common/sessiondata.cpp +++ b/src/net/common/sessiondata.cpp @@ -402,19 +402,39 @@ SessionData::GetPlayerData() } void -SessionData::SetPlayerLastGames(std:array lastGames) +SessionData::SetPlayerLastGames(std:array lastGames) { boost::mutex::scoped_lock lock(m_dataMutex); - m_lastGames = player; + m_lastGames = lastGames; } -std::array +void +SessionData::AddPlayerLastGame(long lastGame) +{ + boost::mutex::scoped_lock lock(m_dataMutex); + + m_lastGames.push_back(lastGame); + + // @TODO: remove overdued entries +} + +std::array SessionData::GetPlayerLastGames() { boost::mutex::scoped_lock lock(m_dataMutex); return m_lastGames; } +bool +SessionData::IsPlayerAllowedToJoinLimitRank() +{ + bool retVal = false; + + // @TODO: iterate m_lastGames + + return retVal; +} + string SessionData::GetRemoteIPAddressFromSocket() const { diff --git a/src/net/common/sessionmanager.cpp b/src/net/common/sessionmanager.cpp index 276cd48d..ab132268 100644 --- a/src/net/common/sessionmanager.cpp +++ b/src/net/common/sessionmanager.cpp @@ -234,41 +234,6 @@ SessionManager::IsPlayerConnected(unsigned uniqueId) const return retVal; } -bool -SessionManager::IsPlayerAllowedToJoinLimitRank(const string &playerName) const -{ - bool retVal = false; - - // boost::shared_ptr tmpSession = GetSessionByPlayerName(playerName); - - // if (tmpSession){ - // std::array lastGames = tmpSession->GetPlayerLastGames(); - // std::time_t now = std::time(nullptr); - - - // retVal = true; - // } - - return retVal; -} - -bool -SessionManager::IsPlayerAllowedToJoinLimitRank(unsigned uniqueId) const -{ - bool retVal = false; - - // boost::shared_ptr tmpSession = GetSessionByUniquePlayerId(uniqueId); - - // if (tmpSession){ - // std::array lastGames = tmpSession->GetPlayerLastGames(); - // std::time_t now = std::time(nullptr); - - // retVal = true; - // } - - return retVal; -} - bool SessionManager::IsClientAddressConnected(const std::string &clientAddress) const { diff --git a/src/net/sessiondata.h b/src/net/sessiondata.h index 73ea97c2..73b37c56 100644 --- a/src/net/sessiondata.h +++ b/src/net/sessiondata.h @@ -127,8 +127,10 @@ public: void SetPlayerData(boost::shared_ptr player); boost::shared_ptr GetPlayerData(); - void SetPlayerLastGames(std::array lastGames); - std::array GetPlayerLastGames(); + void AddPlayerLastGame(unsigned long lastGames); + void SetPlayerLastGames(std::array lastGames); + std::array GetPlayerLastGames(); + bool IsPlayerAllowedToJoinLimitRank(); std::string GetRemoteIPAddressFromSocket() const; @@ -163,7 +165,7 @@ private: std::string m_password; boost::shared_ptr m_playerData; - std::array m_lastGames; + std::array m_lastGames; mutable boost::mutex m_dataMutex; };