Skip to content

Commit d237dce

Browse files
committed
Fix gun pointing animation glitch from c55ef42
1 parent 89f0daa commit d237dce

File tree

1 file changed

+9
-36
lines changed

1 file changed

+9
-36
lines changed

Client/multiplayer_sa/multiplayer_shotsync.cpp

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ static void Event_BulletImpact(void)
297297
CPedSAInterface* pAPed = NULL;
298298
float fTempPosX = 0, fTempPosY = 0, fTempPosZ = 0;
299299
CPed* pATargetingPed = NULL;
300-
SClientEntity<CPedSA>* pATargetingPedClient = nullptr;
301300
CVector* pTempVec;
302301
bool* pSkipAim;
303302
CRemoteDataStorageSA* pTempRemote;
@@ -322,6 +321,12 @@ VOID _declspec(naked) HOOK_CTaskSimpleUsegun_ProcessPed()
322321
}
323322
}
324323

324+
static CPed * GetTargetingPed()
325+
{
326+
SClientEntity<CPedSA>* pClientEntity = m_pools->GetPed((DWORD*)pAPed);
327+
return pClientEntity ? pClientEntity->pEntity : nullptr;
328+
}
329+
325330
VOID _declspec(naked) HOOK_SkipAim()
326331
{
327332
// We can use ECX
@@ -338,17 +343,7 @@ VOID _declspec(naked) HOOK_SkipAim()
338343
pushad
339344
}
340345

341-
pATargetingPedClient = m_pools->GetPed((DWORD*)pAPed);
342-
if (pATargetingPedClient)
343-
{
344-
// access pEntity member, not using [0] will crash it
345-
pATargetingPed = reinterpret_cast<CPed*>(((DWORD*)pATargetingPedClient)[0]);
346-
}
347-
else
348-
{
349-
pATargetingPed = nullptr;
350-
}
351-
346+
pATargetingPed = GetTargetingPed();
352347
if (pATargetingPed)
353348
{
354349
// If this is the local player
@@ -419,18 +414,7 @@ VOID _declspec(naked) HOOK_IKChainManager_PointArm()
419414
pushad
420415
}
421416

422-
pATargetingPedClient = m_pools->GetPed((DWORD*)pAPed);
423-
424-
if (pATargetingPedClient)
425-
{
426-
// access pEntity member, not using [0] will crash it
427-
pATargetingPed = reinterpret_cast<CPed*>(((DWORD*)pATargetingPedClient)[0]);
428-
}
429-
else
430-
{
431-
pATargetingPed = nullptr;
432-
}
433-
417+
pATargetingPed = GetTargetingPed();
434418
if (pATargetingPed)
435419
{
436420
// If this is the local player
@@ -493,18 +477,7 @@ VOID _declspec(naked) HOOK_IKChainManager_LookAt()
493477
// Jax: this gets called on vehicle collision and pTargetVector is null
494478
if (pTargetVector)
495479
{
496-
pATargetingPedClient = m_pools->GetPed((DWORD*)pAPed);
497-
498-
if (pATargetingPedClient)
499-
{
500-
// access pEntity member, not using [0] will crash it
501-
pATargetingPed = reinterpret_cast<CPed*>(((DWORD*)pATargetingPedClient)[0]);
502-
}
503-
else
504-
{
505-
pATargetingPed = nullptr;
506-
}
507-
480+
pATargetingPed = GetTargetingPed();
508481
if (pATargetingPed)
509482
{
510483
// If this is the local player

0 commit comments

Comments
 (0)