From 55a1e89af53ce91cd9ea316b49235c672376ebb7 Mon Sep 17 00:00:00 2001 From: Sam V Date: Mon, 29 Nov 2021 20:47:47 +0100 Subject: [PATCH] Fix CTalkMonster::RunTask not properly initializing variable Resolves ValveSoftware/halflife#3177 --- dlls/talkmonster.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/dlls/talkmonster.cpp b/dlls/talkmonster.cpp index dedea259a..a5fb6c53f 100644 --- a/dlls/talkmonster.cpp +++ b/dlls/talkmonster.cpp @@ -476,22 +476,17 @@ void CTalkMonster::RunTask(Task_t* pTask) switch (pTask->iTask) { case TASK_TLK_CLIENT_STARE: - case TASK_TLK_LOOK_AT_CLIENT: - - edict_t* pPlayer; + case TASK_TLK_LOOK_AT_CLIENT: { + // Get edict for one player + edict_t* pPlayer = g_engfuncs.pfnPEntityOfEntIndex(1); // track head to the client for a while. - if (m_MonsterState == MONSTERSTATE_IDLE && + if (pPlayer && + m_MonsterState == MONSTERSTATE_IDLE && !IsMoving() && !IsTalking()) { - // Get edict for one player - pPlayer = g_engfuncs.pfnPEntityOfEntIndex(1); - - if (pPlayer) - { - IdleHeadTurn(pPlayer->v.origin); - } + IdleHeadTurn(pPlayer->v.origin); } else { @@ -522,6 +517,7 @@ void CTalkMonster::RunTask(Task_t* pTask) TaskComplete(); } break; + } case TASK_FACE_PLAYER: { // Get edict for one player