Révision | ab01759a332d40b16c467246cbed2f9491da7a5b (tree) |
---|---|
l'heure | 2023-02-05 00:00:50 |
Auteur | Adam Kaminski <kaminskiadam9@gmai...> |
Commiter | Adam Kaminski |
Fixed the DONTSEPARATETEAMS flag not being handled properly.
@@ -1924,8 +1924,8 @@ | ||
1924 | 1924 | { |
1925 | 1925 | int result = 0; |
1926 | 1926 | |
1927 | - // [AK] Sanity check: make sure that we're pointing to a rank order. | |
1928 | - if ( pRankOrder == NULL ) | |
1927 | + // [AK] Sanity check: make sure that we're pointing to a scoreboard. | |
1928 | + if ( pScoreboard == NULL ) | |
1929 | 1929 | return false; |
1930 | 1930 | |
1931 | 1931 | // [AK] Always return false if the first player index is invalid, |
@@ -1944,7 +1944,7 @@ | ||
1944 | 1944 | |
1945 | 1945 | // [AK] In team-based game modes, order players by team. Players with lower |
1946 | 1946 | // team indices should come before those with higher indices. |
1947 | - if ( GAMEMODE_GetCurrentFlags( ) & GMF_PLAYERSONTEAMS ) | |
1947 | + if ( pScoreboard->ShouldSeparateTeams( )) | |
1948 | 1948 | { |
1949 | 1949 | result = players[arg1].Team - players[arg2].Team; |
1950 | 1950 |
@@ -1952,13 +1952,13 @@ | ||
1952 | 1952 | return ( result < 0 ); |
1953 | 1953 | } |
1954 | 1954 | |
1955 | - for ( unsigned int i = 0; i < pRankOrder->Size( ); i++ ) | |
1955 | + for ( unsigned int i = 0; i < pScoreboard->RankOrder.Size( ); i++ ) | |
1956 | 1956 | { |
1957 | - if (( *pRankOrder )[i]->IsDisabled( )) | |
1957 | + if ( pScoreboard->RankOrder[i]->IsDisabled( )) | |
1958 | 1958 | continue; |
1959 | 1959 | |
1960 | - const ColumnValue Value1 = ( *pRankOrder )[i]->GetValue( arg1 ); | |
1961 | - const ColumnValue Value2 = ( *pRankOrder )[i]->GetValue( arg2 ); | |
1960 | + const ColumnValue Value1 = pScoreboard->RankOrder[i]->GetValue( arg1 ); | |
1961 | + const ColumnValue Value2 = pScoreboard->RankOrder[i]->GetValue( arg2 ); | |
1962 | 1962 | |
1963 | 1963 | // [AK] Always return false if the data type of the first value is unknown. |
1964 | 1964 | // This is also the case when both values have unknown data types. |
@@ -2001,7 +2001,7 @@ | ||
2001 | 2001 | |
2002 | 2002 | // [AK] If the values for this column aren't the same for both players, return the result. |
2003 | 2003 | if ( result != 0 ) |
2004 | - return (( *pRankOrder )[i]->GetFlags( ) & COLUMNFLAG_REVERSEORDER ) ? ( result < 0 ) : ( result > 0 ); | |
2004 | + return ( pScoreboard->RankOrder[i]->GetFlags( ) & COLUMNFLAG_REVERSEORDER ) ? ( result < 0 ) : ( result > 0 ); | |
2005 | 2005 | } |
2006 | 2006 | |
2007 | 2007 | return false; |
@@ -2053,7 +2053,7 @@ | ||
2053 | 2053 | for ( ULONG ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ ) |
2054 | 2054 | ulPlayerList[ulIdx] = ulIdx; |
2055 | 2055 | |
2056 | - std::stable_sort( ulPlayerList, ulPlayerList + MAXPLAYERS, PlayerComparator( &RankOrder )); | |
2056 | + std::stable_sort( ulPlayerList, ulPlayerList + MAXPLAYERS, PlayerComparator( this )); | |
2057 | 2057 | } |
2058 | 2058 | |
2059 | 2059 | //***************************************************************************** |
@@ -2138,7 +2138,7 @@ | ||
2138 | 2138 | // [AK] Add the total height of all rows for active players. |
2139 | 2139 | if ( ulNumActivePlayers > 0 ) |
2140 | 2140 | { |
2141 | - if (( GAMEMODE_GetCurrentFlags( ) & GMF_PLAYERSONTEAMS ) && (( ulFlags & SCOREBOARDFLAG_DONTSEPARATETEAMS ) == false )) | |
2141 | + if ( ShouldSeparateTeams( )) | |
2142 | 2142 | { |
2143 | 2143 | for ( ULONG ulTeam = 0; ulTeam < teams.Size( ); ulTeam++ ) |
2144 | 2144 | { |
@@ -2219,7 +2219,7 @@ | ||
2219 | 2219 | |
2220 | 2220 | // [AK] In team-based game modes, if the previous player is on a different team than |
2221 | 2221 | // the current player, leave a gap between both teams and make the row background light. |
2222 | - if (( GAMEMODE_GetCurrentFlags( ) & GMF_PLAYERSONTEAMS ) && ( ulIdx > 0 ) && ( players[ulPlayer].Team != players[ulPlayerList[ulIdx - 1]].Team )) | |
2222 | + if (( ShouldSeparateTeams( )) && ( ulIdx > 0 ) && ( players[ulPlayer].Team != players[ulPlayerList[ulIdx - 1]].Team )) | |
2223 | 2223 | { |
2224 | 2224 | lYPos += lRowHeight; |
2225 | 2225 | bUseLightBackground = true; |
@@ -2449,6 +2449,19 @@ | ||
2449 | 2449 | |
2450 | 2450 | //***************************************************************************** |
2451 | 2451 | // |
2452 | +// [AK] Scoreboard::ShouldSeparateTeams | |
2453 | +// | |
2454 | +// Checks if the scoreboard should separate players into their respective teams. | |
2455 | +// | |
2456 | +//***************************************************************************** | |
2457 | + | |
2458 | +bool Scoreboard::ShouldSeparateTeams( void ) const | |
2459 | +{ | |
2460 | + return (( GAMEMODE_GetCurrentFlags( ) & GMF_PLAYERSONTEAMS ) && (( ulFlags & SCOREBOARDFLAG_DONTSEPARATETEAMS ) == false )); | |
2461 | +} | |
2462 | + | |
2463 | +//***************************************************************************** | |
2464 | +// | |
2452 | 2465 | // [AK] SCOREBOARD_GetColumn |
2453 | 2466 | // |
2454 | 2467 | // Returns a pointer to a column by searching for its name. |
@@ -392,14 +392,15 @@ | ||
392 | 392 | void DrawBorder( const EColorRange Color, LONG &lYPos, const bool bReverse ) const; |
393 | 393 | void DrawRowBackground( const PalEntry color, int x, int y, int width, int height, const float fAlpha ) const; |
394 | 394 | void DrawRowBackground( const PalEntry color, const int y, const float fAlpha ) const; |
395 | + bool ShouldSeparateTeams( void ) const; | |
395 | 396 | |
396 | 397 | private: |
397 | 398 | struct PlayerComparator |
398 | 399 | { |
399 | - PlayerComparator( TArray<DataScoreColumn *> *pList ) : pRankOrder( pList ) { } | |
400 | + PlayerComparator( Scoreboard *pOtherScoreboard ) : pScoreboard( pOtherScoreboard ) { } | |
400 | 401 | bool operator( )( const int &arg1, const int &arg2 ) const; |
401 | 402 | |
402 | - const TArray<DataScoreColumn *> *pRankOrder; | |
403 | + const Scoreboard *pScoreboard; | |
403 | 404 | }; |
404 | 405 | |
405 | 406 | ULONG ulPlayerList[MAXPLAYERS]; |