mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 16:44:48 -07:00
[Server_AbstractParticipant] Rename bool getters (#6492)
* [Server_AbstractParticipant] Rename bool getters * reformat
This commit is contained in:
parent
746f2af044
commit
2d5e8deb75
3 changed files with 16 additions and 17 deletions
|
|
@ -89,11 +89,11 @@ public:
|
||||||
{
|
{
|
||||||
return playerId;
|
return playerId;
|
||||||
}
|
}
|
||||||
bool getSpectator() const
|
bool isSpectator() const
|
||||||
{
|
{
|
||||||
return spectator;
|
return spectator;
|
||||||
}
|
}
|
||||||
bool getJudge() const
|
bool isJudge() const
|
||||||
{
|
{
|
||||||
return judge;
|
return judge;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1516,7 +1516,7 @@ Server_AbstractPlayer::cmdRevealCards(const Command_RevealCards &cmd, ResponseCo
|
||||||
zone->addWritePermission(cmd.player_id());
|
zone->addWritePermission(cmd.player_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getJudge()) {
|
if (isJudge()) {
|
||||||
ges.setOverwriteOwnership(true);
|
ges.setOverwriteOwnership(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ void Server_Game::pingClockTimeout()
|
||||||
if (participant == nullptr)
|
if (participant == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!participant->getSpectator()) {
|
if (!participant->isSpectator()) {
|
||||||
++playerCount;
|
++playerCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -200,7 +200,7 @@ void Server_Game::pingClockTimeout()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((participant->getPingTime() != -1) &&
|
if ((participant->getPingTime() != -1) &&
|
||||||
(!participant->getSpectator() || participant->getPlayerId() == hostId)) {
|
(!participant->isSpectator() || participant->getPlayerId() == hostId)) {
|
||||||
allPlayersInactive = false;
|
allPlayersInactive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -222,7 +222,7 @@ QMap<int, Server_AbstractPlayer *> Server_Game::getPlayers() const // copies poi
|
||||||
QMutexLocker locker(&gameMutex);
|
QMutexLocker locker(&gameMutex);
|
||||||
for (int id : participants.keys()) {
|
for (int id : participants.keys()) {
|
||||||
auto *participant = participants[id];
|
auto *participant = participants[id];
|
||||||
if (!participant->getSpectator()) {
|
if (!participant->isSpectator()) {
|
||||||
players[id] = static_cast<Server_AbstractPlayer *>(participant);
|
players[id] = static_cast<Server_AbstractPlayer *>(participant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -232,7 +232,7 @@ QMap<int, Server_AbstractPlayer *> Server_Game::getPlayers() const // copies poi
|
||||||
Server_AbstractPlayer *Server_Game::getPlayer(int id) const
|
Server_AbstractPlayer *Server_Game::getPlayer(int id) const
|
||||||
{
|
{
|
||||||
auto *participant = participants.value(id);
|
auto *participant = participants.value(id);
|
||||||
if (!participant->getSpectator()) {
|
if (!participant->isSpectator()) {
|
||||||
return static_cast<Server_AbstractPlayer *>(participant);
|
return static_cast<Server_AbstractPlayer *>(participant);
|
||||||
} else {
|
} else {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -250,7 +250,7 @@ int Server_Game::getSpectatorCount() const
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for (Server_AbstractParticipant *participant : participants.values()) {
|
for (Server_AbstractParticipant *participant : participants.values()) {
|
||||||
if (participant->getSpectator())
|
if (participant->isSpectator())
|
||||||
++result;
|
++result;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -295,8 +295,8 @@ void Server_Game::sendGameStateToPlayers()
|
||||||
// send game state info to clients according to their role in the game
|
// send game state info to clients according to their role in the game
|
||||||
for (auto *participant : participants.values()) {
|
for (auto *participant : participants.values()) {
|
||||||
GameEventContainer *gec;
|
GameEventContainer *gec;
|
||||||
if (participant->getSpectator()) {
|
if (participant->isSpectator()) {
|
||||||
if (spectatorsSeeEverything || participant->getJudge()) {
|
if (spectatorsSeeEverything || participant->isJudge()) {
|
||||||
gec = prepareGameEvent(omniscientEvent, -1);
|
gec = prepareGameEvent(omniscientEvent, -1);
|
||||||
} else {
|
} else {
|
||||||
gec = prepareGameEvent(spectatorNormalEvent, -1);
|
gec = prepareGameEvent(spectatorNormalEvent, -1);
|
||||||
|
|
@ -527,7 +527,7 @@ void Server_Game::removeParticipant(Server_AbstractParticipant *participant, Eve
|
||||||
gameId, participant->getPlayerId());
|
gameId, participant->getPlayerId());
|
||||||
participants.remove(participant->getPlayerId());
|
participants.remove(participant->getPlayerId());
|
||||||
|
|
||||||
bool spectator = participant->getSpectator();
|
bool spectator = participant->isSpectator();
|
||||||
GameEventStorage ges;
|
GameEventStorage ges;
|
||||||
if (!spectator) {
|
if (!spectator) {
|
||||||
auto *player = static_cast<Server_AbstractPlayer *>(participant);
|
auto *player = static_cast<Server_AbstractPlayer *>(participant);
|
||||||
|
|
@ -728,8 +728,8 @@ void Server_Game::createGameJoinedEvent(Server_AbstractParticipant *joiningParti
|
||||||
getInfo(*event1.mutable_game_info());
|
getInfo(*event1.mutable_game_info());
|
||||||
event1.set_host_id(hostId);
|
event1.set_host_id(hostId);
|
||||||
event1.set_player_id(joiningParticipant->getPlayerId());
|
event1.set_player_id(joiningParticipant->getPlayerId());
|
||||||
event1.set_spectator(joiningParticipant->getSpectator());
|
event1.set_spectator(joiningParticipant->isSpectator());
|
||||||
event1.set_judge(joiningParticipant->getJudge());
|
event1.set_judge(joiningParticipant->isJudge());
|
||||||
event1.set_resuming(resuming);
|
event1.set_resuming(resuming);
|
||||||
if (resuming) {
|
if (resuming) {
|
||||||
const QStringList &allGameTypes = room->getGameTypes();
|
const QStringList &allGameTypes = room->getGameTypes();
|
||||||
|
|
@ -747,7 +747,7 @@ void Server_Game::createGameJoinedEvent(Server_AbstractParticipant *joiningParti
|
||||||
event2.set_active_player_id(activePlayer);
|
event2.set_active_player_id(activePlayer);
|
||||||
event2.set_active_phase(activePhase);
|
event2.set_active_phase(activePhase);
|
||||||
|
|
||||||
bool omniscient = joiningParticipant->getSpectator() && (spectatorsSeeEverything || joiningParticipant->getJudge());
|
bool omniscient = joiningParticipant->isSpectator() && (spectatorsSeeEverything || joiningParticipant->isJudge());
|
||||||
for (auto *participant : participants.values()) {
|
for (auto *participant : participants.values()) {
|
||||||
participant->getInfo(event2.add_player_list(), joiningParticipant, omniscient, true);
|
participant->getInfo(event2.add_player_list(), joiningParticipant, omniscient, true);
|
||||||
}
|
}
|
||||||
|
|
@ -763,9 +763,8 @@ void Server_Game::sendGameEventContainer(GameEventContainer *cont,
|
||||||
|
|
||||||
cont->set_game_id(gameId);
|
cont->set_game_id(gameId);
|
||||||
for (auto *participant : participants.values()) {
|
for (auto *participant : participants.values()) {
|
||||||
const bool playerPrivate =
|
const bool playerPrivate = (participant->getPlayerId() == privatePlayerId) ||
|
||||||
(participant->getPlayerId() == privatePlayerId) ||
|
(participant->isSpectator() && (spectatorsSeeEverything || participant->isJudge()));
|
||||||
(participant->getSpectator() && (spectatorsSeeEverything || participant->getJudge()));
|
|
||||||
if ((recipients.testFlag(GameEventStorageItem::SendToPrivate) && playerPrivate) ||
|
if ((recipients.testFlag(GameEventStorageItem::SendToPrivate) && playerPrivate) ||
|
||||||
(recipients.testFlag(GameEventStorageItem::SendToOthers) && !playerPrivate))
|
(recipients.testFlag(GameEventStorageItem::SendToOthers) && !playerPrivate))
|
||||||
participant->sendGameEvent(*cont);
|
participant->sendGameEvent(*cont);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue