Make the chat bot temporarily ban players.

This commit is contained in:
lotodore
2010-07-14 17:20:51 +00:00
parent 9248f5a15e
commit 6c997ca21a
4 changed files with 79 additions and 29 deletions
+22 -3
View File
@@ -106,7 +106,12 @@ public:
virtual void SignalBanPlayer(unsigned playerId)
{
// TODO
string playerName(m_server.GetPlayerNameFromId(playerId));
if (!playerName.empty())
{
m_server.GetBanManager().BanPlayerRegex(playerName, 1);
m_server.RemovePlayer(playerId, ERR_NET_PLAYER_KICKED);
}
}
virtual void ConnectSuccess()
@@ -492,15 +497,29 @@ ServerLobbyThread::GetPlayerIPAddress(const std::string &playerName) const
{
string ipAddress;
SessionWrapper session = m_sessionManager.GetSessionByPlayerName(playerName);
if (!session.sessionData.get())
if (!session.sessionData)
session = m_gameSessionManager.GetSessionByPlayerName(playerName);
if (session.sessionData.get() && session.playerData.get())
if (session.sessionData && session.playerData)
ipAddress = session.sessionData->GetClientAddr();
return ipAddress;
}
std::string
ServerLobbyThread::GetPlayerNameFromId(unsigned playerId) const
{
string name;
SessionWrapper session = m_sessionManager.GetSessionByUniquePlayerId(playerId);
if (!session.sessionData)
session = m_gameSessionManager.GetSessionByUniquePlayerId(playerId);
if (session.sessionData && session.playerData)
name = session.playerData->GetName();
return name;
}
void
ServerLobbyThread::RemovePlayer(unsigned playerId, unsigned errorCode)
{