55#include < ../game_sa/CAnimBlendAssociationSA.h>
66#include < ../game_sa/CAnimBlendAssocGroupSA.h>
77
8- DWORD FUNC_NEW_OPERATOR = 0x082119A ;
9- DWORD FUNC_CAnimBlendAssociation_Constructor = 0x04CF080 ;
108DWORD FUNC_CAnimBlendAssociation__ReferenceAnimBlock = 0x4CEA50 ;
119DWORD FUNC_UncompressAnimation = 0x4D41C0 ;
1210DWORD FUNC_CAnimBlendAssociation__CAnimBlendAssociation_hierarchy = 0x4CEFC0 ;
1311
14- DWORD RETURN_CAnimBlendAssoc_destructor = 0x4CECF6 ;
1512DWORD RETURN_CAnimBlendAssocGroup_CopyAnimation_NORMALFLOW = 0x4CE151 ;
1613DWORD RETURN_CAnimBlendAssocGroup_CopyAnimation = 0x4CE187 ;
1714DWORD RETURN_CAnimBlendAssocGroup_CopyAnimation_ERROR = 0x4CE199 ;
1815DWORD RETURN_CAnimManager_AddAnimation = 0x4D3AB1 ;
1916DWORD RETURN_CAnimManager_AddAnimationAndSync = 0x4D3B41 ;
2017DWORD RETURN_CAnimManager_BlendAnimation_Hierarchy = 0x4D4577 ;
2118
22- CAnimBlendAssocDestructorHandler* m_pCAnimBlendAssocDestructorHandler = nullptr ;
19+ auto CAnimBlendStaticAssociation_FreeSequenceArray = (hCAnimBlendStaticAssociation_FreeSequenceArray)0x4ce9a0 ;
20+ auto UncompressAnimation = (hUncompressAnimation)0x4d41c0 ;
21+ auto CAnimBlendAssociation_NewOperator = (hCAnimBlendAssociation_NewOperator)0x082119A ;
22+ auto CAnimBlendAssociation_Constructor_staticAssocByReference = (hCAnimBlendAssociation_Constructor_staticAssocByReference)0x4CF080 ;
23+
2324AddAnimationHandler* m_pAddAnimationHandler = nullptr ;
2425AddAnimationAndSyncHandler* m_pAddAnimationAndSyncHandler = nullptr ;
2526AssocGroupCopyAnimationHandler* m_pAssocGroupCopyAnimationHandler = nullptr ;
2627BlendAnimationHierarchyHandler* m_pBlendAnimationHierarchyHandler = nullptr ;
2728
2829int _cdecl OnCAnimBlendAssocGroupCopyAnimation (AssocGroupId animGroup, int iAnimId);
29- auto CAnimBlendStaticAssociation_FreeSequenceArray = (hCAnimBlendStaticAssociation_FreeSequenceArray)0x4ce9a0 ;
30-
31- void CMultiplayerSA::SetCAnimBlendAssocDestructorHandler (CAnimBlendAssocDestructorHandler* pHandler)
32- {
33- m_pCAnimBlendAssocDestructorHandler = pHandler;
34- }
3530
3631void CMultiplayerSA::SetAddAnimationHandler (AddAnimationHandler* pHandler)
3732{
@@ -53,42 +48,22 @@ void CMultiplayerSA::SetBlendAnimationHierarchyHandler(BlendAnimationHierarchyHa
5348 m_pBlendAnimationHierarchyHandler = pHandler;
5449}
5550
56- void __cdecl CAnimBlendAssoc_destructor (CAnimBlendAssociationSAInterface* pThis)
57- {
58- if (m_pCAnimBlendAssocDestructorHandler)
59- {
60- m_pCAnimBlendAssocDestructorHandler (pThis);
61- }
62- }
63-
64- void _declspec (naked) HOOK_CAnimBlendAssoc_destructor()
51+ CAnimBlendAssociationSAInterface * __cdecl CAnimBlendAssocGroup_CopyAnimation ( RpClump* pClump, CAnimBlendAssocGroupSAInterface* pAnimAssocGroupInterface, AnimationId animID )
6552{
66- _asm
67- {
68- push ecx
53+ auto pAnimAssociationInterface = reinterpret_cast < CAnimBlendAssociationSAInterface * > (CAnimBlendAssociation_NewOperator ( sizeof (CAnimBlendAssociationSAInterface)));
54+ if (pAnimAssociationInterface)
55+ {
56+ CAnimBlendStaticAssociationSAInterface staticAnimAssociationInterface;
6957
70- push ecx
71- call CAnimBlendAssoc_destructor
72- add esp, 0x4
58+ m_pAssocGroupCopyAnimationHandler (&staticAnimAssociationInterface, pAnimAssociationInterface, pClump, pAnimAssocGroupInterface, animID);
7359
74- pop ecx
60+ UncompressAnimation (staticAnimAssociationInterface. pAnimHeirarchy );
7561
76- push esi
77- mov esi, ecx
78- mov eax, [esi+10h]
79- jmp RETURN_CAnimBlendAssoc_destructor
80- }
81- }
62+ CAnimBlendAssociation_Constructor_staticAssocByReference (pAnimAssociationInterface, staticAnimAssociationInterface);
8263
83- CAnimBlendStaticAssociationSAInterface* __cdecl AllocateStaticAssociationMemory (void )
84- {
85- return new CAnimBlendStaticAssociationSAInterface;
86- }
87-
88- void __cdecl DeleteStaticAssociation (CAnimBlendStaticAssociationSAInterface* pAnimStaticAssoc)
89- {
90- CAnimBlendStaticAssociation_FreeSequenceArray (pAnimStaticAssoc);
91- delete pAnimStaticAssoc;
64+ CAnimBlendStaticAssociation_FreeSequenceArray (&staticAnimAssociationInterface);
65+ }
66+ return pAnimAssociationInterface;
9267}
9368
9469void _declspec (naked) HOOK_CAnimBlendAssocGroup_CopyAnimation()
@@ -104,88 +79,21 @@ void _declspec(naked) HOOK_CAnimBlendAssocGroup_CopyAnimation()
10479 {
10580 popad
10681
107- push ecx
108- push ebp
109- mov ebp, esp
110- sub esp, 4
111-
112- push eax
113- push ecx
114- push edi
115-
116- // create CAnimBlendAssociation
117- push 3Ch
118- call FUNC_NEW_OPERATOR
119- add esp, 4
120-
121- mov [ebp-4 ], eax
122- push eax
123-
124- // Allocate memory for our new static association
125- call AllocateStaticAssociationMemory
126- mov edi, eax
127-
128- // push the static association
129- push edi
130- call m_pAssocGroupCopyAnimationHandler // CAnimBlendAssocGroup_CopyAnimation
131- add esp, 14h
82+ push esi
13283
133- mov ecx, [ebp-4 ]
84+ push eax // animID
85+ push ecx // pAnimAssocGroupInterface
86+ push edi // pClump
87+ call CAnimBlendAssocGroup_CopyAnimation
88+ add esp, 0Ch
13489
135- add esp, 4 // remove space for local var
136- mov esp, ebp
137- pop ebp
138-
139- // save eax and ecx for later to check whether current animation is custom or not
140- // after calling FUNC_CAnimBlendAssociation_Constructor function
141- push eax // isCustomAnimation ( bool )
142- push ecx // pIFPAnimations
143-
144- // get "this" from stack that we pushed first
145- mov ecx, [esp+8 ]
146- mov ecx, [ecx+4 ]
147- sub eax, edx
148- push esi
149-
150- // copy the static association to esi
151- mov esi, edi
152- test esi, esi
153- jz ERROR_CopyAnimation
154- mov eax, [esi+10h]
155- push eax
156- mov eax, 04D41C0h
157- call eax
158- add esp, 4
159- mov eax, [esp+4 ] // pAnimAssociation
160- mov [esp+20h], eax
16190 test eax, eax
162- mov [esp+18h], 0
16391 jz ERROR_CopyAnimation
164- push esi
165- mov ecx, eax
166- call FUNC_CAnimBlendAssociation_Constructor
167- mov edi, eax
168-
169- // Delete our static association, since we no longer need it
170- push esi
171- call DeleteStaticAssociation
172- add esp, 4
173-
174- mov ecx, [esp+4 ] // pIFPAnimations
175- mov eax, [esp+8 ] // isCustomAnimation
17692
177- // put CAnimBlendAssociation in eax
178- mov eax, edi
179- add esp, 0Ch
18093 jmp RETURN_CAnimBlendAssocGroup_CopyAnimation
18194
182- ERROR_CopyAnimation:
183- add esp, 0Ch
184- // Delete our static association
185- push edi
186- call DeleteStaticAssociation
187- add esp, 4
188- jmp RETURN_CAnimBlendAssocGroup_CopyAnimation_ERROR
95+ ERROR_CopyAnimation:
96+ jmp RETURN_CAnimBlendAssocGroup_CopyAnimation_ERROR
18997 }
19098 }
19199
0 commit comments