diff --git a/src/net/common/serveradminbot.cpp b/src/net/common/serveradminbot.cpp index 1d4809da..dbe539c6 100644 --- a/src/net/common/serveradminbot.cpp +++ b/src/net/common/serveradminbot.cpp @@ -84,6 +84,16 @@ ServerAdminBot::SignalIrcChatMsg(const std::string &nickName, const std::string else m_ircAdminThread->SendChatMessage(nickName + ": Player \"" + playerName + "\" was not found on the server."); } + } else if (command == "removegame") { + while (msgStream.peek() == ' ') + msgStream.get(); + string playerName(msgStream.str().substr(msgStream.tellg())); + if (!playerName.empty()) { + if (GetLobbyThread().RemoveGameByPlayerName(playerName)) + m_ircAdminThread->SendChatMessage(nickName + ": Successfully removed game of player \"" + playerName + "\"."); + else + m_ircAdminThread->SendChatMessage(nickName + ": Player \"" + playerName + "\" is currently not playing a game."); + } } else if (command == "cleaner-reconnect") { GetLobbyThread().ReconnectChatBot(); m_ircAdminThread->SendChatMessage(nickName + ": Cleaner bot reconnect initiated."); diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index 15d81000..1463291a 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -509,6 +509,23 @@ ServerLobbyThread::KickPlayerByName(const std::string &playerName) return retVal; } +bool +ServerLobbyThread::RemoveGameByPlayerName(const std::string &playerName) +{ + bool retVal = false; + boost::shared_ptr session = m_gameSessionManager.GetSessionByPlayerName(playerName); + + if (session) { + boost::shared_ptr game = session->GetGame(); + if (game) { + m_ioService->post(boost::bind(&ServerLobbyThread::InternalRemoveGame, shared_from_this(), game)); + retVal = true; + } + } + + return retVal; +} + string ServerLobbyThread::GetPlayerIPAddress(const std::string &playerName) const { diff --git a/src/net/serverlobbythread.h b/src/net/serverlobbythread.h index cecfec5f..66427cef 100644 --- a/src/net/serverlobbythread.h +++ b/src/net/serverlobbythread.h @@ -76,6 +76,7 @@ public: void HandleChatRequest(boost::shared_ptr session, const ChatRequestMessage_t &chatRequest); bool KickPlayerByName(const std::string &playerName); + bool RemoveGameByPlayerName(const std::string &playerName); std::string GetPlayerIPAddress(const std::string &playerName) const; std::string GetPlayerNameFromId(unsigned playerId) const; void RemovePlayer(unsigned playerId, unsigned errorCode);