# HG changeset patch # User Adam Kaminski # Date 1621801699 14400 # Sun May 23 16:28:19 2021 -0400 # Node ID 57744dc1f002e098c5d190f28798680d4df5f529 # Parent 7d8a3f1d94e9413bf03eb09d8b4e20be2a77c0ce Replaced SCOREBOARD_GetNumPlayers with SERVER_CalcNumNonSpectatingPlayers. diff -r 7d8a3f1d94e9 -r 57744dc1f002 src/g_doom/doom_sbar.cpp --- a/src/g_doom/doom_sbar.cpp Thu May 20 00:14:48 2021 -0400 +++ b/src/g_doom/doom_sbar.cpp Sun May 23 16:28:19 2021 -0400 @@ -835,7 +835,7 @@ } // Just simple deathmatch. Draw the individual rank/spread if there are competitors. - else if ( deathmatch && SCOREBOARD_GetNumPlayers( ) > 1 ) + else if ( deathmatch && SERVER_CalcNumNonSpectatingPlayers( MAXPLAYERS ) > 1 ) { ulCurXPos = 4; ulCurYPos = screenHeight - 4 - ( TexMan["MEDIA0"]->GetHeight( ) + 4 ) *2 - ( TexMan["ARM1A0"]->GetHeight( ) + 4 ) - 14; @@ -852,7 +852,7 @@ if ( !duel ) { ulCurYPos += ConFont->GetHeight( ) + 4; - sprintf( szString, "rank: \\cC%d/%s%d", static_cast (SCOREBOARD_GetRank( ) + 1), SCOREBOARD_IsTied( ) ? "\\cG" : "", static_cast (SCOREBOARD_GetNumPlayers( ))); + sprintf( szString, "rank: \\cC%d/%s%d", static_cast (SCOREBOARD_GetRank( ) + 1), SCOREBOARD_IsTied( ) ? "\\cG" : "", static_cast( SERVER_CalcNumNonSpectatingPlayers( MAXPLAYERS ))); V_ColorizeString( szString ); HUD_DrawText( ConFont, CR_RED, ulCurXPos, diff -r 7d8a3f1d94e9 -r 57744dc1f002 src/scoreboard.cpp --- a/src/scoreboard.cpp Thu May 20 00:14:48 2021 -0400 +++ b/src/scoreboard.cpp Sun May 23 16:28:19 2021 -0400 @@ -84,9 +84,6 @@ // Player list according to rank. static int g_iSortedPlayers[MAXPLAYERS]; -// How many players are currently in the game? -static ULONG g_ulNumPlayers = 0; - // What is our current rank? static ULONG g_ulRank = 0; @@ -816,6 +813,7 @@ // void SCOREBOARD_RenderStats_RankSpread( void ) { + ULONG ulNumPlayers = SERVER_CalcNumNonSpectatingPlayers( MAXPLAYERS ); ULONG ulYPos; char szString[160]; @@ -826,10 +824,10 @@ ulYPos -= ( g_ulTextHeight * 2 ); // [RC] Don't draw this if there aren't any competitors. - if ( g_ulNumPlayers <= 1 ) + if ( ulNumPlayers <= 1 ) return; - sprintf( szString, "\\cGRANK: \\cC%d/%s%d", static_cast (g_ulRank + 1), g_bIsTied ? "\\cG" : "", static_cast (g_ulNumPlayers) ); + sprintf( szString, "\\cGRANK: \\cC%d/%s%d", static_cast (g_ulRank + 1), g_bIsTied ? "\\cG" : "", static_cast( ulNumPlayers )); V_ColorizeString( szString ); HUD_DrawText( SmallFont, CR_GRAY, @@ -1859,7 +1857,6 @@ if ( NETWORK_GetState( ) == NETSTATE_SERVER ) return; - g_ulNumPlayers = 0; g_pTerminatorArtifactCarrier = NULL; g_pPossessionArtifactCarrier = NULL; @@ -1869,35 +1866,22 @@ g_pWhiteCarrier = NULL; for ( ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ ) { - if ( lastmanstanding || teamlms ) + if (( playeringame[ulIdx] ) && ( PLAYER_IsTrueSpectator( &players[ulIdx] ) == false )) { - if ( playeringame[ulIdx] == false ) - continue; - - if ( PLAYER_IsTrueSpectator( &players[ulIdx] ) == false ) - g_ulNumPlayers++; - } - else - { - if ( playeringame[ulIdx] && ( players[ulIdx].bSpectating == false )) + if ( players[ulIdx].cheats2 & CF2_TERMINATORARTIFACT ) + g_pTerminatorArtifactCarrier = &players[ulIdx]; + else if ( players[ulIdx].cheats2 & CF2_POSSESSIONARTIFACT ) + g_pPossessionArtifactCarrier = &players[ulIdx]; + else if ( players[ulIdx].mo ) { - g_ulNumPlayers++; - - if ( players[ulIdx].cheats2 & CF2_TERMINATORARTIFACT ) - g_pTerminatorArtifactCarrier = &players[ulIdx]; - else if ( players[ulIdx].cheats2 & CF2_POSSESSIONARTIFACT ) - g_pPossessionArtifactCarrier = &players[ulIdx]; - else if ( players[ulIdx].mo ) + for ( ULONG i = 0; i < teams.Size( ); i++ ) { - for ( ULONG i = 0; i < teams.Size( ); i++ ) - { - if ( players[ulIdx].mo->FindInventory( TEAM_GetItem( i ))) - TEAM_SetCarrier( i, &players[ulIdx] ); - } - - if ( players[ulIdx].mo->FindInventory( PClass::FindClass( "WhiteFlag" ), true )) - g_pWhiteCarrier = &players[ulIdx]; + if ( players[ulIdx].mo->FindInventory( TEAM_GetItem( i ))) + TEAM_SetCarrier( i, &players[ulIdx] ); } + + if ( players[ulIdx].mo->FindInventory( PClass::FindClass( "WhiteFlag" ), true )) + g_pWhiteCarrier = &players[ulIdx]; } } } @@ -1934,13 +1918,6 @@ //***************************************************************************** // -ULONG SCOREBOARD_GetNumPlayers( void ) -{ - return ( g_ulNumPlayers ); -} - -//***************************************************************************** -// ULONG SCOREBOARD_GetRank( void ) { return ( g_ulRank ); diff -r 7d8a3f1d94e9 -r 57744dc1f002 src/scoreboard.h --- a/src/scoreboard.h Thu May 20 00:14:48 2021 -0400 +++ b/src/scoreboard.h Sun May 23 16:28:19 2021 -0400 @@ -119,7 +119,6 @@ void SCOREBOARD_DisplayFragMessage( player_t *pFraggedPlayer ); void SCOREBOARD_DisplayFraggedMessage( player_t *pFraggingPlayer ); void SCOREBOARD_RefreshHUD( void ); -ULONG SCOREBOARD_GetNumPlayers( void ); ULONG SCOREBOARD_GetRank( void ); LONG SCOREBOARD_GetSpread( void ); LONG SCOREBOARD_GetLeftToLimit( void );