Block bad game names on server.
This commit is contained in:
@@ -51,7 +51,7 @@ ServerBanManager::BanPlayerRegex(const string &playerRegex, unsigned durationHou
|
||||
|
||||
TimedPlayerBan tmpBan;
|
||||
tmpBan.timer = InternalRegisterTimedBan(banId, durationHours);
|
||||
tmpBan.nameRegex = boost::regex(playerRegex, boost::regex_constants::no_except);
|
||||
tmpBan.nameRegex = boost::regex(playerRegex, boost::regex::extended | boost::regex::icase);
|
||||
m_banPlayerNameMap[banId] = tmpBan;
|
||||
}
|
||||
|
||||
@@ -186,6 +186,36 @@ ServerBanManager::IsIPAddressBanned(const std::string &ipAddress) const
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void
|
||||
ServerBanManager::InitGameNameBadWordList(const std::list<string> &badWordList)
|
||||
{
|
||||
list<string>::const_iterator i = badWordList.begin();
|
||||
list<string>::const_iterator end = badWordList.end();
|
||||
while (i != end)
|
||||
{
|
||||
m_gameNameBadWordFilter.push_back(boost::regex(*i, boost::regex::extended | boost::regex::icase));
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ServerBanManager::IsBadGameName(const std::string &name) const
|
||||
{
|
||||
bool retVal = false;
|
||||
RegexList::const_iterator i = m_gameNameBadWordFilter.begin();
|
||||
RegexList::const_iterator end = m_gameNameBadWordFilter.end();
|
||||
while (i != end)
|
||||
{
|
||||
if (regex_match(name, *i))
|
||||
{
|
||||
retVal = true;
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
boost::shared_ptr<boost::asio::deadline_timer>
|
||||
ServerBanManager::InternalRegisterTimedBan(unsigned timerId, unsigned durationHours)
|
||||
{
|
||||
|
||||
@@ -145,23 +145,23 @@ static void PerformPlayerAction(ServerGame &server, boost::shared_ptr<PlayerInte
|
||||
|
||||
player->setMySet(bet);
|
||||
|
||||
// update minimumRaise and lastActionPlayer
|
||||
// update minimumRaise and lastActionPlayer
|
||||
switch(action) {
|
||||
case PLAYER_ACTION_BET: {
|
||||
curGame.getCurrentHand()->getCurrentBeRo()->setMinimumRaise(bet);
|
||||
curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID());
|
||||
curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID());
|
||||
} break;
|
||||
case PLAYER_ACTION_RAISE: {
|
||||
curGame.getCurrentHand()->getCurrentBeRo()->setMinimumRaise(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet());
|
||||
curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID());
|
||||
curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID());
|
||||
} break;
|
||||
case PLAYER_ACTION_ALLIN: {
|
||||
if(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet() > curGame.getCurrentHand()->getCurrentBeRo()->getMinimumRaise()) {
|
||||
curGame.getCurrentHand()->getCurrentBeRo()->setMinimumRaise(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet());
|
||||
}
|
||||
if(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet() > 0) {
|
||||
curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID());
|
||||
}
|
||||
if(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet() > 0) {
|
||||
curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID());
|
||||
}
|
||||
} break;
|
||||
default: {
|
||||
}
|
||||
|
||||
@@ -202,6 +202,8 @@ ServerLobbyThread::Init(const string &logDir)
|
||||
m_serverConfig->readConfigString("DBServerPassword"),
|
||||
m_serverConfig->readConfigString("DBServerDatabaseName"),
|
||||
m_serverConfig->readConfigString("DBServerEncryptionKey"));
|
||||
|
||||
GetBanManager().InitGameNameBadWordList(m_serverConfig->readConfigStringList("GameNameBadWordList"));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1335,6 +1337,10 @@ ServerLobbyThread::HandleNetPacketCreateGame(SessionWrapper session, const std::
|
||||
{
|
||||
SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_GAME_NAME_IN_USE);
|
||||
}
|
||||
else if (GetBanManager().IsBadGameName(gameName))
|
||||
{
|
||||
SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_GAME_BAD_NAME);
|
||||
}
|
||||
else if (session.playerData->GetRights() == PLAYER_RIGHTS_GUEST
|
||||
&& tmpData.gameType != GAME_TYPE_NORMAL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user