Skip to content

Commit

Permalink
Merge pull request #375 from Ymihere03/better-ready-check
Browse files Browse the repository at this point in the history
Initiate ready check when a player switches to away/spectator
  • Loading branch information
Ymihere03 authored Dec 18, 2023
2 parents 9e4a339 + 8c1102d commit 617c7d1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/game/CAbstractPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1553,8 +1553,12 @@ void CAbstractPlayer::PlayerAction() {
Reincarnate();
} else {
itsManager->DeadOrDone();
if ((itsGame->GetSpectatePlayer() == NULL && itsManager->IsLocalPlayer()) || // Player is out of lives
(itsGame->GetSpectatePlayer() != NULL && itsGame->GetSpectatePlayer()->lives == 0)) { // Spectate player is out of lives

// Auto spectate another player if:
// - The player runs out of lives
// - The player being spectated runs out of lives
if ((itsGame->GetSpectatePlayer() == NULL && itsManager->IsLocalPlayer()) ||
(itsGame->GetSpectatePlayer() != NULL && itsGame->GetSpectatePlayer()->lives == 0)) {
itsGame->SpectateNext();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/game/CHUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ void CHUD::DrawKillFeed(NVGcontext *ctx, CNetManager *net, int bufferWidth, floa
nvgFillColor(ctx, BACKGROUND_COLOR);
nvgFill(ctx);

ARGBColor longTeamColor = *ColorManager::getTeamColor(net->teamColors[event.team]);
ARGBColor longTeamColor = *ColorManager::getTeamColor(event.team);
longTeamColor.ExportGLFloats(teamColorRGB, 3);

nvgBeginPath(ctx);
Expand Down Expand Up @@ -886,7 +886,7 @@ void CHUD::DrawKillFeed(NVGcontext *ctx, CNetManager *net, int bufferWidth, floa
nvgFillColor(ctx, BACKGROUND_COLOR);
nvgFill(ctx);

ARGBColor longTeamColor = *ColorManager::getTeamColor(net->teamColors[event.team]);
ARGBColor longTeamColor = *ColorManager::getTeamColor(event.team);
longTeamColor.ExportGLFloats(teamColorRGB, 3);

nvgBeginPath(ctx);
Expand Down
6 changes: 6 additions & 0 deletions src/game/CPlayerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,12 @@ void CPlayerManagerImpl::SetPlayerStatus(LoadingState newStatus, PresenceType ne

loadingStatus = newStatus;
presence = newPresence;

// Check if the game is ready to start if a player set themselves to away or spectator
// Only the server can start the game this way to prevent multiple game start commands
if ((newPresence == kzSpectating || newPresence == kzAway) && theNetManager->itsCommManager->myId == 0) {
SetPlayerReady(true);
}
}

void CPlayerManagerImpl::SetPlayerReady(bool isReady) {
Expand Down

0 comments on commit 617c7d1

Please sign in to comment.