[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().
This commit is contained in:
Lukas Brübach 2026-11-04 08:58:36 +01:00
parent e945b73e3a
commit 16a2e70039
2 changed files with 23 additions and 4 deletions

View file

@ -634,7 +634,7 @@ void TabGame::actConcede()
void TabGame::actTurnOrder() void TabGame::actTurnOrder()
{ {
if (!game->isHost() || game->getGameMetaInfo()->started()) { if (!canSetTurnOrder()) {
return; return;
} }
@ -668,17 +668,35 @@ void TabGame::actTurnOrder()
game->getGameEventHandler()->handleSetPlayerOrder(dlg.order(), dlg.isRandomizeRequested()); 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 * 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 * player must be allowed to set the order and the game must not have started.
* either condition may have changed (game start/stop, host change). * Called whenever either condition may have changed (game start/stop, host
* change).
*/ */
void TabGame::updateTurnOrderAction() void TabGame::updateTurnOrderAction()
{ {
if (aTurnOrder == nullptr) { if (aTurnOrder == nullptr) {
return; return;
} }
aTurnOrder->setVisible(game->isHost() && !game->getGameMetaInfo()->started()); aTurnOrder->setVisible(canSetTurnOrder());
} }
/** /**

View file

@ -130,6 +130,7 @@ private:
PlayerLogic *setActivePlayer(int id); PlayerLogic *setActivePlayer(int id);
void setActivePhase(int phase); void setActivePhase(int phase);
bool canSetTurnOrder() const;
void createMenuItems(); void createMenuItems();
void createReplayMenuItems(); void createReplayMenuItems();
void createViewMenuItems(); void createViewMenuItems();