From 16a2e70039181cfd65c6242f3da805a29d84ecfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Wed, 4 Nov 2026 08:58:36 +0100 Subject: [PATCH] [Client] Let moderators set the turn order The server accepts SET_PLAYER_ORDER from the host or a moderator, but the client hid the action from everyone except the host, making the moderator branch unreachable. Visibility and the handler now share canSetTurnOrder(). --- .../src/interface/widgets/tabs/tab_game.cpp | 26 ++++++++++++++++--- .../src/interface/widgets/tabs/tab_game.h | 1 + 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/cockatrice/src/interface/widgets/tabs/tab_game.cpp b/cockatrice/src/interface/widgets/tabs/tab_game.cpp index 7270e001a..a38bf7b21 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_game.cpp +++ b/cockatrice/src/interface/widgets/tabs/tab_game.cpp @@ -634,7 +634,7 @@ void TabGame::actConcede() void TabGame::actTurnOrder() { - if (!game->isHost() || game->getGameMetaInfo()->started()) { + if (!canSetTurnOrder()) { return; } @@ -668,17 +668,35 @@ void TabGame::actTurnOrder() game->getGameEventHandler()->handleSetPlayerOrder(dlg.order(), dlg.isRandomizeRequested()); } +/** + * Whether the local user may change the seating order: only while the game has + * not started, and only as the host or a moderator - the server allows both + * (Server_AbstractParticipant::cmdSetPlayerOrder). + */ +bool TabGame::canSetTurnOrder() const +{ + if (game->getGameMetaInfo()->started()) { + return false; + } + if (game->isHost()) { + return true; + } + const ServerInfo_User *userInfo = tabSupervisor->getUserInfo(); + return userInfo != nullptr && (userInfo->user_level() & ServerInfo_User::IsModerator); +} + /** * Shows the turn order action only when it can actually change anything: the - * player must be host and the game must not have started yet. Called whenever - * either condition may have changed (game start/stop, host change). + * player must be allowed to set the order and the game must not have started. + * Called whenever either condition may have changed (game start/stop, host + * change). */ void TabGame::updateTurnOrderAction() { if (aTurnOrder == nullptr) { return; } - aTurnOrder->setVisible(game->isHost() && !game->getGameMetaInfo()->started()); + aTurnOrder->setVisible(canSetTurnOrder()); } /** diff --git a/cockatrice/src/interface/widgets/tabs/tab_game.h b/cockatrice/src/interface/widgets/tabs/tab_game.h index 7e9452caf..412529dc2 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_game.h +++ b/cockatrice/src/interface/widgets/tabs/tab_game.h @@ -130,6 +130,7 @@ private: PlayerLogic *setActivePlayer(int id); void setActivePhase(int phase); + bool canSetTurnOrder() const; void createMenuItems(); void createReplayMenuItems(); void createViewMenuItems();