Skip to content
Permalink
Browse files

Add null pointer check in CClientPed::SetDoingGangDriveby

GetOccupiedVehicle() returned a null pointer
  • Loading branch information...
botder committed Sep 6, 2019
1 parent f08c645 commit 8c8c1fdd40d8d41df20a628ece7ec33b4bc208f1
Showing with 39 additions and 37 deletions.
  1. +39 −37 Client/mods/deathmatch/logic/CClientPed.cpp
@@ -5584,52 +5584,54 @@ bool CClientPed::IsDoingGangDriveby()

void CClientPed::SetDoingGangDriveby(bool bDriveby)
{
if (m_pPlayerPed)
m_bDoingGangDriveby = bDriveby;

if (!m_pPlayerPed)
return;

CTask* primaryTask = m_pTaskManager->GetTask(TASK_PRIORITY_PRIMARY);

if (primaryTask && primaryTask->GetTaskType() == TASK_SIMPLE_GANG_DRIVEBY)
{
CTask* pTask = m_pTaskManager->GetTask(TASK_PRIORITY_PRIMARY);
if (pTask && pTask->GetTaskType() == TASK_SIMPLE_GANG_DRIVEBY)
if (!bDriveby)
{
if (!bDriveby)
{
pTask->MakeAbortable(m_pPlayerPed, ABORT_PRIORITY_URGENT, NULL);
}
primaryTask->MakeAbortable(m_pPlayerPed, ABORT_PRIORITY_URGENT, NULL);
}
else if (bDriveby)
{
char cSeat = GetOccupiedVehicleSeat();
bool bRight = (cSeat % 2 != 0);
CTask* pTask = g_pGame->GetTasks()->CreateTaskSimpleGangDriveBy(NULL, NULL, 0.0f, 0, 0, bRight);
if (pTask)
{
pTask->SetAsPedTask(m_pPlayerPed, TASK_PRIORITY_PRIMARY);
}
}
else if (bDriveby)
{
unsigned int seat = GetOccupiedVehicleSeat();
bool bRight = (seat % 2 != 0);

char cWindow = -1;
switch (cSeat)
{
case 0:
cWindow = WINDOW_LEFT_FRONT;
break;
if (CTask* task = g_pGame->GetTasks()->CreateTaskSimpleGangDriveBy(NULL, NULL, 0.0f, 0, 0, bRight); task != nullptr)
{
task->SetAsPedTask(m_pPlayerPed, TASK_PRIORITY_PRIMARY);
}

case 1:
cWindow = WINDOW_RIGHT_FRONT;
break;
uchar ucWindow = -1;

case 2:
cWindow = WINDOW_LEFT_BACK;
break;
switch (seat)
{
case 0:
ucWindow = WINDOW_LEFT_FRONT;
break;
case 1:
ucWindow = WINDOW_RIGHT_FRONT;
break;
case 2:
ucWindow = WINDOW_LEFT_BACK;
break;
case 3:
ucWindow = WINDOW_RIGHT_BACK;
break;
}

case 3:
cWindow = WINDOW_RIGHT_BACK;
break;
}
if (cWindow != -1)
{
GetOccupiedVehicle()->SetWindowOpen(cWindow, true);
}
if (ucWindow != -1)
{
if (CClientVehicle* vehicle = GetOccupiedVehicle(); vehicle != nullptr)
vehicle->SetWindowOpen(ucWindow, true);
}
}
m_bDoingGangDriveby = bDriveby;
}

bool CClientPed::IsRunningAnimation()

0 comments on commit 8c8c1fd

Please sign in to comment.
You can’t perform that action at this time.