diff --git a/cockatrice/src/tab_game.cpp b/cockatrice/src/tab_game.cpp index 009b77c4..424b9e3c 100644 --- a/cockatrice/src/tab_game.cpp +++ b/cockatrice/src/tab_game.cpp @@ -445,13 +445,13 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QTimer::singleShot(0, this, SLOT(loadLayout())); } -void TabGame::addMentionTag(QString value) +void TabGame::addMentionTag(const QString &value) { sayEdit->insert(value + " "); sayEdit->setFocus(); } -void TabGame::linkCardToChat(QString cardName) +void TabGame::linkCardToChat(const QString &cardName) { sayEdit->insert("[[" + cardName + "]] "); sayEdit->setFocus(); @@ -1814,10 +1814,19 @@ void TabGame::createMessageDock(bool bReplay) sayEdit->setCompleter(completer); actCompleterChanged(); - if (spectator && !gameInfo.spectators_can_chat() && tabSupervisor->getAdminLocked()) { - sayLabel->hide(); - sayEdit->hide(); + if (spectator) { + /* Spectators can only talk if: + * (a) the game creator allows it + * (b) the spectator is a moderator/administrator + * (c) the spectator is a judge + */ + bool isModOrJudge = !tabSupervisor->getAdminLocked() || judge; + if (!isModOrJudge && !gameInfo.spectators_can_chat()) { + sayLabel->hide(); + sayEdit->hide(); + } } + connect(tabSupervisor, SIGNAL(adminLockChanged(bool)), this, SLOT(adminLockChanged(bool))); connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(actSay())); diff --git a/cockatrice/src/tab_game.h b/cockatrice/src/tab_game.h index d99a68cd..97c36498 100644 --- a/cockatrice/src/tab_game.h +++ b/cockatrice/src/tab_game.h @@ -242,8 +242,8 @@ private slots: void actNextTurn(); void actReverseTurn(); - void addMentionTag(QString value); - void linkCardToChat(QString cardName); + void addMentionTag(const QString &value); + void linkCardToChat(const QString &cardName); void commandFinished(const Response &response); void refreshShortcuts(); diff --git a/cockatrice/src/tab_supervisor.cpp b/cockatrice/src/tab_supervisor.cpp index c9aacbf1..d6f07873 100644 --- a/cockatrice/src/tab_supervisor.cpp +++ b/cockatrice/src/tab_supervisor.cpp @@ -621,6 +621,11 @@ void TabSupervisor::updateCurrent(int index) emit setMenu(); } +/** + * Determine if a user is a moderator/administrator + * By seeing if they have the admin tab open & unlocked + * @return if the admin tab is open & unlocked + */ bool TabSupervisor::getAdminLocked() const { if (!tabAdmin) diff --git a/common/server_player.cpp b/common/server_player.cpp index fa19c63b..35debaa4 100644 --- a/common/server_player.cpp +++ b/common/server_player.cpp @@ -919,8 +919,16 @@ Server_Player::cmdReadyStart(const Command_ReadyStart &cmd, ResponseContainer & Response::ResponseCode Server_Player::cmdGameSay(const Command_GameSay &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges) { - if (spectator && !game->getSpectatorsCanTalk() && !(userInfo->user_level() & ServerInfo_User::IsModerator)) { - return Response::RespFunctionNotAllowed; + if (spectator) { + /* Spectators can only talk if: + * (a) the game creator allows it + * (b) the spectator is a moderator/administrator + * (c) the spectator is a judge + */ + bool isModOrJudge = (userInfo->user_level() & (ServerInfo_User::IsModerator | ServerInfo_User::IsJudge)); + if (!isModOrJudge && !game->getSpectatorsCanTalk()) { + return Response::RespFunctionNotAllowed; + } } Event_GameSay event;