Skip to content

Commit 65ae168

Browse files
committed
Fix restoreTaskOnAnimEnd #947
1 parent 10cd2ed commit 65ae168

File tree

6 files changed

+28
-86
lines changed

6 files changed

+28
-86
lines changed

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ CClientGame::CClientGame(bool bLocalPlay)
263263
g_pMultiplayer->SetAddAnimationAndSyncHandler(CClientGame::StaticAddAnimationAndSyncHandler);
264264
g_pMultiplayer->SetAssocGroupCopyAnimationHandler(CClientGame::StaticAssocGroupCopyAnimationHandler);
265265
g_pMultiplayer->SetBlendAnimationHierarchyHandler(CClientGame::StaticBlendAnimationHierarchyHandler);
266-
g_pMultiplayer->SetBlendAnimationHandler(CClientGame::StaticBlendAnimationHandler);
267266
g_pMultiplayer->SetProcessCollisionHandler(CClientGame::StaticProcessCollisionHandler);
268267
g_pMultiplayer->SetVehicleCollisionHandler(CClientGame::StaticVehicleCollisionHandler);
269268
g_pMultiplayer->SetVehicleDamageHandler(CClientGame::StaticVehicleDamageHandler);
@@ -432,7 +431,6 @@ CClientGame::~CClientGame()
432431
g_pMultiplayer->SetAddAnimationAndSyncHandler(NULL);
433432
g_pMultiplayer->SetAssocGroupCopyAnimationHandler(NULL);
434433
g_pMultiplayer->SetBlendAnimationHierarchyHandler(NULL);
435-
g_pMultiplayer->SetBlendAnimationHandler(nullptr);
436434
g_pMultiplayer->SetProcessCollisionHandler(NULL);
437435
g_pMultiplayer->SetVehicleCollisionHandler(NULL);
438436
g_pMultiplayer->SetVehicleDamageHandler(NULL);
@@ -3697,11 +3695,6 @@ bool CClientGame::StaticBlendAnimationHierarchyHandler(CAnimBlendAssociationSAIn
36973695
return g_pClientGame->BlendAnimationHierarchyHandler(pAnimAssoc, pOutAnimHierarchy, pFlags, pClump);
36983696
}
36993697

3700-
bool CClientGame::StaticBlendAnimationHandler(RpClump* pClump, AssocGroupId animGroup, AnimationId animID, float fBlendData)
3701-
{
3702-
return g_pClientGame->BlendAnimationHandler(pClump, animGroup, animID, fBlendData);
3703-
}
3704-
37053698
void CClientGame::StaticPreWorldProcessHandler()
37063699
{
37073700
g_pClientGame->PreWorldProcessHandler();
@@ -4048,20 +4041,40 @@ bool CClientGame::AssocGroupCopyAnimationHandler(CAnimBlendAssociationSAInterfac
40484041
CClientPed* pClientPed = GetClientPedByClump(*pClump);
40494042
if (pClientPed != nullptr)
40504043
{
4051-
auto pReplacedAnimation = pClientPed->GetReplacedAnimation(pOriginalAnimHierarchyInterface);
4052-
if (pReplacedAnimation != nullptr)
4044+
std::unique_ptr<CAnimBlendHierarchy> pAnimHierarchy = nullptr;
4045+
if (pClientPed->IsTaskToBeRestoredOnAnimEnd() && pClientPed->GetTaskTypeToBeRestoredOnAnimEnd() == TASK_SIMPLE_DUCK)
4046+
{
4047+
// check for idle animation
4048+
if (animID == 3)
4049+
{
4050+
if ((iGroupID == 0) || (iGroupID >= 54 && iGroupID <= 70) || (iGroupID >= 118))
4051+
{
4052+
auto pDuckAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation(0, 55);
4053+
pAnimHierarchy = pAnimationManager->GetCustomAnimBlendHierarchy(pDuckAnimStaticAssoc->GetAnimHierachyInterface());
4054+
isCustomAnimationToPlay = true;
4055+
}
4056+
}
4057+
}
4058+
else
40534059
{
4054-
std::shared_ptr<CIFPAnimations> pIFPAnimations = pReplacedAnimation->pIFP->GetIFPAnimationsPointer();
4055-
InsertAnimationAssociationToMap(pAnimAssocInterface, pIFPAnimations);
4060+
auto pReplacedAnimation = pClientPed->GetReplacedAnimation(pOriginalAnimHierarchyInterface);
4061+
if (pReplacedAnimation != nullptr)
4062+
{
4063+
std::shared_ptr<CIFPAnimations> pIFPAnimations = pReplacedAnimation->pIFP->GetIFPAnimationsPointer();
4064+
InsertAnimationAssociationToMap(pAnimAssocInterface, pIFPAnimations);
40564065

4057-
// Play our custom animation instead of default
4058-
auto pAnimHierarchy = pAnimationManager->GetCustomAnimBlendHierarchy(pReplacedAnimation->pAnimationHierarchy);
4066+
// Play our custom animation instead of default
4067+
pAnimHierarchy = pAnimationManager->GetCustomAnimBlendHierarchy(pReplacedAnimation->pAnimationHierarchy);
4068+
isCustomAnimationToPlay = true;
4069+
}
4070+
}
4071+
if (isCustomAnimationToPlay)
4072+
{
40594073
pAnimationManager->UncompressAnimation(pAnimHierarchy.get());
40604074
pAnimAssociation->InitializeForCustomAnimation(pClump, pAnimHierarchy->GetInterface());
40614075
pAnimAssociation->SetFlags(pOriginalAnimStaticAssoc->GetFlags());
40624076
pAnimAssociation->SetAnimID(pOriginalAnimStaticAssoc->GetAnimID());
40634077
pAnimAssociation->SetAnimGroup(pOriginalAnimStaticAssoc->GetAnimGroup());
4064-
isCustomAnimationToPlay = true;
40654078
}
40664079
}
40674080

@@ -4116,26 +4129,6 @@ bool CClientGame::BlendAnimationHierarchyHandler(CAnimBlendAssociationSAInterfac
41164129
return isCustomAnimationToPlay;
41174130
}
41184131

4119-
bool CClientGame::BlendAnimationHandler(RpClump* pClump, AssocGroupId animGroup, AnimationId animID, float fBlendData)
4120-
{
4121-
CClientPed* pClientPed = GetClientPedByClump(*pClump);
4122-
if (pClientPed != nullptr)
4123-
{
4124-
if (pClientPed->IsTaskToBeRestoredOnAnimEnd() && pClientPed->GetTaskTypeToBeRestoredOnAnimEnd() == TASK_SIMPLE_DUCK)
4125-
{
4126-
// check for idle animation
4127-
if (animID == 3)
4128-
{
4129-
if ((animGroup == 0) || (animGroup >= 54 && animGroup <= 70) || (animGroup >= 118))
4130-
{
4131-
return false;
4132-
}
4133-
}
4134-
}
4135-
}
4136-
return true;
4137-
}
4138-
41394132
bool CClientGame::ProcessCollisionHandler(CEntitySAInterface* pThisInterface, CEntitySAInterface* pOtherInterface)
41404133
{
41414134
if (pThisInterface == pOtherInterface)

Client/mods/deathmatch/logic/CClientGame.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,6 @@ class CClientGame
507507
CAnimBlendAssocGroupSAInterface* pAnimAssocGroup, AnimationId animID);
508508
static bool StaticBlendAnimationHierarchyHandler(CAnimBlendAssociationSAInterface* pAnimAssoc, CAnimBlendHierarchySAInterface** pOutAnimHierarchy,
509509
int* pFlags, RpClump* pClump);
510-
static bool StaticBlendAnimationHandler(RpClump* pClump, AssocGroupId animGroup, AnimationId animID, float fBlendData);
511510
static bool StaticProcessCollisionHandler(CEntitySAInterface* pThisInterface, CEntitySAInterface* pOtherInterface);
512511
static bool StaticVehicleCollisionHandler(CVehicleSAInterface*& pThisInterface, CEntitySAInterface* pOtherInterface, int iModelIndex,
513512
float fDamageImpulseMag, float fCollidingDamageImpulseMag, uint16 usPieceType, CVector vecCollisionPos,
@@ -552,7 +551,6 @@ class CClientGame
552551
AnimationId animID);
553552
bool BlendAnimationHierarchyHandler(CAnimBlendAssociationSAInterface* pAnimAssoc, CAnimBlendHierarchySAInterface** pOutAnimHierarchy, int* pFlags,
554553
RpClump* pClump);
555-
bool BlendAnimationHandler(RpClump* pClump, AssocGroupId animGroup, AnimationId animID, float fBlendData);
556554
bool ProcessCollisionHandler(CEntitySAInterface* pThisInterface, CEntitySAInterface* pOtherInterface);
557555
bool VehicleCollisionHandler(CVehicleSAInterface*& pCollidingVehicle, CEntitySAInterface* pCollidedVehicle, int iModelIndex, float fDamageImpulseMag,
558556
float fCollidingDamageImpulseMag, uint16 usPieceType, CVector vecCollisionPos, CVector vecCollisionVelocity);

Client/mods/deathmatch/logic/rpc/CPedRPCs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ void CPedRPCs::SetPedAnimation(CClientEntity* pSource, NetBitStreamInterface& bi
274274
{
275275
pPed->RunNamedAnimation(pBlock, animName.c_str(), iTime, iBlend, bLoop, bUpdatePosition, bInterruptable, bFreezeLastFrame);
276276
pPed->SetTaskToBeRestoredOnAnimEnd(bTaskToBeRestoredOnAnimEnd);
277+
pPed->SetTaskTypeToBeRestoredOnAnimEnd((eTaskType)TASK_SIMPLE_DUCK);
277278
}
278279
}
279280
}

Client/multiplayer_sa/CMultiplayerSA.cpp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@ DWORD RETURN_CEventHandler_ComputeKnockOffBikeResponse = 0x4BA076;
152152
#define HOOKPOS_CAnimManager_AddAnimationAndSync 0x4D3B30
153153
#define HOOKPOS_CAnimManager_BlendAnimation_Hierarchy 0x4D453E
154154

155-
#define HOOKPOS_CAnimManager_BlendAnimation 0x4D4610
156-
DWORD RETURN_CAnimManager_BlendAnimation = 0x4D4617;
157-
158155
#define HOOKPOS_CPed_GetWeaponSkill 0x5e3b60
159156
DWORD RETURN_CPed_GetWeaponSkill = 0x5E3B68;
160157

@@ -354,7 +351,6 @@ ObjectDamageHandler* m_pObjectDamageHandler = NULL;
354351
ObjectBreakHandler* m_pObjectBreakHandler = NULL;
355352
FxSystemDestructionHandler* m_pFxSystemDestructionHandler = NULL;
356353
DrivebyAnimationHandler* m_pDrivebyAnimationHandler = NULL;
357-
BlendAnimationHandler* m_pBlendAnimationHandler = nullptr;
358354

359355
CEntitySAInterface* dwSavedPlayerPointer = 0;
360356
CEntitySAInterface* activeEntityForStreaming = 0; // the entity that the streaming system considers active
@@ -417,7 +413,6 @@ void HOOK_CAnimBlendAssoc_destructor();
417413
void HOOK_CAnimManager_AddAnimation();
418414
void HOOK_CAnimManager_AddAnimationAndSync();
419415
void HOOK_CAnimManager_BlendAnimation_Hierarchy();
420-
void HOOK_CAnimManager_BlendAnimation();
421416
void HOOK_CPed_GetWeaponSkill();
422417
void HOOK_CPed_AddGogglesModel();
423418
void HOOK_CPhysical_ProcessCollisionSectorList();
@@ -734,7 +729,6 @@ void CMultiplayerSA::InitHooks()
734729
HookInstall(HOOKPOS_CAnimManager_AddAnimation, (DWORD)HOOK_CAnimManager_AddAnimation, 10);
735730
HookInstall(HOOKPOS_CAnimManager_AddAnimationAndSync, (DWORD)HOOK_CAnimManager_AddAnimationAndSync, 10);
736731
HookInstall(HOOKPOS_CAnimManager_BlendAnimation_Hierarchy, (DWORD)HOOK_CAnimManager_BlendAnimation_Hierarchy, 5);
737-
HookInstall(HOOKPOS_CAnimManager_BlendAnimation, (DWORD)HOOK_CAnimManager_BlendAnimation, 7);
738732

739733
// Disable GTA setting g_bGotFocus to false when we minimize
740734
MemSet((void*)ADDR_GotFocus, 0x90, pGameInterface->GetGameVersion() == VERSION_EU_10 ? 6 : 10);
@@ -2229,11 +2223,6 @@ void CMultiplayerSA::SetPreHudRenderHandler(PreHudRenderHandler* pHandler)
22292223
m_pPreHudRenderHandler = pHandler;
22302224
}
22312225

2232-
void CMultiplayerSA::SetBlendAnimationHandler(BlendAnimationHandler* pHandler)
2233-
{
2234-
m_pBlendAnimationHandler = pHandler;
2235-
}
2236-
22372226
void CMultiplayerSA::SetProcessCollisionHandler(ProcessCollisionHandler* pHandler)
22382227
{
22392228
m_pProcessCollisionHandler = pHandler;
@@ -5394,42 +5383,6 @@ void _declspec(naked) HOOK_CPed_GetWeaponSkill()
53945383
}
53955384
}
53965385

5397-
bool _cdecl OnCAnimManagerBlendAnimation(RpClump* pClump, AssocGroupId animGroup, AnimationId animID, float fBlendData)
5398-
{
5399-
if (m_pBlendAnimationHandler)
5400-
{
5401-
return m_pBlendAnimationHandler(pClump, animGroup, animID, fBlendData);
5402-
}
5403-
return true;
5404-
}
5405-
5406-
void _declspec(naked) HOOK_CAnimManager_BlendAnimation()
5407-
{
5408-
_asm
5409-
{
5410-
push ebp
5411-
mov ebp, esp
5412-
5413-
push [ebp + 20]
5414-
push [ebp + 16]
5415-
push [ebp + 12]
5416-
push [ebp + 8]
5417-
call OnCAnimManagerBlendAnimation
5418-
add esp, 4 * 4
5419-
5420-
pop ebp
5421-
test al, al
5422-
jnz standardcode
5423-
mov eax, 0
5424-
retn
5425-
5426-
standardcode:
5427-
sub esp, 14h
5428-
mov ecx, [esp + 18h]
5429-
jmp RETURN_CAnimManager_BlendAnimation
5430-
}
5431-
}
5432-
54335386
// Actually check if the ped putting on goggles is the local player before
54345387
// applying the visual effect
54355388
bool _cdecl CPed_AddGogglesModelCheck(void* pPedInterface)

Client/multiplayer_sa/CMultiplayerSA.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ class CMultiplayerSA : public CMultiplayer
117117
void SetAddAnimationAndSyncHandler(AddAnimationAndSyncHandler* pHandler);
118118
void SetAssocGroupCopyAnimationHandler(AssocGroupCopyAnimationHandler* pHandler);
119119
void SetBlendAnimationHierarchyHandler(BlendAnimationHierarchyHandler* pHandler);
120-
void SetBlendAnimationHandler(BlendAnimationHandler* pHandler);
121120
void SetProcessCollisionHandler(ProcessCollisionHandler* pHandler);
122121
void SetVehicleCollisionHandler(VehicleCollisionHandler* pHandler);
123122
void SetVehicleDamageHandler(VehicleDamageHandler* pHandler);

Client/sdk/multiplayer/CMultiplayer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ typedef bool(AssocGroupCopyAnimationHandler)(CAnimBlendAssociationSAInterface* p
9797
AnimationId animID);
9898
typedef bool(BlendAnimationHierarchyHandler)(CAnimBlendAssociationSAInterface* pAnimAssoc, CAnimBlendHierarchySAInterface** pOutAnimHierarchy, int* pFlags,
9999
RpClump* pClump);
100-
typedef bool(BlendAnimationHandler)(RpClump* pClump, AssocGroupId animGroup, AnimationId animID, float fBlendData);
101100
typedef bool(ProcessCollisionHandler)(class CEntitySAInterface* pThisInterface, class CEntitySAInterface* pOtherInterface);
102101
typedef bool(VehicleCollisionHandler)(class CVehicleSAInterface*& pCollidingVehicle, class CEntitySAInterface* pCollidedVehicle, int iModelIndex,
103102
float fDamageImpulseMag, float fCollidingDamageImpulseMag, uint16 usPieceType, CVector vecCollisionPos,
@@ -222,7 +221,6 @@ class CMultiplayer
222221
virtual void SetAddAnimationAndSyncHandler(AddAnimationAndSyncHandler* pHandler) = 0;
223222
virtual void SetAssocGroupCopyAnimationHandler(AssocGroupCopyAnimationHandler* pHandler) = 0;
224223
virtual void SetBlendAnimationHierarchyHandler(BlendAnimationHierarchyHandler* pHandler) = 0;
225-
virtual void SetBlendAnimationHandler(BlendAnimationHandler* pHandler) = 0;
226224
virtual void SetProcessCollisionHandler(ProcessCollisionHandler* pHandler) = 0;
227225
virtual void SetVehicleCollisionHandler(VehicleCollisionHandler* pHandler) = 0;
228226
virtual void SetVehicleDamageHandler(VehicleDamageHandler* pHandler) = 0;

0 commit comments

Comments
 (0)