mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-01-08 19:33:22 -08:00
Allow Judges to see all information, regardless of room settings (#5053)
This commit is contained in:
@@ -276,7 +276,7 @@ void Server_Game::sendGameStateToPlayers()
|
||||
{
|
||||
// game state information for replay and omniscient spectators
|
||||
Event_GameStateChanged omniscientEvent;
|
||||
createGameStateChangedEvent(&omniscientEvent, 0, true, false);
|
||||
createGameStateChangedEvent(&omniscientEvent, nullptr, true, false);
|
||||
|
||||
GameEventContainer *replayCont = prepareGameEvent(omniscientEvent, -1);
|
||||
replayCont->set_seconds_elapsed(secondsElapsed - startTimeOfThisGame);
|
||||
@@ -287,18 +287,19 @@ void Server_Game::sendGameStateToPlayers()
|
||||
// If spectators are not omniscient, we need an additional createGameStateChangedEvent call, otherwise we can use
|
||||
// the data we used for the replay. All spectators are equal, so we don't need to make a createGameStateChangedEvent
|
||||
// call for each one.
|
||||
Event_GameStateChanged spectatorEvent;
|
||||
if (spectatorsSeeEverything)
|
||||
spectatorEvent = omniscientEvent;
|
||||
else
|
||||
createGameStateChangedEvent(&spectatorEvent, 0, false, false);
|
||||
Event_GameStateChanged spectatorNormalEvent;
|
||||
createGameStateChangedEvent(&spectatorNormalEvent, nullptr, false, false);
|
||||
|
||||
// send game state info to clients according to their role in the game
|
||||
for (Server_Player *player : players.values()) {
|
||||
GameEventContainer *gec;
|
||||
if (player->getSpectator())
|
||||
gec = prepareGameEvent(spectatorEvent, -1);
|
||||
else {
|
||||
if (player->getSpectator()) {
|
||||
if (spectatorsSeeEverything || player->getJudge()) {
|
||||
gec = prepareGameEvent(omniscientEvent, -1);
|
||||
} else {
|
||||
gec = prepareGameEvent(spectatorNormalEvent, -1);
|
||||
}
|
||||
} else {
|
||||
Event_GameStateChanged event;
|
||||
createGameStateChangedEvent(&event, player, false, false);
|
||||
|
||||
@@ -341,7 +342,7 @@ void Server_Game::doStartGameIfReady()
|
||||
gameInfo->set_started(false);
|
||||
|
||||
Event_GameStateChanged omniscientEvent;
|
||||
createGameStateChangedEvent(&omniscientEvent, 0, true, true);
|
||||
createGameStateChangedEvent(&omniscientEvent, nullptr, true, true);
|
||||
|
||||
GameEventContainer *replayCont = prepareGameEvent(omniscientEvent, -1);
|
||||
replayCont->set_seconds_elapsed(0);
|
||||
@@ -711,7 +712,8 @@ void Server_Game::createGameJoinedEvent(Server_Player *player, ResponseContainer
|
||||
event2.set_active_phase(activePhase);
|
||||
|
||||
for (auto *_player : players.values()) {
|
||||
_player->getInfo(event2.add_player_list(), _player, _player->getSpectator() && spectatorsSeeEverything, true);
|
||||
_player->getInfo(event2.add_player_list(), _player,
|
||||
(_player->getSpectator() && (spectatorsSeeEverything || _player->getJudge())), true);
|
||||
}
|
||||
|
||||
rc.enqueuePostResponseItem(ServerMessage::GAME_EVENT_CONTAINER, prepareGameEvent(event2, -1));
|
||||
@@ -725,8 +727,8 @@ void Server_Game::sendGameEventContainer(GameEventContainer *cont,
|
||||
|
||||
cont->set_game_id(gameId);
|
||||
for (Server_Player *player : players.values()) {
|
||||
const bool playerPrivate =
|
||||
(player->getPlayerId() == privatePlayerId) || (player->getSpectator() && spectatorsSeeEverything);
|
||||
const bool playerPrivate = (player->getPlayerId() == privatePlayerId) ||
|
||||
(player->getSpectator() && (spectatorsSeeEverything || player->getJudge()));
|
||||
if ((recipients.testFlag(GameEventStorageItem::SendToPrivate) && playerPrivate) ||
|
||||
(recipients.testFlag(GameEventStorageItem::SendToOthers) && !playerPrivate))
|
||||
player->sendGameEvent(*cont);
|
||||
|
||||
Reference in New Issue
Block a user