Skip to content

Commit b46cefb

Browse files
Make Killfeed use the Assisters team color if applicable instead of always using the Killers team color
ValveSoftware#1506
1 parent cc2e0ff commit b46cefb

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

src/game/client/tf/hud_basedeathnotice.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,22 @@ void CHudBaseDeathNotice::Paint()
151151

152152
wchar_t victim[256]=L"";
153153
wchar_t killer[256]=L"";
154+
wchar_t assister[256] = L"";
154155

156+
const wchar_t* plus = L"+";
155157
// TEMP - print the death icon name if we don't have a material for it
156158

157159
g_pVGuiLocalize->ConvertANSIToUnicode( msg.Victim.szName, victim, sizeof( victim ) );
158160
g_pVGuiLocalize->ConvertANSIToUnicode( msg.Killer.szName, killer, sizeof( killer ) );
161+
g_pVGuiLocalize->ConvertANSIToUnicode( msg.Assister.szName, assister, sizeof( assister ) );
159162

160163
int iVictimTextWide = UTIL_ComputeStringWidth( m_hTextFont, victim ) + xSpacing;
161164
int iDeathInfoTextWide= msg.wzInfoText[0] ? UTIL_ComputeStringWidth( m_hTextFont, msg.wzInfoText ) + xSpacing : 0;
162165
int iDeathInfoEndTextWide= msg.wzInfoTextEnd[0] ? UTIL_ComputeStringWidth( m_hTextFont, msg.wzInfoTextEnd ) + xSpacing : 0;
163166

164167
int iKillerTextWide = killer[0] ? UTIL_ComputeStringWidth( m_hTextFont, killer ) + xSpacing : 0;
168+
int iAssisterTextWide = assister[0] ? UTIL_ComputeStringWidth( m_hTextFont, assister ) + xSpacing : 0;
169+
int iPlusTextWide = assister[0] ? UTIL_ComputeStringWidth( m_hTextFont, plus ) + xSpacing : 0;
165170
int iLineTall = m_flLineHeight;
166171
int iTextTall = surface()->GetFontTall( m_hTextFont );
167172
int iconWide = 0, iconTall = 0, iDeathInfoOffset = 0, iVictimTextOffset = 0, iconActualWide = 0;
@@ -234,7 +239,7 @@ void CHudBaseDeathNotice::Paint()
234239
iconPostVictimWide *= flScale;
235240
}
236241

237-
int iTotalWide = iKillerTextWide + iconWide + iVictimTextWide + iDeathInfoTextWide + iDeathInfoEndTextWide + ( xMargin * 2 );
242+
int iTotalWide = iKillerTextWide + iPlusTextWide + iAssisterTextWide + iconWide + iVictimTextWide + iDeathInfoTextWide + iDeathInfoEndTextWide + (xMargin * 2);
238243
iTotalWide += iconPrekillerWide + iconPostkillerWide + iPreKillerTextWide + iconPostVictimWide;
239244

240245
int y = yStart + ( ( iLineTall + m_flLineSpacing ) * i );
@@ -270,7 +275,13 @@ void CHudBaseDeathNotice::Paint()
270275
DrawText( x, yText, m_hTextFont, GetTeamColor( msg.Killer.iTeam, msg.bLocalPlayerInvolved ), killer );
271276
x += iKillerTextWide;
272277
}
273-
278+
if ( assister[0] )
279+
{
280+
DrawText( x, yText, m_hTextFont, GetTeamColor( msg.Killer.iTeam == msg.Assister.iTeam ? msg.Assister.iTeam : TEAM_UNASSIGNED, msg.bLocalPlayerInvolved ), plus );
281+
x += iPlusTextWide;
282+
DrawText( x, yText, m_hTextFont, GetTeamColor( msg.Assister.iTeam, msg.bLocalPlayerInvolved ), assister );
283+
x += iAssisterTextWide;
284+
}
274285
// prekiller text
275286
if ( msg.wzPreKillerText[0] )
276287
{

src/game/client/tf/hud_basedeathnotice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct DeathNoticeItem
5454

5555
DeathNoticePlayer Killer;
5656
DeathNoticePlayer Victim;
57+
DeathNoticePlayer Assister;
5758
char szIcon[32]; // name of icon to display
5859
wchar_t wzInfoText[32]; // any additional text to display next to icon
5960
wchar_t wzInfoTextEnd[32]; // any additional text to display next to victim name

src/game/client/tf/tf_hud_deathnotice.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -866,12 +866,13 @@ void CTFHudDeathNotice::OnGameEvent( IGameEvent *event, int iDeathNoticeMsg )
866866
if ( pszAssisterName && (ePyroVisionHack == kHorriblePyroVisionHack_KillAssisterType_CustomName_First ||
867867
ePyroVisionHack == kHorriblePyroVisionHack_KillAssisterType_LocalizationString_First) )
868868
{
869-
std::swap( pszKillerName, pszAssisterName );
869+
Q_strncpy(msg.Killer.szName, pszAssisterName, ARRAYSIZE(msg.Killer.szName));
870+
pszAssisterName = pszKillerName;
870871
}
871872

872-
char szKillerBuf[MAX_PLAYER_NAME_LENGTH*2];
873-
Q_snprintf( szKillerBuf, ARRAYSIZE(szKillerBuf), "%s + %s", pszKillerName, pszAssisterName );
874-
Q_strncpy( msg.Killer.szName, szKillerBuf, ARRAYSIZE( msg.Killer.szName ) );
873+
msg.Assister.iTeam = (iAssisterID > 0 ? g_PR->GetTeam(iAssisterID) : msg.Killer.iTeam);
874+
Q_strncpy(msg.Assister.szName, pszAssisterName, ARRAYSIZE(msg.Assister.szName));
875+
875876
if ( iLocalPlayerIndex == iAssisterID )
876877
{
877878
msg.bLocalPlayerInvolved = true;
@@ -1307,9 +1308,8 @@ void CTFHudDeathNotice::OnGameEvent( IGameEvent *event, int iDeathNoticeMsg )
13071308
const char *assister_name = ( iAssisterID > 0 ? g_PR->GetPlayerName( iAssisterID ) : NULL );
13081309
if ( assister_name )
13091310
{
1310-
char szKillerBuf[MAX_PLAYER_NAME_LENGTH*2];
1311-
Q_snprintf( szKillerBuf, ARRAYSIZE(szKillerBuf), "%s + %s", msg.Killer.szName, assister_name );
1312-
Q_strncpy( msg.Killer.szName, szKillerBuf, ARRAYSIZE( msg.Killer.szName ) );
1311+
msg.Assister.iTeam = g_PR->GetTeam(iAssisterID);
1312+
Q_strncpy(msg.Assister.szName, assister_name, ARRAYSIZE(msg.Assister.szName));
13131313
}
13141314
}
13151315
//else if ( FStrEq( "throwable_hit", pszEventName ) )

0 commit comments

Comments
 (0)