mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 14:32:15 -07:00
Do not log already joined players when resuming a game.
Took 19 minutes
This commit is contained in:
parent
89a8d0f6b8
commit
f49ad4dfa7
1 changed files with 13 additions and 3 deletions
|
|
@ -240,6 +240,11 @@ void GameEventHandler::eventGameStateChanged(const Event_GameStateChanged &event
|
||||||
int /*eventPlayerId*/,
|
int /*eventPlayerId*/,
|
||||||
const GameEventContext & /*context*/)
|
const GameEventContext & /*context*/)
|
||||||
{
|
{
|
||||||
|
// Early check here since this is important for the emission of the join log signals.
|
||||||
|
if (event.game_started() && !game->getGameMetaInfo()->started()) {
|
||||||
|
game->getGameState()->setResuming(!game->getGameState()->isGameStateKnown());
|
||||||
|
}
|
||||||
|
|
||||||
const int playerListSize = event.player_list_size();
|
const int playerListSize = event.player_list_size();
|
||||||
|
|
||||||
QVector<QPair<int, QPair<QString, QString>>> opponentDecksToDisplay;
|
QVector<QPair<int, QPair<QString, QString>>> opponentDecksToDisplay;
|
||||||
|
|
@ -254,14 +259,20 @@ void GameEventHandler::eventGameStateChanged(const Event_GameStateChanged &event
|
||||||
if (!game->getPlayerManager()->getSpectators().contains(playerId)) {
|
if (!game->getPlayerManager()->getSpectators().contains(playerId)) {
|
||||||
game->getPlayerManager()->addSpectator(playerId, prop);
|
game->getPlayerManager()->addSpectator(playerId, prop);
|
||||||
emit spectatorJoined(prop);
|
emit spectatorJoined(prop);
|
||||||
emit logJoinSpectator(playerName);
|
// If the game is resuming, everyone else has already enjoyed. The local spectator always joins.
|
||||||
|
if (!game->getGameState()->isResuming() || playerId == game->getPlayerManager()->getLocalPlayerId()) {
|
||||||
|
emit logJoinSpectator(playerName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Player *player = game->getPlayerManager()->getPlayers().value(playerId, 0);
|
Player *player = game->getPlayerManager()->getPlayers().value(playerId, 0);
|
||||||
if (!player) {
|
if (!player) {
|
||||||
player = game->getPlayerManager()->addPlayer(playerId, prop.user_info());
|
player = game->getPlayerManager()->addPlayer(playerId, prop.user_info());
|
||||||
emit playerJoined(prop);
|
emit playerJoined(prop);
|
||||||
emit logJoinPlayer(player);
|
// If the game is resuming, everyone else has already enjoyed. The local player always joins.
|
||||||
|
if (!game->getGameState()->isResuming() || playerId == game->getPlayerManager()->getLocalPlayerId()) {
|
||||||
|
emit logJoinPlayer(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
player->processPlayerInfo(playerInfo);
|
player->processPlayerInfo(playerInfo);
|
||||||
if (player->getPlayerInfo()->getLocal()) {
|
if (player->getPlayerInfo()->getLocal()) {
|
||||||
|
|
@ -284,7 +295,6 @@ void GameEventHandler::eventGameStateChanged(const Event_GameStateChanged &event
|
||||||
game->getGameState()->setGameTime(event.seconds_elapsed());
|
game->getGameState()->setGameTime(event.seconds_elapsed());
|
||||||
|
|
||||||
if (event.game_started() && !game->getGameMetaInfo()->started()) {
|
if (event.game_started() && !game->getGameMetaInfo()->started()) {
|
||||||
game->getGameState()->setResuming(!game->getGameState()->isGameStateKnown());
|
|
||||||
game->getGameMetaInfo()->setStarted(event.game_started());
|
game->getGameMetaInfo()->setStarted(event.game_started());
|
||||||
if (game->getGameState()->isGameStateKnown())
|
if (game->getGameState()->isGameStateKnown())
|
||||||
emit logGameStart();
|
emit logGameStart();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue