re-structuring
This commit is contained in:
@@ -1434,12 +1434,9 @@ ServerLobbyThread::HandleNetPacketJoinGame(boost::shared_ptr<SessionData> sessio
|
|||||||
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4
|
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4
|
||||||
&& game->IsClientAddressConnected(session->GetClientAddr())) {
|
&& game->IsClientAddressConnected(session->GetClientAddr())) {
|
||||||
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED);
|
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);
|
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MoveSessionToGame(game, session, joinGame.autoleave(), false);
|
MoveSessionToGame(game, session, joinGame.autoleave(), false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -402,19 +402,39 @@ SessionData::GetPlayerData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SessionData::SetPlayerLastGames(std:array<long, 25> lastGames)
|
SessionData::SetPlayerLastGames(std:array<unsigned long, 25> lastGames)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_dataMutex);
|
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||||
m_lastGames = player;
|
m_lastGames = lastGames;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<long, 25>
|
void
|
||||||
|
SessionData::AddPlayerLastGame(long lastGame)
|
||||||
|
{
|
||||||
|
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||||
|
|
||||||
|
m_lastGames.push_back(lastGame);
|
||||||
|
|
||||||
|
// @TODO: remove overdued entries
|
||||||
|
}
|
||||||
|
|
||||||
|
std::array<unsigned long, 25>
|
||||||
SessionData::GetPlayerLastGames()
|
SessionData::GetPlayerLastGames()
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_dataMutex);
|
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||||
return m_lastGames;
|
return m_lastGames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
SessionData::IsPlayerAllowedToJoinLimitRank()
|
||||||
|
{
|
||||||
|
bool retVal = false;
|
||||||
|
|
||||||
|
// @TODO: iterate m_lastGames
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
SessionData::GetRemoteIPAddressFromSocket() const
|
SessionData::GetRemoteIPAddressFromSocket() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -234,41 +234,6 @@ SessionManager::IsPlayerConnected(unsigned uniqueId) const
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
SessionManager::IsPlayerAllowedToJoinLimitRank(const string &playerName) const
|
|
||||||
{
|
|
||||||
bool retVal = false;
|
|
||||||
|
|
||||||
// boost::shared_ptr<SessionData> tmpSession = GetSessionByPlayerName(playerName);
|
|
||||||
|
|
||||||
// if (tmpSession){
|
|
||||||
// std::array<std::time_t> 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<SessionData> tmpSession = GetSessionByUniquePlayerId(uniqueId);
|
|
||||||
|
|
||||||
// if (tmpSession){
|
|
||||||
// std::array<std::time_t> lastGames = tmpSession->GetPlayerLastGames();
|
|
||||||
// std::time_t now = std::time(nullptr);
|
|
||||||
|
|
||||||
// retVal = true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SessionManager::IsClientAddressConnected(const std::string &clientAddress) const
|
SessionManager::IsClientAddressConnected(const std::string &clientAddress) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -127,8 +127,10 @@ public:
|
|||||||
void SetPlayerData(boost::shared_ptr<PlayerData> player);
|
void SetPlayerData(boost::shared_ptr<PlayerData> player);
|
||||||
boost::shared_ptr<PlayerData> GetPlayerData();
|
boost::shared_ptr<PlayerData> GetPlayerData();
|
||||||
|
|
||||||
void SetPlayerLastGames(std::array<long, 25> lastGames);
|
void AddPlayerLastGame(unsigned long lastGames);
|
||||||
std::array<long, 25> GetPlayerLastGames();
|
void SetPlayerLastGames(std::array<unsigned long, 25> lastGames);
|
||||||
|
std::array<unsigned long, 25> GetPlayerLastGames();
|
||||||
|
bool IsPlayerAllowedToJoinLimitRank();
|
||||||
|
|
||||||
std::string GetRemoteIPAddressFromSocket() const;
|
std::string GetRemoteIPAddressFromSocket() const;
|
||||||
|
|
||||||
@@ -163,7 +165,7 @@ private:
|
|||||||
std::string m_password;
|
std::string m_password;
|
||||||
boost::shared_ptr<PlayerData> m_playerData;
|
boost::shared_ptr<PlayerData> m_playerData;
|
||||||
|
|
||||||
std::array<long, 25> m_lastGames;
|
std::array<unsigned long, 25> m_lastGames;
|
||||||
|
|
||||||
mutable boost::mutex m_dataMutex;
|
mutable boost::mutex m_dataMutex;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user