From 7d418511bb6e45950842da1d20019d87f3ec021b Mon Sep 17 00:00:00 2001 From: ScriptedSnark <51358194+ScriptedSnark@users.noreply.github.com> Date: Sat, 28 Sep 2024 19:34:58 +0500 Subject: [PATCH] Client: fix GetThisPlayerInfo crash --- src/game/client/hud/chat.cpp | 2 +- src/game/client/hud/death_notice_panel.cpp | 6 ++++++ src/game/client/vgui/score_panel.cpp | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/game/client/hud/chat.cpp b/src/game/client/hud/chat.cpp index 920b520d..d234272e 100644 --- a/src/game/client/hud/chat.cpp +++ b/src/game/client/hud/chat.cpp @@ -1279,7 +1279,7 @@ void CHudChat::ChatPrintf(int iPlayerIndex, const char *fmt, ...) } // If a player is muted for voice, also mute them for text because jerks gonna jerk. - if (cl_mute_all_comms.GetBool() && iPlayerIndex != 0 && iPlayerIndex != GetThisPlayerInfo()->GetIndex()) + if (GetThisPlayerInfo() && cl_mute_all_comms.GetBool() && iPlayerIndex != 0 && iPlayerIndex != GetThisPlayerInfo()->GetIndex()) { if (GetClientVoiceMgr() && GetClientVoiceMgr()->IsPlayerBlocked(iPlayerIndex)) return; diff --git a/src/game/client/hud/death_notice_panel.cpp b/src/game/client/hud/death_notice_panel.cpp index ea521a35..90a2ce0b 100644 --- a/src/game/client/hud/death_notice_panel.cpp +++ b/src/game/client/hud/death_notice_panel.cpp @@ -82,6 +82,12 @@ void CHudDeathNoticePanel::Think() void CHudDeathNoticePanel::AddItem(int killerId, int victimId, const char *killedwith) { + if (!GetThisPlayerInfo()) + { + // Not yet connected + return; + } + Entry e; CPlayerInfo *killer = GetPlayerInfoSafe(killerId); CPlayerInfo *victim = GetPlayerInfoSafe(victimId); diff --git a/src/game/client/vgui/score_panel.cpp b/src/game/client/vgui/score_panel.cpp index 2669d902..472af81f 100644 --- a/src/game/client/vgui/score_panel.cpp +++ b/src/game/client/vgui/score_panel.cpp @@ -209,6 +209,12 @@ void CScorePanel::UpdateOnPlayerInfo(int client) void CScorePanel::DeathMsg(int killer, int victim) { + if (!GetThisPlayerInfo()) + { + // Not yet connected + return; + } + if (victim == GetThisPlayerInfo()->GetIndex()) { // if we were the one killed, set the scoreboard to indicate killer