5
5
#include < ../game_sa/CAnimBlendAssociationSA.h>
6
6
#include < ../game_sa/CAnimBlendAssocGroupSA.h>
7
7
8
- DWORD FUNC_NEW_OPERATOR = 0x082119A ;
9
- DWORD FUNC_CAnimBlendAssociation_Constructor = 0x04CF080 ;
10
8
DWORD FUNC_CAnimBlendAssociation__ReferenceAnimBlock = 0x4CEA50 ;
11
9
DWORD FUNC_UncompressAnimation = 0x4D41C0 ;
12
10
DWORD FUNC_CAnimBlendAssociation__CAnimBlendAssociation_hierarchy = 0x4CEFC0 ;
13
11
14
- DWORD RETURN_CAnimBlendAssoc_destructor = 0x4CECF6 ;
15
12
DWORD RETURN_CAnimBlendAssocGroup_CopyAnimation_NORMALFLOW = 0x4CE151 ;
16
13
DWORD RETURN_CAnimBlendAssocGroup_CopyAnimation = 0x4CE187 ;
17
14
DWORD RETURN_CAnimBlendAssocGroup_CopyAnimation_ERROR = 0x4CE199 ;
18
15
DWORD RETURN_CAnimManager_AddAnimation = 0x4D3AB1 ;
19
16
DWORD RETURN_CAnimManager_AddAnimationAndSync = 0x4D3B41 ;
20
17
DWORD RETURN_CAnimManager_BlendAnimation_Hierarchy = 0x4D4577 ;
21
18
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
+
23
24
AddAnimationHandler* m_pAddAnimationHandler = nullptr ;
24
25
AddAnimationAndSyncHandler* m_pAddAnimationAndSyncHandler = nullptr ;
25
26
AssocGroupCopyAnimationHandler* m_pAssocGroupCopyAnimationHandler = nullptr ;
26
27
BlendAnimationHierarchyHandler* m_pBlendAnimationHierarchyHandler = nullptr ;
27
28
28
29
int _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
- }
35
30
36
31
void CMultiplayerSA::SetAddAnimationHandler (AddAnimationHandler* pHandler)
37
32
{
@@ -53,42 +48,22 @@ void CMultiplayerSA::SetBlendAnimationHierarchyHandler(BlendAnimationHierarchyHa
53
48
m_pBlendAnimationHierarchyHandler = pHandler;
54
49
}
55
50
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 )
65
52
{
66
- _asm
67
- {
68
- push ecx
53
+ auto pAnimAssociationInterface = reinterpret_cast < CAnimBlendAssociationSAInterface * > (CAnimBlendAssociation_NewOperator ( sizeof (CAnimBlendAssociationSAInterface)));
54
+ if (pAnimAssociationInterface)
55
+ {
56
+ CAnimBlendStaticAssociationSAInterface staticAnimAssociationInterface;
69
57
70
- push ecx
71
- call CAnimBlendAssoc_destructor
72
- add esp, 0x4
58
+ m_pAssocGroupCopyAnimationHandler (&staticAnimAssociationInterface, pAnimAssociationInterface, pClump, pAnimAssocGroupInterface, animID);
73
59
74
- pop ecx
60
+ UncompressAnimation (staticAnimAssociationInterface. pAnimHeirarchy );
75
61
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);
82
63
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;
92
67
}
93
68
94
69
void _declspec (naked) HOOK_CAnimBlendAssocGroup_CopyAnimation()
@@ -104,88 +79,21 @@ void _declspec(naked) HOOK_CAnimBlendAssocGroup_CopyAnimation()
104
79
{
105
80
popad
106
81
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
132
83
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
134
89
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
161
90
test eax, eax
162
- mov [esp+18h], 0
163
91
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
176
92
177
- // put CAnimBlendAssociation in eax
178
- mov eax, edi
179
- add esp, 0Ch
180
93
jmp RETURN_CAnimBlendAssocGroup_CopyAnimation
181
94
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
189
97
}
190
98
}
191
99
0 commit comments