Skip to content

Commit aab7940

Browse files
committed
Moved custom animation hooks to a separate file
1 parent 16a9c55 commit aab7940

File tree

2 files changed

+306
-306
lines changed

2 files changed

+306
-306
lines changed

Client/multiplayer_sa/CMultiplayerSA.cpp

Lines changed: 2 additions & 306 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525
#include "..\game_sa\CBuildingSA.h"
2626
#include "..\game_sa\CPedSA.h"
2727
#include "..\game_sa\common.h"
28-
#include <../game_sa/CAnimBlendHierarchySA.h> // ---------------- REMOVE THIS LATER
29-
#include <../game_sa/CAnimBlendStaticAssociationSA.h>
30-
#include <../game_sa/CAnimBlendAssociationSA.h>
31-
#include <../game_sa/CAnimBlendAssocGroupSA.h>
28+
3229

3330
extern CCoreInterface* g_pCore;
3431
extern CMultiplayerSA* pMultiplayer;
@@ -160,23 +157,10 @@ DWORD RETURN_CPlantMgr_Render_fail = 0x5DBDAA;
160157
#define HOOKPOS_CEventHandler_ComputeKnockOffBikeResponse 0x4BA06F
161158
DWORD RETURN_CEventHandler_ComputeKnockOffBikeResponse = 0x4BA076;
162159

163-
DWORD FUNC_NEW_OPERATOR = 0x082119A;
164-
DWORD FUNC_CAnimBlendAssociation_Constructor = 0x04CF080;
165-
166160
#define HOOKPOS_CAnimBlendAssocGroup_CopyAnimation 0x4CE14C
167-
DWORD RETURN_CAnimBlendAssocGroup_CopyAnimation_NORMALFLOW =0x4CE151;
168-
DWORD RETURN_CAnimBlendAssocGroup_CopyAnimation = 0x4CE187;
169-
DWORD RETURN_CAnimBlendAssocGroup_CopyAnimation_ERROR = 0x4CE199;
170-
171161
#define HOOKPOS_CAnimManager_AddAnimation 0x4d3aa0
172-
DWORD RETURN_CAnimManager_AddAnimation = 0x4D3AB1;
173-
174162
#define HOOKPOS_CAnimManager_AddAnimationAndSync 0x4D3B30
175-
DWORD RETURN_CAnimManager_AddAnimationAndSync = 0x4D3B41;
176-
177-
178-
#define HOOKPOS_CAnimManager_BlendAnimation_Hierarchy 0x4D4410 //0x4D4425
179-
DWORD RETURN_CAnimManager_BlendAnimation_Hierarchy = 0x4D4417; //0x4D442D;
163+
#define HOOKPOS_CAnimManager_BlendAnimation_Hierarchy 0x4D4410
180164

181165
#define HOOKPOS_CPed_GetWeaponSkill 0x5e3b60
182166
DWORD RETURN_CPed_GetWeaponSkill = 0x5E3B68;
@@ -377,10 +361,6 @@ PostWorldProcessHandler * m_pPostWorldProcessHandler = NULL;
377361
IdleHandler * m_pIdleHandler = NULL;
378362
PreFxRenderHandler * m_pPreFxRenderHandler = NULL;
379363
PreHudRenderHandler * m_pPreHudRenderHandler = NULL;
380-
AddAnimationHandler* m_pAddAnimationHandler = NULL;
381-
AddAnimationAndSyncHandler* m_pAddAnimationAndSyncHandler = nullptr;
382-
AssocGroupCopyAnimationHandler* m_pAssocGroupCopyAnimationHandler = nullptr;
383-
BlendAnimationHierarchyHandler* m_pBlendAnimationHierarchyHandler = NULL;
384364
ProcessCollisionHandler* m_pProcessCollisionHandler = NULL;
385365
VehicleCollisionHandler* m_pVehicleCollisionHandler = NULL;
386366
HeliKillHandler* m_pHeliKillHandler = NULL;
@@ -392,8 +372,6 @@ DrivebyAnimationHandler* m_pDrivebyAnimationHandler = NULL;
392372
CEntitySAInterface * dwSavedPlayerPointer = 0;
393373
CEntitySAInterface * activeEntityForStreaming = 0; // the entity that the streaming system considers active
394374

395-
int _cdecl OnCAnimBlendAssocGroupCopyAnimation ( AssocGroupId animGroup, int iAnimId );
396-
auto CAnimBlendStaticAssociation_FreeSequenceArray = (hCAnimBlendStaticAssociation_FreeSequenceArray)0x4ce9a0;
397375

398376
void HOOK_FindPlayerCoors();
399377
void HOOK_FindPlayerCentreOfWorld();
@@ -2237,26 +2215,6 @@ void CMultiplayerSA::SetPreHudRenderHandler ( PreHudRenderHandler * pHandler )
22372215
m_pPreHudRenderHandler = pHandler;
22382216
}
22392217

2240-
void CMultiplayerSA::SetAddAnimationHandler ( AddAnimationHandler * pHandler )
2241-
{
2242-
m_pAddAnimationHandler = pHandler;
2243-
}
2244-
2245-
void CMultiplayerSA::SetAddAnimationAndSyncHandler ( AddAnimationAndSyncHandler * pHandler )
2246-
{
2247-
m_pAddAnimationAndSyncHandler = pHandler;
2248-
}
2249-
2250-
void CMultiplayerSA::SetAssocGroupCopyAnimationHandler ( AssocGroupCopyAnimationHandler * pHandler )
2251-
{
2252-
m_pAssocGroupCopyAnimationHandler = pHandler;
2253-
}
2254-
2255-
void CMultiplayerSA::SetBlendAnimationHierarchyHandler ( BlendAnimationHierarchyHandler * pHandler )
2256-
{
2257-
m_pBlendAnimationHierarchyHandler = pHandler;
2258-
}
2259-
22602218
void CMultiplayerSA::SetProcessCollisionHandler ( ProcessCollisionHandler * pHandler )
22612219
{
22622220
m_pProcessCollisionHandler = pHandler;
@@ -2267,7 +2225,6 @@ void CMultiplayerSA::SetVehicleCollisionHandler ( VehicleCollisionHandler * pHan
22672225
m_pVehicleCollisionHandler = pHandler;
22682226
}
22692227

2270-
22712228
void CMultiplayerSA::SetHeliKillHandler ( HeliKillHandler * pHandler )
22722229
{
22732230
m_pHeliKillHandler = pHandler;
@@ -5361,267 +5318,6 @@ void _declspec(naked) HOOK_CEventHandler_ComputeKnockOffBikeResponse ()
53615318
}
53625319
}
53635320

5364-
CAnimBlendStaticAssociationSAInterface * __cdecl AllocateStaticAssociationMemory ( void )
5365-
{
5366-
return new CAnimBlendStaticAssociationSAInterface;
5367-
}
5368-
5369-
void __cdecl DeleteStaticAssociation ( CAnimBlendStaticAssociationSAInterface * pAnimStaticAssoc )
5370-
{
5371-
CAnimBlendStaticAssociation_FreeSequenceArray ( pAnimStaticAssoc );
5372-
delete pAnimStaticAssoc;
5373-
}
5374-
5375-
5376-
void _declspec(naked) HOOK_CAnimBlendAssocGroup_CopyAnimation ()
5377-
{
5378-
_asm
5379-
{
5380-
pushad
5381-
}
5382-
5383-
if ( m_pAssocGroupCopyAnimationHandler )
5384-
{
5385-
_asm
5386-
{
5387-
popad
5388-
5389-
push ecx
5390-
push ebp
5391-
mov ebp, esp
5392-
sub esp, 4
5393-
5394-
push eax
5395-
push ecx
5396-
push edi
5397-
5398-
lea eax, [ebp-4]
5399-
push eax
5400-
5401-
// Allocate memory for our new static association
5402-
call AllocateStaticAssociationMemory
5403-
mov edi, eax
5404-
5405-
// push the static association
5406-
push edi
5407-
call m_pAssocGroupCopyAnimationHandler
5408-
add esp, 14h
5409-
5410-
mov ecx, [ebp-4]
5411-
5412-
add esp, 4 // remove space for local var
5413-
mov esp, ebp
5414-
pop ebp
5415-
5416-
// save eax and ecx for later to check whether current animation is custom or not
5417-
// after calling FUNC_CAnimBlendAssociation_Constructor function
5418-
push eax
5419-
push ecx
5420-
5421-
// get "this" from stack that we pushed first
5422-
mov ecx, [esp+8]
5423-
mov ecx, [ecx+4]
5424-
sub eax, edx
5425-
push esi
5426-
5427-
// copy the static association to esi
5428-
mov esi, edi
5429-
test esi, esi
5430-
jz ERROR_CopyAnimation
5431-
mov eax, [esi+10h]
5432-
push eax
5433-
mov eax, 04D41C0h
5434-
call eax
5435-
push 3Ch
5436-
call FUNC_NEW_OPERATOR
5437-
add esp, 8
5438-
mov [esp+20h], eax
5439-
test eax, eax
5440-
mov [esp+18h], 0
5441-
jz ERROR_CopyAnimation
5442-
push esi
5443-
mov ecx, eax
5444-
call FUNC_CAnimBlendAssociation_Constructor
5445-
mov edi, eax
5446-
5447-
// Delete our static association, since we no longer need it
5448-
push esi
5449-
call DeleteStaticAssociation
5450-
add esp, 4
5451-
5452-
pop ecx
5453-
pop eax
5454-
5455-
// Check wether this is a custom animation or not
5456-
cmp al, 0
5457-
je NOT_CUSTOM_ANIMATION_CopyAnimation
5458-
5459-
// It's a custom animation, store it in a map
5460-
5461-
NOT_CUSTOM_ANIMATION_CopyAnimation:
5462-
// put CAnimBlendAssociation in eax
5463-
mov eax, edi
5464-
add esp, 4
5465-
jmp RETURN_CAnimBlendAssocGroup_CopyAnimation
5466-
5467-
ERROR_CopyAnimation:
5468-
// Delete our static association first
5469-
push edi
5470-
call DeleteStaticAssociation
5471-
add esp, 4
5472-
jmp RETURN_CAnimBlendAssocGroup_CopyAnimation_ERROR
5473-
}
5474-
}
5475-
5476-
_asm
5477-
{
5478-
popad
5479-
mov ecx, [ecx+4]
5480-
sub eax, edx
5481-
jmp RETURN_CAnimBlendAssocGroup_CopyAnimation_NORMALFLOW
5482-
}
5483-
}
5484-
5485-
void _declspec(naked) HOOK_CAnimManager_AddAnimation ()
5486-
{
5487-
_asm
5488-
{
5489-
pushad
5490-
}
5491-
5492-
if ( m_pAddAnimationHandler )
5493-
{
5494-
_asm
5495-
{
5496-
popad
5497-
mov ecx, [esp+4] // animationClump
5498-
mov edx, [esp+8] // animationGroup
5499-
mov eax, [esp+12] // animationID
5500-
push eax
5501-
push edx
5502-
call OnCAnimBlendAssocGroupCopyAnimation
5503-
add esp, 8
5504-
mov [esp+12], eax // replace animationID
5505-
5506-
// call our handler function
5507-
push eax
5508-
push edx
5509-
mov ecx, [esp+12] // animationClump
5510-
push ecx
5511-
call m_pAddAnimationHandler
5512-
add esp, 0Ch
5513-
pushad
5514-
jmp NORMAL_FLOW_AddAnimation
5515-
}
5516-
}
5517-
5518-
_asm
5519-
{
5520-
NORMAL_FLOW_AddAnimation:
5521-
popad
5522-
mov eax, dword ptr [esp+0Ch]
5523-
mov edx, dword ptr ds:[0B4EA34h]
5524-
push esi
5525-
push edi
5526-
push eax
5527-
mov eax, dword ptr [esp+14h] // animationGroup
5528-
mov edi, dword ptr [esp+10h] // animationClump
5529-
jmp RETURN_CAnimManager_AddAnimation
5530-
}
5531-
}
5532-
5533-
void _declspec(naked) HOOK_CAnimManager_AddAnimationAndSync ()
5534-
{
5535-
_asm
5536-
{
5537-
pushad
5538-
}
5539-
5540-
if ( m_pAddAnimationAndSyncHandler )
5541-
{
5542-
_asm
5543-
{
5544-
popad
5545-
mov ecx, [esp+4] // animationClump
5546-
mov ebx, [esp+8] // pAnimAssociationToSyncWith
5547-
mov edx, [esp+12] // animationGroup
5548-
mov eax, [esp+16] // animationID
5549-
push eax
5550-
push edx
5551-
call OnCAnimBlendAssocGroupCopyAnimation
5552-
add esp, 8
5553-
mov [esp+16], eax // replace animationID
5554-
5555-
// call our handler function
5556-
push eax
5557-
push edx
5558-
push ebx
5559-
mov ecx, [esp+16] // animationClump
5560-
push ecx
5561-
call m_pAddAnimationAndSyncHandler
5562-
add esp, 10h
5563-
pushad
5564-
jmp NORMAL_FLOW_AddAnimationAndSync
5565-
}
5566-
}
5567-
5568-
_asm
5569-
{
5570-
NORMAL_FLOW_AddAnimationAndSync:
5571-
popad
5572-
mov eax, dword ptr [esp+10h]
5573-
mov edx, dword ptr ds:[0B4EA34h]
5574-
push esi
5575-
push edi
5576-
push eax
5577-
mov eax, dword ptr [esp+18h] // animationGroup
5578-
mov edi, dword ptr [esp+10h] // animationClump
5579-
jmp RETURN_CAnimManager_AddAnimationAndSync
5580-
}
5581-
}
5582-
5583-
void _declspec(naked) HOOK_CAnimManager_BlendAnimation_Hierarchy ()
5584-
{
5585-
_asm
5586-
{
5587-
pushad
5588-
}
5589-
5590-
if ( m_pBlendAnimationHierarchyHandler )
5591-
{
5592-
_asm
5593-
{
5594-
popad
5595-
//mov edx, [esp+4] // animationClump
5596-
mov eax, [esp+8] // pAnimHierarchy
5597-
mov ecx, [esp+12] // flags
5598-
mov edx, [esp+16] // animationBlendDelta
5599-
5600-
// call our handler function
5601-
push edx
5602-
mov edx, [esp+8] // animationClump
5603-
push ecx
5604-
push eax
5605-
push edx
5606-
call m_pBlendAnimationHierarchyHandler
5607-
add esp, 10h
5608-
mov [esp+8], eax // replace pAnimHierarchy
5609-
pushad
5610-
jmp NORMAL_FLOW_BlendAnimation_Hierarchy
5611-
}
5612-
}
5613-
5614-
_asm
5615-
{
5616-
NORMAL_FLOW_BlendAnimation_Hierarchy:
5617-
popad
5618-
push 0FFFFFFFFh
5619-
push 04D4410h
5620-
jmp RETURN_CAnimManager_BlendAnimation_Hierarchy
5621-
}
5622-
5623-
}
5624-
56255321
CPedSAInterface * weaponSkillPed;
56265322
eWeaponType weaponSkillWeapon;
56275323
BYTE weaponSkill;

0 commit comments

Comments
 (0)