# HG changeset patch # User Adam Kaminski # Date 1621856251 14400 # Mon May 24 07:37:31 2021 -0400 # Node ID e42ce7f3d3724fb13e5a1f88733102e1800da0b7 # Parent 6d5b0271c473ea6f58d0e8fc82ddfe4b8ae4220f Add the word "and" before the name of the last team on the list of teams who have the highest score when building the point string. diff -r 6d5b0271c473 -r e42ce7f3d372 src/scoreboard.cpp --- a/src/scoreboard.cpp Mon May 24 00:07:45 2021 -0400 +++ b/src/scoreboard.cpp Mon May 24 07:37:31 2021 -0400 @@ -274,6 +274,7 @@ LONG lLowestScore = LONG_MAX; FString scoreName, teamName; + FString lastTeamName; LONG (*scoreFunction)( ULONG ); // [AK] Determine what kind of score we are interested in (wins, points, frags). @@ -316,7 +317,13 @@ // [AK] If this team's score is equal to the current highest score, add their name to the end of the list. else if (( lTeamScore == lHighestScore ) && ( ulNumTeamsWithHighestScore > 0 )) { - teamName.AppendFormat( TEXTCOLOR_NORMAL ", \\c%c%s", V_GetColorChar( TEAM_GetTextColor( ulTeam )), TEAM_GetName( ulTeam )); + // [AK] If there's more than two teams with the highest score, add a comma and the + // name of the team we got last. + if (( ulNumTeamsWithHighestScore >= 2 ) && ( lastTeamName.IsNotEmpty( ))) + teamName.AppendFormat( TEXTCOLOR_NORMAL ", %s", lastTeamName.GetChars( )); + + // [AK] Store this team's name and text color into a string, we'll need it later. + lastTeamName.Format( "\\c%c%s", V_GetColorChar( TEAM_GetTextColor( ulTeam )), TEAM_GetName( ulTeam )); ulNumTeamsWithHighestScore++; } @@ -338,9 +345,18 @@ if ( ulNumAvailableTeams > 2 ) { if ( ulNumTeamsWithHighestScore == 1 ) + { message.Format( "%s" TEXTCOLOR_NORMAL " %s with %d %s", teamName.GetChars( ), gamestate == GS_LEVEL ? "leads" : "has won", static_cast( lHighestScore ), scoreName.GetChars( )); + } else + { + // [AK] Add the word "and" before the name of the last team on the list, preceeded by a comma if + // there's more than two teams with the highest score. + if ( lastTeamName.IsNotEmpty( )) + teamName.AppendFormat( TEXTCOLOR_NORMAL "%s and %s", ulNumTeamsWithHighestScore > 2 ? "," : "", lastTeamName.GetChars( )); + message.Format( "Teams %s with %d %s: %s", gamestate == GS_LEVEL ? "leading" : "that won", static_cast( lHighestScore ), scoreName.GetChars( ), teamName.GetChars( )); + } } else {