@@ -84,12 +84,18 @@ CTask* CTaskSA::GetSubTask()
8484{
8585 static CTaskManagementSystemSA* s_pTaskManagementSystem = pGame->GetTaskManagementSystem ();
8686
87- DWORD dwThisInterface = (DWORD)GetInterface ();
88- DWORD dwFunc = GetInterface ()->VTBL ->GetSubTask ;
87+ CTaskSAInterface* pTaskInterface = GetInterface ();
88+ if (!pTaskInterface)
89+ return nullptr ;
90+
91+ DWORD dwFunc = pTaskInterface->VTBL ->GetSubTask ;
92+ if (!dwFunc || dwFunc == 0x82263A )
93+ return nullptr ;
94+
8995 DWORD dwReturn = 0 ;
9096 _asm
9197 {
92- mov ecx, dwThisInterface
98+ mov ecx, pTaskInterface
9399 call dwFunc
94100 mov dwReturn, eax
95101 }
@@ -326,21 +332,24 @@ CTask* CTaskComplexSA::CreateNextSubTask(CPed* pPed)
326332{
327333 CPedSA* pPedSA = dynamic_cast <CPedSA*>(pPed);
328334 if (!pPedSA)
329- return NULL ;
335+ return nullptr ;
336+
337+ CTaskSAInterface* pTaskInterface = GetInterface ();
338+ if (!pTaskInterface)
339+ return nullptr ;
340+
341+ DWORD dwFunc = ((TaskComplexVTBL*)pTaskInterface->VTBL )->CreateNextSubTask ;
342+ if (!dwFunc || dwFunc == 0x82263A )
343+ return nullptr ;
330344
331345 DWORD dwPedInterface = (DWORD)pPedSA->GetInterface ();
332- DWORD dwThisInterface = (DWORD)GetInterface ();
333- DWORD dwFunc = ((TaskComplexVTBL*)GetInterface ()->VTBL )->CreateNextSubTask ;
334346 DWORD dwReturn = 0 ;
335- if (dwFunc != 0x82263A && dwFunc)
347+ _asm
336348 {
337- _asm
338- {
339- mov ecx, dwThisInterface
340- push dwPedInterface
341- call dwFunc
342- mov dwReturn, eax
343- }
349+ mov ecx, pTaskInterface
350+ push dwPedInterface
351+ call dwFunc
352+ mov dwReturn, eax
344353 }
345354 return pGame->GetTaskManagementSystem ()->GetTask ((CTaskSAInterface*)dwReturn);
346355}
@@ -349,21 +358,24 @@ CTask* CTaskComplexSA::CreateFirstSubTask(CPed* pPed)
349358{
350359 CPedSA* pPedSA = dynamic_cast <CPedSA*>(pPed);
351360 if (!pPedSA)
352- return NULL ;
361+ return nullptr ;
362+
363+ CTaskSAInterface* pTaskInterface = GetInterface ();
364+ if (!pTaskInterface)
365+ return nullptr ;
366+
367+ DWORD dwFunc = ((TaskComplexVTBL*)pTaskInterface->VTBL )->CreateFirstSubTask ;
368+ if (!dwFunc || dwFunc == 0x82263A )
369+ return nullptr ;
353370
354371 DWORD dwPedInterface = (DWORD)pPedSA->GetInterface ();
355- DWORD dwThisInterface = (DWORD)GetInterface ();
356- DWORD dwFunc = ((TaskComplexVTBL*)GetInterface ()->VTBL )->CreateFirstSubTask ;
357372 DWORD dwReturn = 0 ;
358- if (dwFunc != 0x82263A && dwFunc)
373+ _asm
359374 {
360- _asm
361- {
362- mov ecx, dwThisInterface
363- push dwPedInterface
364- call dwFunc
365- mov dwReturn, eax
366- }
375+ mov ecx, pTaskInterface
376+ push dwPedInterface
377+ call dwFunc
378+ mov dwReturn, eax
367379 }
368380 return pGame->GetTaskManagementSystem ()->GetTask ((CTaskSAInterface*)dwReturn);
369381}
@@ -372,21 +384,24 @@ CTask* CTaskComplexSA::ControlSubTask(CPed* pPed)
372384{
373385 CPedSA* pPedSA = dynamic_cast <CPedSA*>(pPed);
374386 if (!pPedSA)
375- return NULL ;
387+ return nullptr ;
388+
389+ CTaskSAInterface* pTaskInterface = GetInterface ();
390+ if (!pTaskInterface)
391+ return nullptr ;
392+
393+ DWORD dwFunc = ((TaskComplexVTBL*)pTaskInterface->VTBL )->ControlSubTask ;
394+ if (!dwFunc || dwFunc == 0x82263A )
395+ return nullptr ;
376396
377397 DWORD dwPedInterface = (DWORD)pPedSA->GetInterface ();
378- DWORD dwThisInterface = (DWORD)GetInterface ();
379- DWORD dwFunc = ((TaskComplexVTBL*)GetInterface ()->VTBL )->ControlSubTask ;
380398 DWORD dwReturn = 0 ;
381- if (dwFunc != 0x82263A && dwFunc)
399+ _asm
382400 {
383- _asm
384- {
385- mov ecx, dwThisInterface
386- push dwPedInterface
387- call dwFunc
388- mov dwReturn, eax
389- }
401+ mov ecx, pTaskInterface
402+ push dwPedInterface
403+ call dwFunc
404+ mov dwReturn, eax
390405 }
391406 return pGame->GetTaskManagementSystem ()->GetTask ((CTaskSAInterface*)dwReturn);
392407}
0 commit comments