Implement chat bot mute on server side (#1).
This commit is contained in:
@@ -81,8 +81,7 @@ QStringList MessageFilter::check(unsigned gameId, unsigned playerId, QString nic
|
|||||||
if(gameId) {
|
if(gameId) {
|
||||||
//check for ingame to do not kick but mute
|
//check for ingame to do not kick but mute
|
||||||
action = MUTE;
|
action = MUTE;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Kick Command
|
// Kick Command
|
||||||
action = KICK;
|
action = KICK;
|
||||||
//remove playerId from all lists and as LAST from myClientWarnLevelList
|
//remove playerId from all lists and as LAST from myClientWarnLevelList
|
||||||
|
|||||||
@@ -849,7 +849,7 @@ LocalPlayer::LocalPlayer(ConfigFile *c, int id, unsigned uniqueId, PlayerType ty
|
|||||||
: PlayerInterface(), myConfig(c), currentHand(0), myID(id), myUniqueID(uniqueId), myType(type), myName(name), myAvatar(avatar),
|
: PlayerInterface(), myConfig(c), currentHand(0), myID(id), myUniqueID(uniqueId), myType(type), myName(name), myAvatar(avatar),
|
||||||
myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), logHoleCardsDone(false), myCash(sC), mySet(0), myLastRelativeSet(0), myAction(PLAYER_ACTION_NONE),
|
myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), logHoleCardsDone(false), myCash(sC), mySet(0), myLastRelativeSet(0), myAction(PLAYER_ACTION_NONE),
|
||||||
myButton(mB), myActiveStatus(aS), myStayOnTableStatus(sotS), myTurn(0), myCardsFlip(0), myRoundStartCash(0), lastMoneyWon(0),
|
myButton(mB), myActiveStatus(aS), myStayOnTableStatus(sotS), myTurn(0), myCardsFlip(0), myRoundStartCash(0), lastMoneyWon(0),
|
||||||
sBluff(0), sBluffStatus(false), m_actionTimeoutCounter(0), m_isSessionActive(false), m_isKicked(false)
|
sBluff(0), sBluffStatus(false), m_actionTimeoutCounter(0), m_isSessionActive(false), m_isKicked(false), m_isMuted(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
// !!!!!!!!!!!!!!!!!!!!!!!! testing !!!!!!!!!!!!!!!!!!!!!!!!
|
// !!!!!!!!!!!!!!!!!!!!!!!! testing !!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
@@ -5114,6 +5114,16 @@ bool LocalPlayer::isKicked() const
|
|||||||
return m_isKicked;
|
return m_isKicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocalPlayer::setIsMuted(bool muted)
|
||||||
|
{
|
||||||
|
m_isMuted = muted;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LocalPlayer::isMuted() const
|
||||||
|
{
|
||||||
|
return m_isMuted;
|
||||||
|
}
|
||||||
|
|
||||||
bool LocalPlayer::checkIfINeedToShowCards()
|
bool LocalPlayer::checkIfINeedToShowCards()
|
||||||
{
|
{
|
||||||
std::list<unsigned> playerNeedToShowCardsList = currentHand->getBoard()->getPlayerNeedToShowCards();
|
std::list<unsigned> playerNeedToShowCardsList = currentHand->getBoard()->getPlayerNeedToShowCards();
|
||||||
|
|||||||
@@ -284,6 +284,8 @@ public:
|
|||||||
bool isSessionActive() const;
|
bool isSessionActive() const;
|
||||||
void setIsKicked(bool kicked);
|
void setIsKicked(bool kicked);
|
||||||
bool isKicked() const;
|
bool isKicked() const;
|
||||||
|
void setIsMuted(bool muted);
|
||||||
|
bool isMuted() const;
|
||||||
|
|
||||||
bool checkIfINeedToShowCards();
|
bool checkIfINeedToShowCards();
|
||||||
|
|
||||||
@@ -335,6 +337,7 @@ private:
|
|||||||
unsigned m_actionTimeoutCounter;
|
unsigned m_actionTimeoutCounter;
|
||||||
bool m_isSessionActive;
|
bool m_isSessionActive;
|
||||||
bool m_isKicked;
|
bool m_isKicked;
|
||||||
|
bool m_isMuted;
|
||||||
boost::timers::portable::microsec_timer m_lastRemoteActionTimer;
|
boost::timers::portable::microsec_timer m_lastRemoteActionTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ ClientPlayer::ClientPlayer(ConfigFile *c, int id, unsigned uniqueId, PlayerType
|
|||||||
: PlayerInterface(), myConfig(c), currentHand(0), myID(id), myUniqueID(uniqueId), myType(type),
|
: PlayerInterface(), myConfig(c), currentHand(0), myID(id), myUniqueID(uniqueId), myType(type),
|
||||||
myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), logHoleCardsDone(false), myCash(sC), mySet(0), myLastRelativeSet(0),
|
myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), logHoleCardsDone(false), myCash(sC), mySet(0), myLastRelativeSet(0),
|
||||||
myAction(PLAYER_ACTION_NONE), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(sotS), myTurn(false), myCardsFlip(false), myRoundStartCash(0),
|
myAction(PLAYER_ACTION_NONE), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(sotS), myTurn(false), myCardsFlip(false), myRoundStartCash(0),
|
||||||
lastMoneyWon(0), sBluff(0), sBluffStatus(false), m_isSessionActive(false), m_isKicked(false)
|
lastMoneyWon(0), sBluff(0), sBluffStatus(false), m_isSessionActive(false), m_isKicked(false), m_isMuted(false)
|
||||||
{
|
{
|
||||||
myBestHandPosition[0] = myBestHandPosition[1] = myBestHandPosition[2] = myBestHandPosition[3] = myBestHandPosition[4] = 0;
|
myBestHandPosition[0] = myBestHandPosition[1] = myBestHandPosition[2] = myBestHandPosition[3] = myBestHandPosition[4] = 0;
|
||||||
myNiveau[0] = myNiveau[1] = myNiveau[2] = 0;
|
myNiveau[0] = myNiveau[1] = myNiveau[2] = 0;
|
||||||
@@ -563,6 +563,20 @@ ClientPlayer::isKicked() const
|
|||||||
return m_isKicked;
|
return m_isKicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ClientPlayer::setIsMuted(bool muted)
|
||||||
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
|
m_isMuted = muted;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ClientPlayer::isMuted() const
|
||||||
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
|
return m_isMuted;
|
||||||
|
}
|
||||||
|
|
||||||
bool ClientPlayer::checkIfINeedToShowCards()
|
bool ClientPlayer::checkIfINeedToShowCards()
|
||||||
{
|
{
|
||||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
|
|||||||
@@ -137,6 +137,8 @@ public:
|
|||||||
bool isSessionActive() const;
|
bool isSessionActive() const;
|
||||||
void setIsKicked(bool kicked);
|
void setIsKicked(bool kicked);
|
||||||
bool isKicked() const;
|
bool isKicked() const;
|
||||||
|
void setIsMuted(bool muted);
|
||||||
|
bool isMuted() const;
|
||||||
|
|
||||||
bool checkIfINeedToShowCards();
|
bool checkIfINeedToShowCards();
|
||||||
|
|
||||||
@@ -190,6 +192,7 @@ private:
|
|||||||
|
|
||||||
bool m_isSessionActive;
|
bool m_isSessionActive;
|
||||||
bool m_isKicked;
|
bool m_isKicked;
|
||||||
|
bool m_isMuted;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -122,6 +122,8 @@ public:
|
|||||||
virtual bool isSessionActive() const=0;
|
virtual bool isSessionActive() const=0;
|
||||||
virtual void setIsKicked(bool kicked) =0;
|
virtual void setIsKicked(bool kicked) =0;
|
||||||
virtual bool isKicked() const=0;
|
virtual bool isKicked() const=0;
|
||||||
|
virtual void setIsMuted(bool muted) =0;
|
||||||
|
virtual bool isMuted() const=0;
|
||||||
|
|
||||||
virtual bool checkIfINeedToShowCards() =0;
|
virtual bool checkIfINeedToShowCards() =0;
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public:
|
|||||||
virtual void SignalChatBotMessage(unsigned gameId, const std::string &msg) = 0;
|
virtual void SignalChatBotMessage(unsigned gameId, const std::string &msg) = 0;
|
||||||
virtual void SignalKickPlayer(unsigned playerId) = 0;
|
virtual void SignalKickPlayer(unsigned playerId) = 0;
|
||||||
virtual void SignalBanPlayer(unsigned playerId) = 0;
|
virtual void SignalBanPlayer(unsigned playerId) = 0;
|
||||||
|
virtual void SignalMutePlayer(unsigned playerId) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -239,6 +239,8 @@ ChatCleanerManager::HandleMessage(InternalChatCleanerPacket &msg)
|
|||||||
m_callback.SignalKickPlayer(netReply->playerId);
|
m_callback.SignalKickPlayer(netReply->playerId);
|
||||||
else if (netReply->cleanerActionType == cleanerActionType_cleanerActionBan)
|
else if (netReply->cleanerActionType == cleanerActionType_cleanerActionBan)
|
||||||
m_callback.SignalBanPlayer(netReply->playerId);
|
m_callback.SignalBanPlayer(netReply->playerId);
|
||||||
|
else if (netReply->cleanerActionType == cleanerActionType_cleanerActionMute)
|
||||||
|
m_callback.SignalMutePlayer(netReply->playerId);
|
||||||
error = false;
|
error = false;
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
|
|||||||
@@ -102,6 +102,17 @@ ServerGame::RemovePlayer(unsigned playerId, unsigned errorCode)
|
|||||||
SessionError(tmpSession, errorCode);
|
SessionError(tmpSession, errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ServerGame::MutePlayer(unsigned playerId, bool mute)
|
||||||
|
{
|
||||||
|
if (m_game) {
|
||||||
|
boost::shared_ptr<PlayerInterface> tmpPlayer(m_game->getPlayerByUniqueId(playerId));
|
||||||
|
if (tmpPlayer) {
|
||||||
|
tmpPlayer->setIsMuted(mute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerGame::MarkPlayerAsInactive(unsigned playerId)
|
ServerGame::MarkPlayerAsInactive(unsigned playerId)
|
||||||
{
|
{
|
||||||
@@ -612,6 +623,16 @@ ServerGame::GetPlayerInterfaceFromGame(const std::string &playerName)
|
|||||||
return tmpPlayer;
|
return tmpPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<PlayerInterface>
|
||||||
|
ServerGame::GetPlayerInterfaceFromGame(unsigned playerId)
|
||||||
|
{
|
||||||
|
boost::shared_ptr<PlayerInterface> tmpPlayer;
|
||||||
|
if (m_game) {
|
||||||
|
tmpPlayer = m_game->getPlayerByUniqueId(playerId);
|
||||||
|
}
|
||||||
|
return tmpPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ServerGame::IsRunning() const
|
ServerGame::IsRunning() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -266,6 +266,8 @@ AbstractServerGameStateReceiving::ProcessPacket(boost::shared_ptr<ServerGame> se
|
|||||||
chatSent = true;
|
chatSent = true;
|
||||||
}
|
}
|
||||||
} else if (netChatRequest->chatRequestType.present == chatRequestType_PR_chatRequestTypeGame) {
|
} else if (netChatRequest->chatRequestType.present == chatRequestType_PR_chatRequestTypeGame) {
|
||||||
|
boost::shared_ptr<PlayerInterface> tmpPlayer (server->GetPlayerInterfaceFromGame(session->GetPlayerData()->GetUniqueId()));
|
||||||
|
if (tmpPlayer && !tmpPlayer->isMuted()) {
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket(NetPacket::Alloc));
|
boost::shared_ptr<NetPacket> packet(new NetPacket(NetPacket::Alloc));
|
||||||
packet->GetMsg()->present = PokerTHMessage_PR_chatMessage;
|
packet->GetMsg()->present = PokerTHMessage_PR_chatMessage;
|
||||||
ChatMessage_t *netChat = &packet->GetMsg()->choice.chatMessage;
|
ChatMessage_t *netChat = &packet->GetMsg()->choice.chatMessage;
|
||||||
@@ -279,6 +281,7 @@ AbstractServerGameStateReceiving::ProcessPacket(boost::shared_ptr<ServerGame> se
|
|||||||
netChatRequest->chatText.size);
|
netChatRequest->chatText.size);
|
||||||
server->SendToAllPlayers(packet, SessionData::Game);
|
server->SendToAllPlayers(packet, SessionData::Game);
|
||||||
chatSent = true;
|
chatSent = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Send the message to the chat cleaner bot for ranking games.
|
// Send the message to the chat cleaner bot for ranking games.
|
||||||
//if (server->GetGameData().gameType == GAME_TYPE_RANKING)
|
//if (server->GetGameData().gameType == GAME_TYPE_RANKING)
|
||||||
|
|||||||
@@ -125,6 +125,10 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void SignalMutePlayer(unsigned playerId) {
|
||||||
|
m_server.MutePlayerInGame(playerId);
|
||||||
|
}
|
||||||
|
|
||||||
virtual void ConnectSuccess() {
|
virtual void ConnectSuccess() {
|
||||||
LOG_MSG("Successfully connected to database.");
|
LOG_MSG("Successfully connected to database.");
|
||||||
}
|
}
|
||||||
@@ -539,6 +543,12 @@ ServerLobbyThread::RemovePlayer(unsigned playerId, unsigned errorCode)
|
|||||||
m_ioService->post(boost::bind(&ServerLobbyThread::InternalRemovePlayer, shared_from_this(), playerId, errorCode));
|
m_ioService->post(boost::bind(&ServerLobbyThread::InternalRemovePlayer, shared_from_this(), playerId, errorCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ServerLobbyThread::MutePlayerInGame(unsigned playerId)
|
||||||
|
{
|
||||||
|
m_ioService->post(boost::bind(&ServerLobbyThread::InternalMutePlayerInGame, shared_from_this(), playerId));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerLobbyThread::SendGlobalChat(const string &message)
|
ServerLobbyThread::SendGlobalChat(const string &message)
|
||||||
{
|
{
|
||||||
@@ -1744,17 +1754,25 @@ ServerLobbyThread::InternalRemovePlayer(unsigned playerId, unsigned errorCode)
|
|||||||
if (session)
|
if (session)
|
||||||
SessionError(session, errorCode);
|
SessionError(session, errorCode);
|
||||||
else {
|
else {
|
||||||
// Scan games for the player.
|
// Remove player from game.
|
||||||
GameMap::iterator i = m_gameMap.begin();
|
boost::shared_ptr<SessionData> session = m_gameSessionManager.GetSessionByUniquePlayerId(playerId);
|
||||||
GameMap::iterator end = m_gameMap.end();
|
if (session) {
|
||||||
|
boost::shared_ptr<ServerGame> tmpGame = session->GetGame();
|
||||||
while (i != end) {
|
if (tmpGame) {
|
||||||
boost::shared_ptr<ServerGame> tmpGame = i->second;
|
|
||||||
if (tmpGame->GetPlayerDataByUniqueId(playerId)) {
|
|
||||||
tmpGame->RemovePlayer(playerId, errorCode);
|
tmpGame->RemovePlayer(playerId, errorCode);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
++i;
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ServerLobbyThread::InternalMutePlayerInGame(unsigned playerId)
|
||||||
|
{
|
||||||
|
boost::shared_ptr<SessionData> session = m_gameSessionManager.GetSessionByUniquePlayerId(playerId);
|
||||||
|
if (session) {
|
||||||
|
boost::shared_ptr<ServerGame> tmpGame = session->GetGame();
|
||||||
|
if (tmpGame) {
|
||||||
|
tmpGame->MutePlayer(playerId, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public:
|
|||||||
|
|
||||||
void AddSession(boost::shared_ptr<SessionData> session);
|
void AddSession(boost::shared_ptr<SessionData> session);
|
||||||
void RemovePlayer(unsigned playerId, unsigned errorCode);
|
void RemovePlayer(unsigned playerId, unsigned errorCode);
|
||||||
|
void MutePlayer(unsigned playerId, bool mute);
|
||||||
void MarkPlayerAsInactive(unsigned playerId);
|
void MarkPlayerAsInactive(unsigned playerId);
|
||||||
void MarkPlayerAsKicked(unsigned playerId);
|
void MarkPlayerAsKicked(unsigned playerId);
|
||||||
|
|
||||||
@@ -76,6 +77,7 @@ public:
|
|||||||
bool IsPlayerConnected(unsigned playerId) const;
|
bool IsPlayerConnected(unsigned playerId) const;
|
||||||
bool IsClientAddressConnected(const std::string &clientAddress) const;
|
bool IsClientAddressConnected(const std::string &clientAddress) const;
|
||||||
boost::shared_ptr<PlayerInterface> GetPlayerInterfaceFromGame(const std::string &playerName);
|
boost::shared_ptr<PlayerInterface> GetPlayerInterfaceFromGame(const std::string &playerName);
|
||||||
|
boost::shared_ptr<PlayerInterface> GetPlayerInterfaceFromGame(unsigned playerId);
|
||||||
|
|
||||||
bool IsRunning() const;
|
bool IsRunning() const;
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ public:
|
|||||||
std::string GetPlayerIPAddress(const std::string &playerName) const;
|
std::string GetPlayerIPAddress(const std::string &playerName) const;
|
||||||
std::string GetPlayerNameFromId(unsigned playerId) const;
|
std::string GetPlayerNameFromId(unsigned playerId) const;
|
||||||
void RemovePlayer(unsigned playerId, unsigned errorCode);
|
void RemovePlayer(unsigned playerId, unsigned errorCode);
|
||||||
|
void MutePlayerInGame(unsigned playerId);
|
||||||
|
|
||||||
void SendGlobalChat(const std::string &message);
|
void SendGlobalChat(const std::string &message);
|
||||||
void SendGlobalMsgBox(const std::string &message);
|
void SendGlobalMsgBox(const std::string &message);
|
||||||
@@ -163,6 +164,7 @@ protected:
|
|||||||
void InternalAddGame(boost::shared_ptr<ServerGame> game);
|
void InternalAddGame(boost::shared_ptr<ServerGame> game);
|
||||||
void InternalRemoveGame(boost::shared_ptr<ServerGame> game);
|
void InternalRemoveGame(boost::shared_ptr<ServerGame> game);
|
||||||
void InternalRemovePlayer(unsigned playerId, unsigned errorCode);
|
void InternalRemovePlayer(unsigned playerId, unsigned errorCode);
|
||||||
|
void InternalMutePlayerInGame(unsigned playerId);
|
||||||
void InternalResubscribeMsg(boost::shared_ptr<SessionData> session);
|
void InternalResubscribeMsg(boost::shared_ptr<SessionData> session);
|
||||||
|
|
||||||
void HandleReAddedSession(boost::shared_ptr<SessionData> session);
|
void HandleReAddedSession(boost::shared_ptr<SessionData> session);
|
||||||
|
|||||||
Reference in New Issue
Block a user