diff --git a/dlls/CBasePlayer.cpp b/dlls/CBasePlayer.cpp index bcbd894e..efac7be2 100644 --- a/dlls/CBasePlayer.cpp +++ b/dlls/CBasePlayer.cpp @@ -2204,10 +2204,11 @@ void CBasePlayer::UpdateStatusBar() } } - if ((!fakePlayerInfo.enabled && tempNameActive) || tempNameActive >= 2) { + if (tempNameActive >= 10) { // have a to wait a bit before resetting the player name and color because // the client doesn't parse the new status bar text until its next rendering frame. - // This can fail if the client fps is less than 10 (or whatever speed this func is called). + // With packet loss and lag, this message can arrive at the same time the status bar + // was last updated, causing the player name to show instead of the npc name. tempNameActive = 0; Rename(STRING(pev->netname), false, MSG_ONE, edict()); UpdateTeamInfo(-1, MSG_ONE, edict()); @@ -5552,12 +5553,16 @@ void CBasePlayer::UpdateScore() { } void CBasePlayer::UpdateTeamInfo(int color, int msg_mode, edict_t* dst) { + if (color == -1) { + color = tempNameActive ? m_tempTeam : GetNameColor(); + } + MESSAGE_BEGIN(msg_mode, gmsgScoreInfo, 0, dst); WRITE_BYTE(entindex()); // client number WRITE_SHORT(pev->frags); WRITE_SHORT(m_iDeaths); WRITE_SHORT(0); - WRITE_SHORT(color == -1 ? GetNameColor() : color); + WRITE_SHORT(color); MESSAGE_END(); MESSAGE_BEGIN(msg_mode, gmsgTeamInfo, 0, dst); diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index d439310e..6085e876 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -910,7 +910,7 @@ void CHalfLifeMultiplay::DeathNotice( CBaseMonster *pVictim, entvars_t *pKiller, CBasePlayer* plr = (CBasePlayer*)pVictim; if (plr->tempNameActive && plr != hackedPlayer1 && plr != hackedPlayer2) { plr->Rename(STRING(plr->pev->netname), true, MSG_ONE, plr->edict()); - plr->UpdateTeamInfo(-1, MSG_ONE, plr->edict()); + plr->UpdateTeamInfo(plr->GetNameColor(), MSG_ONE, plr->edict()); } } if (Killer->IsPlayer()) { @@ -918,7 +918,7 @@ void CHalfLifeMultiplay::DeathNotice( CBaseMonster *pVictim, entvars_t *pKiller, if (plr->tempNameActive && plr != hackedPlayer1 && plr != hackedPlayer2) { if (!originalKillerName) plr->Rename(STRING(plr->pev->netname), true, MSG_ONE, plr->edict()); - plr->UpdateTeamInfo(-1, MSG_ONE, plr->edict()); + plr->UpdateTeamInfo(plr->GetNameColor(), MSG_ONE, plr->edict()); } }