Skip to content

Commit 15f99b2

Browse files
saml1erjushar
saml1er
authored andcommitted
Implement custom IFP animations
Squashed commit of the following: commit ae72bbc Author: Jusonex <jusonex96@gmail.com> Date: Sat Jun 16 20:28:58 2018 +0200 Make custom animations work with the EU version too commit 432344f Author: Jusonex <jusonex96@gmail.com> Date: Sat Jun 16 17:28:56 2018 +0200 Fix source formatting in CMultiplayerSA based on the clang-format change commit 44e8167 Merge: 9900349 05fbbfb Author: Jusonex <jusonex96@gmail.com> Date: Sat Jun 16 17:28:33 2018 +0200 Merge remote-tracking branch 'origin/master' into feature/custom-ifp-animations commit 9900349 Merge: d38e68e 9f4d3de Author: saml1er <10183157+saml1er@users.noreply.github.com> Date: Mon Jun 11 07:14:24 2018 +0500 Merge pull request #1 from multitheftauto/master Merge master into custom_ifp_animations commit d38e68e Author: Qais Patankar <qaisjp@gmail.com> Date: Wed Jun 6 23:41:34 2018 +0100 Undo whitespace change (test commit) commit 3114067 Author: idanish <danishroar@gmail.com> Date: Fri May 4 15:37:41 2018 +0500 Added copyright comment, and added #pragma once to header files commit cd5b1cd Author: idanish <danishroar@gmail.com> Date: Fri May 4 15:36:31 2018 +0500 Added m_ prefix before member names and copyright comment at top. commit a311d8d Author: idanish <danishroar@gmail.com> Date: Thu Apr 12 01:11:43 2018 +0500 Fix warning c4150 when deleting Game SA interface Visual studio was generating a warning when calling delete operator on hierarchy and sequnece interface in Client Deathmatch, so replaced it with CAnimManager::DeleteCustomAnimHierarchyInterface and CAnimManager::DeleteCustomAnimSequenceInterface in CIFPAnimations::DeleteAnimations and CClientIFP::MoveSequencesWithDummies Also, applied source formatting commit 90ba044 Author: idanish <danishroar@gmail.com> Date: Wed Apr 11 23:35:59 2018 +0500 Improved custom animation hooks for readability Rewrote HOOK_CAnimBlendAssocGroup_CopyAnimation in C++ for more clarity, it is shorter now, and thus more readable. Moved HOOK_CAnimBlendAssoc_destructor to CMultiplayerSA_HookDestructors.cpp commit db75cd6 Author: idanish <danishroar@gmail.com> Date: Wed Apr 11 15:39:59 2018 +0500 Removed IFP mutexes from CClientGame and CClientPed They were not needed. I used them because I was in doubt whether GTA:SA is using a secondary thread. I confirmed that it's not using another thread with the help of SharedUtil::IsMainThread() method. - Suggested by Jusonex commit c54b854 Author: idanish <danishroar@gmail.com> Date: Fri Apr 6 17:19:45 2018 +0500 Removed GameSA includes from Client Deathmatch and minor code improvements Replaced GameSA includes with interfaces - Suggested by Jusonex Removed #pragma from CIFPEngine.h eRestoreType is now passed by const reference in CIFPEngine::EngineRestoreAnimation commit 43f90fe Author: idanish <danishroar@gmail.com> Date: Thu Apr 5 14:51:55 2018 +0500 Code quality improvements Replaced uint32_t, int32_t, and int16_t with std::* from <cstdint> - Suggested by Necktrox Used std::find_if in CClientIFP::GetAnimationHierarchy & improved iterator loops by using for (auto& Animation : m_pIFPAnimations->vecAnimations) in CClientIFP::ReadIFPVersion2 and CClientIFP::ReadIFPVersion1 - earlier suggested by sbx320 Replaced std::string with SString. Changed CIFPAnimations::SIFPAnimation::pSequencesMemory type to BYTE*. Removed casting where this member of struct was accessed. Used const where applicable in CClientIFP.cpp. Renamed ConvertStringToMapKey to ConvertStringToKey. Applied source formatting again commit 6ec9bcc Author: idanish <danishroar@gmail.com> Date: Wed Apr 4 16:18:00 2018 +0500 Rewrote CFileReader and some code review improvements CFileReader is using ifstream to load file into std::vector. No more dynamic memory allocation. & replaced std::vector::push_back with std::vector::emplace_back in CElementDeleter::OnClientIFPElementDestroy & Removed empty destructor from CClientIFP and empty constructor from CIFPAnimations - Suggested by Necktrox Used for (auto& pPed : m_setOfPedPointers) for iterating in CClientGame::OnClientIFPUnload. & using std::find_if in CElementDeleter::DeleteIFP with a lambda function - Suggested by sbx320 Removed #pragma once in CClientIFP.h and CIFPAnimations.h - Suggested by sbx320 and Necktrox commit e467f13 Author: idanish <danishroar@gmail.com> Date: Wed Apr 4 06:15:24 2018 +0500 Restored CStaticFunctionDefinitions::GUIMoveToBack Three lines got removed from this function while solving conflicts, so restored them back. commit a45bf99 Merge: dc8ef5c 554a27d Author: saml1er <10183157+saml1er@users.noreply.github.com> Date: Wed Apr 4 04:18:44 2018 +0500 Merge branch 'master' into custom_ifp_animations commit dc8ef5c Author: idanish <danishroar@gmail.com> Date: Wed Apr 4 03:55:45 2018 +0500 Fix source formatting commit 9a6f6ae Merge: e29b13a d7649ba Author: idanish <danishroar@gmail.com> Date: Wed Apr 4 03:39:22 2018 +0500 Merge branch 'test_custom_ifp_animations' # Conflicts: # Client/game_sa/CAnimBlendAssocGroupSA.cpp # Client/game_sa/CAnimBlendAssocGroupSA.h # Client/game_sa/CAnimBlendHierarchySA.cpp # Client/game_sa/CAnimBlendHierarchySA.h # Client/game_sa/CAnimBlendSequenceSA.h # Client/game_sa/CAnimBlendStaticAssociationSA.cpp # Client/game_sa/CAnimBlendStaticAssociationSA.h # Client/game_sa/CAnimBlockSA.h # Client/game_sa/CAnimManagerSA.cpp # Client/game_sa/CAnimManagerSA.h # Client/mods/deathmatch/logic/CClientGame.cpp # Client/mods/deathmatch/logic/CClientGame.h # Client/mods/deathmatch/logic/CClientPed.cpp # Client/mods/deathmatch/logic/CClientPed.h # Client/mods/deathmatch/logic/CElementDeleter.cpp # Client/mods/deathmatch/logic/CElementDeleter.h # Client/mods/deathmatch/logic/CResource.cpp # Client/mods/deathmatch/logic/CResource.h # Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp # Client/mods/deathmatch/logic/CStaticFunctionDefinitions.h # Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp # Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h # Client/multiplayer_sa/CMultiplayerSA.cpp # Client/multiplayer_sa/CMultiplayerSA.h # Client/multiplayer_sa/CMultiplayerSA_FixBadAnimId.cpp # Client/sdk/game/CAnimBlendAssocGroup.h # Client/sdk/game/CAnimBlendHierarchy.h # Client/sdk/game/CAnimBlock.h # Client/sdk/game/CAnimManager.h # Client/sdk/game/CGame.h # Client/sdk/multiplayer/CMultiplayer.h commit d7649ba Author: idanish <danishroar@gmail.com> Date: Wed Apr 4 02:50:33 2018 +0500 Fix engineIFPLoad failure on resource multiple restarts IFP was failing to load after restarting resource multiple times, because it was removed from map in CElementDeleter::DeleteIFP which caused a small delay in ms. Now, it will be removed from map when it's added to element deleter list, so engineLoadIFP won't fail because the element with the same block name does not exist in map anymore. commit 79c2463 Merge: e122684 84655ef Author: Code Nulls <danishroar@gmail.com> Date: Sun Apr 1 19:49:02 2018 +0500 Merge pull request #8 from saml1er/custom_ifp_animations Custom ifp animations ( mergeable to master ) commit 84655ef Author: idanish <danishroar@gmail.com> Date: Sun Apr 1 19:42:46 2018 +0500 Disabled console and removed printf commit 11fe653 Author: idanish <danishroar@gmail.com> Date: Sun Apr 1 16:21:26 2018 +0500 Used Hungarian notation for naming structs and enums commit d38b4ec Author: idanish <danishroar@gmail.com> Date: Sun Apr 1 15:31:49 2018 +0500 [ FIX ] Compiling in release mode caused crash on CAnimBlendAssoc_destructor commit e122684 Merge: 1dfadb5 dae8c85 Author: Code Nulls <danishroar@gmail.com> Date: Sun Apr 1 14:24:47 2018 +0500 Merge pull request #7 from saml1er/custom_ifp_animations Custom ifp animations ( Everything is complete ) commit dae8c85 Author: idanish <danishroar@gmail.com> Date: Sun Apr 1 14:16:12 2018 +0500 Removed 2 unused functions in CGame and CGameSA commit 98ccb35 Author: idanish <danishroar@gmail.com> Date: Sun Apr 1 12:25:25 2018 +0500 Removed unsed GetClientPedByClump from CClientEntity commit 66b9cd1 Author: idanish <danishroar@gmail.com> Date: Sun Apr 1 11:55:06 2018 +0500 Replaced Animations map is now thread-safe in CClientPed commit a5ddb6e Author: idanish <danishroar@gmail.com> Date: Sun Apr 1 11:22:09 2018 +0500 Improved code design for CAnimBlendStaticAssociation commit 7be4f2b Author: idanish <danishroar@gmail.com> Date: Sun Apr 1 09:20:24 2018 +0500 Implemented thread synchronization for maps and set commit ee3b7b1 Author: idanish <danishroar@gmail.com> Date: Sun Apr 1 09:18:38 2018 +0500 Moved Get functions to header in CAnimManagerSA commit 3f4e394 Author: idanish <danishroar@gmail.com> Date: Sat Mar 31 18:44:37 2018 +0500 [FIX] Unloading IFP will allow gateway animation to play instead of custom Custom animation was not playing if you unloaded IFP. I used a shared_ptr to fix this problem. Also, unloading IFP resulted in looped animations to play gateway animation instead of custom, so fixed that as well. commit 679982d Author: idanish <danishroar@gmail.com> Date: Sat Mar 31 18:41:12 2018 +0500 Optimized std::map key for performance. commit 91d3ea8 Author: idanish <danishroar@gmail.com> Date: Fri Mar 30 09:35:15 2018 +0500 [ FIX ] engineReplaceAnimation fails if block is not loaded commit 5966687 Author: idanish <danishroar@gmail.com> Date: Fri Mar 30 09:34:37 2018 +0500 Moved raw memory access to Game SA commit a7b1011 Author: idanish <danishroar@gmail.com> Date: Thu Mar 29 15:20:51 2018 +0500 Code design improvement in CIFPAnimations::DeleteAnimations commit 015fd39 Author: idanish <danishroar@gmail.com> Date: Thu Mar 29 15:19:48 2018 +0500 Added CIFPEngine which contains most logic for Lua IFP functions commit 1dfadb5 Merge: f4d1c55 8bbd104 Author: Code Nulls <danishroar@gmail.com> Date: Thu Mar 29 09:18:04 2018 +0500 Merge pull request #6 from saml1er/custom_ifp_animations Custom ifp animations ( Improved Code Design ) commit 8bbd104 Author: idanish <danishroar@gmail.com> Date: Thu Mar 29 09:01:37 2018 +0500 Added new functions to CAnimManager for CClientIFP commit 1330cb4 Author: idanish <danishroar@gmail.com> Date: Thu Mar 29 08:58:08 2018 +0500 Improved code design of CFileReader commit 1d9eb2b Author: idanish <danishroar@gmail.com> Date: Thu Mar 29 08:55:22 2018 +0500 Moved CIFPAnimations to deathmatch/logic commit 63b17a4 Author: idanish <danishroar@gmail.com> Date: Thu Mar 29 08:54:20 2018 +0500 Removed unused files commit 7f8ace6 Author: idanish <danishroar@gmail.com> Date: Thu Mar 29 08:53:26 2018 +0500 Removed IFPLoader include commit 997ec7d Author: idanish <danishroar@gmail.com> Date: Wed Mar 28 10:02:08 2018 +0500 Improved overall code quality. Methods are even more shorter now. commit c2a4195 Author: idanish <danishroar@gmail.com> Date: Wed Mar 28 03:52:30 2018 +0500 Improved CClientIFP design even more and some optimizations The code design was really bad. Methods were very long which made them hard to understand. Now, they are readable. commit 42e2109 Author: idanish <danishroar@gmail.com> Date: Tue Mar 27 23:38:29 2018 +0500 Improved IFP Readers, both Version 1 and 2. commit c6e089f Author: idanish <danishroar@gmail.com> Date: Tue Mar 27 23:08:20 2018 +0500 Added PraseSequenceVersion1 and PraseSequenceVersion2 commit 7dc2f6e Author: idanish <danishroar@gmail.com> Date: Tue Mar 27 06:36:59 2018 +0500 used iterator in ReadIFPVersion2 instead of C loop commit 5ba567d Author: idanish <danishroar@gmail.com> Date: Tue Mar 27 06:18:31 2018 +0500 Improved key frames reading logic for IFP Version 2 commit b5caa13 Author: idanish <danishroar@gmail.com> Date: Tue Mar 27 04:29:46 2018 +0500 Improved code readability. Still more improvement needed. commit 3e25495 Author: idanish <danishroar@gmail.com> Date: Tue Mar 27 04:28:45 2018 +0500 Moved structs and enums to CClientIFP class commit 412a42a Author: idanish <danishroar@gmail.com> Date: Tue Mar 27 04:28:01 2018 +0500 Added IFP_Animation struct and removed unused members. commit 7b2394c Author: idanish <danishroar@gmail.com> Date: Mon Mar 26 10:02:19 2018 +0500 Removed isIFPLoaded checks commit 6243ca4 Author: idanish <danishroar@gmail.com> Date: Mon Mar 26 10:02:01 2018 +0500 Removed printf commit a64710d Author: idanish <danishroar@gmail.com> Date: Mon Mar 26 09:24:23 2018 +0500 Removed useless function calls in DeleteElementSpecial commit 7cf982b Author: idanish <danishroar@gmail.com> Date: Mon Mar 26 06:33:02 2018 +0500 Using shared_ptr for CIFPAnimations commit 63398af Author: idanish <danishroar@gmail.com> Date: Mon Mar 26 06:31:50 2018 +0500 Created CIFPAnimations class for keeping IFP animations only commit 19f1156 Author: idanish <danishroar@gmail.com> Date: Sun Mar 25 05:15:54 2018 +0500 Replaced raw pointer with shared_ptr for CClientIFP commit 19aae47 Author: idanish <danishroar@gmail.com> Date: Sun Mar 25 05:15:07 2018 +0500 Added IS_IFP macro commit 6e80659 Author: idanish <danishroar@gmail.com> Date: Sat Mar 24 07:53:12 2018 +0500 Added InsertAnimationDummySequence with new parameters commit 85de6ed Author: idanish <danishroar@gmail.com> Date: Sat Mar 24 07:52:44 2018 +0500 Used factory pattern for Animation hierarchy and sequence commit 2b6170b Author: idanish <danishroar@gmail.com> Date: Sat Mar 24 07:52:11 2018 +0500 Added GetCustomAnimBlendHierarchy and GetCustomAnimBlendSequence commit 61b6232 Author: idanish <danishroar@gmail.com> Date: Sat Mar 24 07:51:50 2018 +0500 Added GetCustomAnimBlendHierarchy and GetCustomAnimBlendSequence commit ce30759 Author: idanish <danishroar@gmail.com> Date: Sat Mar 24 07:51:11 2018 +0500 Removed destructor commit ee23cd9 Author: idanish <danishroar@gmail.com> Date: Sat Mar 24 07:50:53 2018 +0500 Added animation hierarchy functions commit 7a6146d Author: idanish <danishroar@gmail.com> Date: Sat Mar 24 04:40:58 2018 +0500 Used Factory pattern for CAnimBlendSequenceSAInterface commit 991df8c Author: idanish <danishroar@gmail.com> Date: Sat Mar 24 04:39:58 2018 +0500 added GetAnimBlendSequence commit 80638dd Author: idanish <danishroar@gmail.com> Date: Sat Mar 24 04:39:31 2018 +0500 Added GetAnimBlendSequence commit d5e33c4 Author: idanish <danishroar@gmail.com> Date: Sat Mar 24 04:39:05 2018 +0500 Added functions for CAnimBlendSequence and SA commit f4d1c55 Merge: cc41b27 cc5b9ed Author: Code Nulls <danishroar@gmail.com> Date: Thu Mar 22 03:15:13 2018 +0500 Merge pull request #5 from saml1er/custom_ifp_animations Custom ifp animations [Fixed unloading] commit cc5b9ed Author: idanish <danishroar@gmail.com> Date: Thu Mar 22 03:09:06 2018 +0500 Removed CAnimBlendAssoc_Hierarchy_Constructor hook and handler commit e557b62 Author: idanish <danishroar@gmail.com> Date: Thu Mar 22 02:43:12 2018 +0500 Completed BlendAnimationHierarchy and CAnimBlendAssoc_Constructor These two hooks are meant to work in the same way. We can use anyone we wish to. BlendAnimationHierarchy is much cleaner and easy to understand, so let's use that one. Keep in mind that these two hooks get triggered for setPedAnimation only. They have nothing to do with AddAnimation and AddAniamtionAndSync commit bb4ed12 Author: idanish <danishroar@gmail.com> Date: Thu Mar 22 02:40:58 2018 +0500 Removed iAnimationSearchReferences. commit 16ed6f5 Author: idanish <danishroar@gmail.com> Date: Wed Mar 21 08:04:19 2018 +0500 Fixed unload crash. IFP is unloaded by checking references now. commit c60a3b2 Author: idanish <danishroar@gmail.com> Date: Wed Mar 21 08:03:15 2018 +0500 UnloadIFP calls DeleteIFPAnimations now and renamed iAnimSearchRef commit 8a67226 Author: idanish <danishroar@gmail.com> Date: Wed Mar 21 08:01:41 2018 +0500 Removed static for iAnimationSearchReferences commit e127b3c Author: idanish <danishroar@gmail.com> Date: Wed Mar 21 08:01:12 2018 +0500 ReplaceAnimation checks whether IFP is loaded or not commit 495220b Author: idanish <danishroar@gmail.com> Date: Wed Mar 21 08:00:01 2018 +0500 changed UnloadIFPAnimations to DeleteIFPAnimations commit a550ae1 Author: idanish <danishroar@gmail.com> Date: Wed Mar 21 05:07:45 2018 +0500 GetAnimationHierarchy loop breaks after hierarchy is found commit 65fdfe7 Author: idanish <danishroar@gmail.com> Date: Wed Mar 21 05:01:44 2018 +0500 s_iAnimationSearchReferences is checked before unloading IFP anims commit 44121e8 Author: idanish <danishroar@gmail.com> Date: Wed Mar 21 05:01:14 2018 +0500 added isIFPLoaded and s_iAnimationSearchReferences to CClientIFP commit 3b1acd7 Author: idanish <danishroar@gmail.com> Date: Wed Mar 21 02:53:18 2018 +0500 custom animation associations are kept in map for setPedAnimation commit f85b8f5 Author: idanish <danishroar@gmail.com> Date: Wed Mar 21 02:51:52 2018 +0500 inlined functions and added IFPAnimationsPointer functions commit c5ee5da Author: idanish <danishroar@gmail.com> Date: Tue Mar 20 21:02:54 2018 +0500 CopyAnimation handler now modifies pOutIFPAnimations. commit 47ea233 Author: idanish <danishroar@gmail.com> Date: Tue Mar 20 21:01:52 2018 +0500 Fixed CopyAnim hook and added mapOfCustomAnimationAssociations and its functions. commit fee333b Author: idanish <danishroar@gmail.com> Date: Tue Mar 20 21:00:11 2018 +0500 Changed getReplacedAnimation return type to SReplacedAnimation * commit f4258de Author: idanish <danishroar@gmail.com> Date: Tue Mar 20 20:59:18 2018 +0500 added GetIFPAnimationsPointer This function will get a pointer to SIFPAnimations struct of the IFP commit cb453c6 Author: idanish <danishroar@gmail.com> Date: Tue Mar 20 02:04:51 2018 +0500 Added CAnimBlendAssociation Contructor and Destructor handler This is for properly unloading IFP using SIFPAnimations struct. commit aab7940 Author: idanish <danishroar@gmail.com> Date: Mon Mar 19 21:12:34 2018 +0500 Moved custom animation hooks to a separate file commit 16a9c55 Author: idanish <danishroar@gmail.com> Date: Mon Mar 19 20:05:31 2018 +0500 [WIP] modifed CopyAnimation hook for SIFPAnimations This is needed for unloading IFP. We'll use this to increment and decrement iReferences in SIFPAnimations when an animation association is created and destroyed respectively. commit 90e784f Author: idanish <danishroar@gmail.com> Date: Mon Mar 19 20:00:26 2018 +0500 changed CopyAnimation handler prototype and added SIFPAnimatins commit f271bd5 Author: idanish <danishroar@gmail.com> Date: Mon Mar 19 19:59:36 2018 +0500 Added include guard and removed prototypes with CAnimBlock in them commit 44b516e Author: idanish <danishroar@gmail.com> Date: Mon Mar 19 19:58:49 2018 +0500 added SIFPAnimations and removed a member from IFP_Animation commit 8c9535e Author: idanish <danishroar@gmail.com> Date: Mon Mar 19 19:57:48 2018 +0500 Animations are stored in SIFPAnimations struct now commit 10506ea Author: idanish <danishroar@gmail.com> Date: Mon Mar 19 19:56:37 2018 +0500 added a new parameter and changed return type of AssocGroupCopyAnimation Added SIFPAnimations ** as a new parameter and changed the return type to bool for both ( static and none static ) handlers of AssocGroupCopyAnimation commit d84dc88 Author: idanish <danishroar@gmail.com> Date: Mon Mar 19 19:48:20 2018 +0500 just added some padding, nothing special commit 3c44bcc Author: idanish <danishroar@gmail.com> Date: Fri Mar 16 23:30:24 2018 +0500 added a check in GetAnimationHierarchy whether IFP is loaded or not commit cc41b27 Merge: c3fb1aa b8a92b0 Author: Code Nulls <danishroar@gmail.com> Date: Fri Mar 16 12:02:22 2018 +0500 Merge pull request #4 from saml1er/custom_ifp_animations Custom ifp animations commit b8a92b0 Author: idanish <danishroar@gmail.com> Date: Fri Mar 16 11:52:57 2018 +0500 engineReplaceAnimation and engineRestoreAnimation is complete commit 54c1a03 Author: idanish <danishroar@gmail.com> Date: Fri Mar 16 11:51:25 2018 +0500 IFP pointer is removed first from map then onClientIFPUnload is called commit f4691ad Author: idanish <danishroar@gmail.com> Date: Fri Mar 16 11:49:48 2018 +0500 added GetResourceIFPRoot inline function commit 4ed6ef9 Author: idanish <danishroar@gmail.com> Date: Fri Mar 16 11:46:00 2018 +0500 added missing member pLinkPtr to Hierarchy interface commit fa75a7b Author: idanish <danishroar@gmail.com> Date: Fri Mar 16 11:45:35 2018 +0500 Added missing members to CAnimBlockSAInterface commit c3fb1aa Merge: 64ba51c 222bfe9 Author: Code Nulls <danishroar@gmail.com> Date: Thu Mar 15 01:15:05 2018 +0500 Merge pull request #3 from saml1er/custom_ifp_animations Custom ifp animations commit 222bfe9 Author: idanish <danishroar@gmail.com> Date: Thu Mar 15 01:09:06 2018 +0500 No longer using global variables in animation hooks commit d9027b5 Author: idanish <danishroar@gmail.com> Date: Wed Mar 14 22:16:50 2018 +0500 Static association is initialized within AssocGroupCopyAnimationHandler The typedef "hCAnimBlendStaticAssociation_Init" needs to deleted for production code. We need to properly use factory method. commit bd58fa4 Author: idanish <danishroar@gmail.com> Date: Wed Mar 14 22:14:55 2018 +0500 Static association is created and destroyed within CopyAnimation hook commit 1ad24fe Author: idanish <danishroar@gmail.com> Date: Wed Mar 14 22:05:24 2018 +0500 added typedef for CAnimBlendStaticAssociation::FreeSequenceArray commit 62b3d09 Author: idanish <danishroar@gmail.com> Date: Wed Mar 14 14:45:34 2018 +0500 Created a new AssocGroupCopyAnimation handler commit 1694765 Author: idanish <danishroar@gmail.com> Date: Wed Mar 14 14:43:04 2018 +0500 Added constexpr getAnimAssocGroupInterface function. commit 9b578f9 Author: idanish <danishroar@gmail.com> Date: Tue Mar 13 23:03:32 2018 +0500 optimized CopyAnimation hook for saving tons of RAM If we created a new static association for every player for every single animation then it means for 1000 players, the memory might exceed 400mb, that's a lot. Why not destroy the static association when we copy the animation from it? That's exactly what's happening in the hook now. commit e17b895 Author: idanish <danishroar@gmail.com> Date: Tue Mar 13 14:34:02 2018 +0500 Added ability to replace GTA internal animations. Modified AddAnimation, AddAnimationAndSync, and CopyAnimation for replacing GTA internal animations with custom animations. We'll need to create our own static association when engineReplaceAnimation is called and use that static association for a specific ped/player to play our custom animation instead. commit 2600653 Author: idanish <danishroar@gmail.com> Date: Tue Mar 13 14:29:48 2018 +0500 Removed code from AddAnimationHandler and AddAnimationAndSyncHandler The code worked perfectly except for custom CopyAnimation function, if we tried to rewrite this function, it would crash. commit af38b5f Author: idanish <danishroar@gmail.com> Date: Tue Mar 13 14:26:51 2018 +0500 Removed CopyAnimation hook in InitHooks_FixBadAnimId commit 5c0f65a Author: idanish <danishroar@gmail.com> Date: Sat Mar 10 12:17:33 2018 +0500 Rewrote animation hooks properly in CClientGame and CMultiplayerSA I renamed BlendAnimation hook to BlendAnimationHierarchy because now it's hooking a different BlendAnimation function that takes an animation hierarchy as argument. Also, I separated AddAnimation and AddAnimationAndSync hooks and their handlers. Now, they work independently. Also, there was a problem with AddAnimationAndSync hook in CMultiplayerSA.cpp, I fixed the return of the hook. commit 1398945 Author: idanish <danishroar@gmail.com> Date: Sat Mar 10 08:55:22 2018 +0500 [FIX] Fixed AddAnimation hook and disabled AddAnimationAndSync hook. I used Original code for AddAnimation hook in CClientGame::AddAnimationHandler. It works well. Now, it's time to create our own CAnimBlendAssociationSAInterface instead of using CopyAnimation. I'll need to enable AddAnimationAndSync hook as well because this is called for almost every internal GTA animation. commit 64ba51c Merge: aa722ff 7e4ad6c Author: Code Nulls <danishroar@gmail.com> Date: Thu Mar 8 16:04:18 2018 +0500 Merge pull request #2 from saml1er/custom_ifp_animations Working custom IFP animations commit 7e4ad6c Author: idanish <danishroar@gmail.com> Date: Thu Mar 8 15:57:45 2018 +0500 Removed CClient Ped pointer map functions commit 7f18adc Author: idanish <danishroar@gmail.com> Date: Thu Mar 8 15:57:17 2018 +0500 enabled AddAnimation hook commit b0157a8 Author: idanish <danishroar@gmail.com> Date: Thu Mar 8 15:57:07 2018 +0500 Animation name is now checked in engineLoadIFP whether the hierarchy exists or not commit d153d3b Author: idanish <danishroar@gmail.com> Date: Thu Mar 8 15:56:30 2018 +0500 Fixes in ModelRequestCallBack and CClientPed constructor and destructor. Removed code for inserting and remove clump from map in ModelRequestCallBack. Also, CClientPed is inserted into map in constructor call and removed when destructor is called. commit c529467 Author: idanish <danishroar@gmail.com> Date: Thu Mar 8 15:54:09 2018 +0500 Added new functions for finding CClientPed by clump and used it in BlendAnimationHandler commit f131323 Author: idanish <danishroar@gmail.com> Date: Thu Mar 8 15:51:13 2018 +0500 [BUGGY] Added a new function GetclientPedByClump, but causes crash sometimes commit ecb3dc5 Author: idanish <danishroar@gmail.com> Date: Thu Mar 8 15:50:35 2018 +0500 Removed CClientPed pointer map functions commit 2259c87 Author: idanish <danishroar@gmail.com> Date: Thu Mar 8 06:13:41 2018 +0500 Block name is now checked when loading IFP. Before you could load many IFPs with same block name and it would cause memory leaks, now it's fixed. commit a9a8066 Author: idanish <danishroar@gmail.com> Date: Thu Mar 8 06:11:31 2018 +0500 [FIX] unloadIFP function works good now. commit 76f2d02 Author: idanish <danishroar@gmail.com> Date: Tue Mar 6 07:34:47 2018 +0500 setPedAnimation finally works for playing custom animations. Both GTA VC and SA have been tested. commit a467ae9 Author: idanish <danishroar@gmail.com> Date: Tue Mar 6 07:32:26 2018 +0500 changed BlendAnimationHandler hook resturn type commit c39f14c Author: idanish <danishroar@gmail.com> Date: Tue Mar 6 07:31:54 2018 +0500 BlendAnimation hook has been changed to BlendAnimation_Hierarchy hook because that is only triggered when setPedAnimation is called. Commented AddAnimation hook for now, it can be used for engineRestoreAnimation and engineReplaceAnimation along with AddAnimationAndSync hook commit 357acfc Author: idanish <danishroar@gmail.com> Date: Tue Mar 6 07:29:32 2018 +0500 added a Name member to IFP_Animation struct for keeping the animation name commit 05289e1 Author: idanish <danishroar@gmail.com> Date: Tue Mar 6 07:28:43 2018 +0500 [FIX] Fixed custom animations crashing by changing keyframes memory allocator from malloc to OLD_CMemoryMgr_Malloc which is GTA SA function commit ac2ef96 Author: idanish <danishroar@gmail.com> Date: Tue Mar 6 07:26:57 2018 +0500 pInterface variable is initialized to nullptr in GetAnimStaticAssociation commit a97d89a Author: idanish <danishroar@gmail.com> Date: Tue Mar 6 07:26:25 2018 +0500 change pAnimBlendNodesSequenceArray type from int * to DWORD * in CAnimBlendStaticAssociationSA commit 6037280 Author: idanish <danishroar@gmail.com> Date: Tue Mar 6 07:25:43 2018 +0500 fixed bRunningCompressed in CAnimBlendHierarchySAInterface commit d8337a5 Author: idanish <danishroar@gmail.com> Date: Sun Mar 4 21:46:07 2018 +0500 changed BlendAnimation hook to BlendAnimation_Hierarchy and hooks works fine. It is called when you execute setPedAnimation from client lua. This is where we can play custom animation commit aa722ff Merge: ceb5663 80aec0e Author: Code Nulls <danishroar@gmail.com> Date: Sun Mar 4 12:40:39 2018 +0500 Merge pull request #1 from saml1er/custom_ifp_animations Custom ifp animations commit 80aec0e Author: idanish <danishroar@gmail.com> Date: Sun Mar 4 12:28:59 2018 +0500 added IFP function prototypes and a map container for retrieving IFP pointer by custom IFP block name commit c1d7814 Author: idanish <danishroar@gmail.com> Date: Sun Mar 4 12:28:10 2018 +0500 added a boolean for checking next animation whether it's custom or not in CClientPed::CClientPed. Renamed PedClump function calls to PedPointer functions commit 333ff15 Author: idanish <danishroar@gmail.com> Date: Sun Mar 4 12:26:50 2018 +0500 remove PedClump map functions to PedPointer map functions. Also added GetWayBlockName and GetGateWayAnimationName commit 9de0774 Author: idanish <danishroar@gmail.com> Date: Sun Mar 4 12:25:58 2018 +0500 custom IFP pointer is removed from map container when unloaded. commit 0ba8e13 Author: idanish <danishroar@gmail.com> Date: Sun Mar 4 12:25:12 2018 +0500 added new functions for adding IFP pointer to map and checks for playing custom animation, not complete though. Custom animation is checked nicely, but isGateWayAnimationHierarchy function is not working properly. commit acf46a7 Author: idanish <danishroar@gmail.com> Date: Sun Mar 4 12:22:20 2018 +0500 IFP pointer is inserted to map if IFP is loaded sucessfully commit df06f10 Author: idanish <danishroar@gmail.com> Date: Sun Mar 4 12:21:14 2018 +0500 Modified setPedAnimation to play custom animation commit b44dfc1 Author: idanish <danishroar@gmail.com> Date: Sun Mar 4 12:20:39 2018 +0500 added new functions isNextAnimationCustom, setNextAnimationCustom, and setNextAnimationNormal commit bf5e7dc Author: idanish <danishroar@gmail.com> Date: Sun Mar 4 12:14:36 2018 +0500 added GetGateWayAnimationName and GetGateWayBlockName. Renamed PedClump to PedPointer of m_mapofPedPointers' functions commit d4b20dd Author: idanish <danishroar@gmail.com> Date: Sun Mar 4 06:00:11 2018 +0500 [FIX] Memory of dummy sequences' frames was not being freed for IFP Version 2. Now, it's being freed commit 9af78ea Author: idanish <danishroar@gmail.com> Date: Sun Mar 4 02:34:08 2018 +0500 [FIX] Memory was not being freed properly for IFP Version 2, fixed it by adding a check. Also the loop for sequences in unloadIFP was incorrect, fixed that as well. Tested by checking the pointers and frees the memory properly now commit d64f8b3 Author: idanish <danishroar@gmail.com> Date: Sat Mar 3 09:55:42 2018 +0500 [BAD DESIGN] Implemented temporary UnloadIFP function for unloading IFPs while testing. Also, using malloc instead of OLD_CMemoryMgr_Malloc. commit 1983a2a Author: idanish <danishroar@gmail.com> Date: Sat Mar 3 09:53:54 2018 +0500 [IMPORTANT] Fixed heap corruption by adding int32_t to IFP_ANIM struct and fixed IFP_Animation struct. commit 25e3a3e Author: idanish <danishroar@gmail.com> Date: Sat Mar 3 09:48:05 2018 +0500 fixed private variables commit e727d19 Author: idanish <danishroar@gmail.com> Date: Sat Mar 3 04:16:02 2018 +0500 [BAD DESIGN] added IFP loader. It works properly, but the design is horrible. We'll need to properly rewrite it according to MTA's coding guidelines. Also, there is no function for unloading IFP, so yeah there are memory leaks. Dynamic memory allocation is used for sequeneces and key frames only, so freeing this memory is important. commit 556bcec Author: idanish <danishroar@gmail.com> Date: Sat Mar 3 02:23:08 2018 +0500 commented printf in CClient::LoadIFP and CClient::UnloadIFP commit 6e3d7d1 Author: idanish <danishroar@gmail.com> Date: Sat Mar 3 02:22:12 2018 +0500 moved GATEWAY_ANIMATION_NAME from global space into CAnimManagerSA class. Also, renamed it to m_kGateWayAnimationName. commit eb23760 Author: idanish <danishroar@gmail.com> Date: Sat Mar 3 00:22:32 2018 +0500 [NOT TESTED] isGateWayAnimationHierarchy is called in AddAnimationHandler for checking and playing custom animation, but it is not tested because IFP reader needs to be added asap. commit b5a6198 Author: idanish <danishroar@gmail.com> Date: Sat Mar 3 00:20:58 2018 +0500 added GetAnimStaticAssociation prototype to CAnimManagerSA class and added gateway animation constant, value is set to "run_wuzi" for gateway animation commit 098da77 Author: idanish <danishroar@gmail.com> Date: Sat Mar 3 00:19:47 2018 +0500 fixed GetAnimAssociation function and renamed it to GetAnimstaticAssociation, also implemented isGateWayAnimationHierarchy commit da68248 Author: idanish <danishroar@gmail.com> Date: Sat Mar 3 00:16:35 2018 +0500 added isGateWayAnimationHierarchy prototype to class commit e2bf58c Author: idanish <danishroar@gmail.com> Date: Sat Mar 3 00:14:46 2018 +0500 completed CAnimBlendStaticAssociationSAInterface class members by adding missing vTable, nNumBlendNodes, and pAnimBlendNodesSequeceArray commit 1514322 Author: idanish <danishroar@gmail.com> Date: Sat Mar 3 00:13:20 2018 +0500 changed iHashKey type from int to unsigned int since it's generated using CKeyGen::GetUpperCaseKey commit f90ff66 Author: idanish <danishroar@gmail.com> Date: Fri Mar 2 18:50:43 2018 +0500 added CClientIFP class, but the functions in there are pretty much empty commit 1483f61 Author: idanish <danishroar@gmail.com> Date: Fri Mar 2 18:49:54 2018 +0500 added additional parameter to engineLoadIFP for custom block name commit 4fddf96 Author: idanish <danishroar@gmail.com> Date: Fri Mar 2 17:07:48 2018 +0500 added scripting function engineLoadIFP for loading IFP on client. CClientIFP::LoadIFP is empty for now. commit 26210bc Author: idanish <danishroar@gmail.com> Date: Fri Mar 2 17:06:13 2018 +0500 added IFP entity commit ceb5663 Author: idanish <danishroar@gmail.com> Date: Thu Mar 1 20:56:57 2018 +0500 correct CClientPed * is returned from GetClientPedFromClumpMap to check to whom the clump belongs and what animation to play, it can be a custom animation as well. commit c931b4c Author: idanish <danishroar@gmail.com> Date: Thu Mar 1 20:54:17 2018 +0500 In ModelRequestCallback, old clump is removed from CAnimManagerSA::m_mapOfPedClumps and new clump is inserted into the map commit 7705414 Author: idanish <danishroar@gmail.com> Date: Thu Mar 1 20:52:45 2018 +0500 added 3 new functions for finding the correct CClientPed * in a map of Ped clumps. commit ff8e9b9 Author: idanish <danishroar@gmail.com> Date: Thu Mar 1 20:51:00 2018 +0500 Removed hCAnimBlendAssocGroup_CopyAnimation typedef commit 76940cc Author: idanish <danishroar@gmail.com> Date: Thu Mar 1 07:38:23 2018 +0500 Using factory method for access association group, instead of ugly direct memory access commit fe9e27b Author: idanish <danishroar@gmail.com> Date: Thu Mar 1 07:37:06 2018 +0500 added CreateAnimBlendAssocGroup function, also fixed tiny bits of formatting commit d097ada Author: idanish <danishroar@gmail.com> Date: Thu Mar 1 07:36:14 2018 +0500 added CreateAnimBlendAssocGroup and getAnimAssocGroupInterface functions commit 26dc2b3 Author: idanish <danishroar@gmail.com> Date: Thu Mar 1 07:35:17 2018 +0500 removed a space, nothing else commit 6b1a4db Author: idanish <danishroar@gmail.com> Date: Thu Mar 1 02:53:57 2018 +0500 removed 2 instructions in HOOK_CAnimManager_AddAnimation, because they were not needed commit 6b6cff2 Author: idanish <danishroar@gmail.com> Date: Wed Feb 28 13:50:14 2018 +0500 Modified AddAnimation hook to skip CopyAnimation function call, if m_pAddanimationHandler is nullptr/NULL then normal function flow executes to avoid crash commit 8fe6bc4 Author: idanish <danishroar@gmail.com> Date: Wed Feb 28 13:48:34 2018 +0500 Aligned all function prototypes properly to match StaticAddAnimationHandler prototype commit 0eb7080 Author: idanish <danishroar@gmail.com> Date: Wed Feb 28 13:47:04 2018 +0500 changed CAnimBlendAssociation * to CAnimBlendAssociationSAInterface * commit bba1a39 Author: idanish <danishroar@gmail.com> Date: Wed Feb 28 04:56:08 2018 +0500 added typedef of CAnimBlendAssocGroup::CopyAnimation and changed return type of StaticAddAnimationHandler and AddAnimationHandler to CAnimBlendAssociation * commit d860cb8 Author: idanish <danishroar@gmail.com> Date: Wed Feb 28 04:54:45 2018 +0500 added CopyAnimation function commit dba18b6 Author: idanish <danishroar@gmail.com> Date: Wed Feb 28 04:54:11 2018 +0500 Animation is copied using CopyAnimation function and the result is returned by AddAnimationHandler commit 3771953 Author: idanish <danishroar@gmail.com> Date: Wed Feb 28 04:53:17 2018 +0500 changed return type of AddAnimationHandler to CAnimBlendAssociation * commit 80a7554 Author: idanish <danishroar@gmail.com> Date: Wed Feb 28 04:52:22 2018 +0500 added CopyAnimation function commit 86d070d Author: idanish <danishroar@gmail.com> Date: Wed Feb 28 04:49:16 2018 +0500 added a new function "CopyAnimation." commit 894b4f6 Author: idanish <danishroar@gmail.com> Date: Wed Feb 28 04:48:04 2018 +0500 Displays Console. I'm only using it for testing
1 parent 05fbbfb commit 15f99b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3299
-227
lines changed

Client/game_sa/CAnimBlendAssocGroupSA.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@ CAnimBlendAssocGroupSA::CAnimBlendAssocGroupSA(CAnimBlendAssocGroupSAInterface*
1818
SetupAnimBlock();
1919
}
2020

21+
CAnimBlendAssociationSAInterface* CAnimBlendAssocGroupSA::CopyAnimation(unsigned int AnimID)
22+
{
23+
CAnimBlendAssociationSAInterface* pAnimAssociationReturn = nullptr;
24+
25+
DWORD dwThis = (DWORD)m_pInterface;
26+
DWORD dwFunc = FUNC_CAnimBlendAssocGroup_CopyAnimation;
27+
_asm
28+
{
29+
mov ecx, dwThis
30+
push AnimID
31+
call dwFunc
32+
mov pAnimAssociationReturn, eax
33+
}
34+
return pAnimAssociationReturn;
35+
}
36+
2137
void CAnimBlendAssocGroupSA::InitEmptyAssociations(RpClump* pClump)
2238
{
2339
DWORD dwThis = (DWORD)m_pInterface;

Client/game_sa/CAnimBlendAssocGroupSA.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "Common.h"
1818

1919
#define FUNC_CAnimBlendAssocGroup_InitEmptyAssociations 0x4cdfb0
20+
#define FUNC_CAnimBlendAssocGroup_CopyAnimation 0x4ce130
2021
#define FUNC_CAnimBlendAssocGroup_IsCreated 0x4d37a0
2122
#define FUNC_CAnimBlendAssocGroup_GetNumAnimations 0x45b050
2223
#define FUNC_CAnimBlendAssocGroup_GetAnimBlock 0x45b060
@@ -44,12 +45,14 @@ class CAnimBlendAssocGroupSA : public CAnimBlendAssocGroup
4445
public:
4546
CAnimBlendAssocGroupSA(CAnimBlendAssocGroupSAInterface* pInterface);
4647

47-
void InitEmptyAssociations(RpClump* pClump);
48-
bool IsCreated(void);
49-
int GetNumAnimations(void);
50-
CAnimBlock* GetAnimBlock(void);
51-
CAnimBlendStaticAssociation* GetAnimation(unsigned int ID);
52-
void CreateAssociations(const char* szBlockName);
48+
CAnimBlendAssociationSAInterface* CopyAnimation(unsigned int AnimID);
49+
void InitEmptyAssociations(RpClump* pClump);
50+
bool IsCreated(void);
51+
int GetNumAnimations(void);
52+
CAnimBlock* GetAnimBlock(void);
53+
CAnimBlendStaticAssociation* GetAnimation(unsigned int ID);
54+
AssocGroupId GetGroupID(void) { return m_pInterface->groupID; };
55+
void CreateAssociations(const char* szBlockName);
5356

5457
bool IsLoaded(void);
5558
void SetIDOffset(int iOffset) { m_pInterface->iIDOffset = iOffset; }

Client/game_sa/CAnimBlendAssociationSA.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class CAnimBlendAssociationSAInterface
3535
short sAnimID; // 44
3636
short sFlags; // or1 = started?, or64 = referenced? // 46
3737
DWORD* pCallback; // 48
38+
DWORD* pCallbackFunc; // 52
39+
DWORD* pCallbackData; // 56
40+
// Total: 60 bytes
3841
};
3942

4043
class CAnimBlendAssociationSA : public CAnimBlendAssociation

Client/game_sa/CAnimBlendHierarchySA.cpp

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,81 @@
1111

1212
#include "StdInc.h"
1313

14+
// Careful, GetIndex will not work for custom animations
1415
int CAnimBlendHierarchySAInterface::GetIndex(void)
1516
{
1617
return (((DWORD)this - ARRAY_CAnimManager_Animations) / 24);
1718
}
19+
20+
void CAnimBlendHierarchySA::Initialize(void)
21+
{
22+
m_pInterface->pSequences = 0;
23+
m_pInterface->usNumSequences = 0;
24+
m_pInterface->bRunningCompressed = 0;
25+
m_pInterface->pad = 0;
26+
m_pInterface->iAnimBlockID = -1;
27+
m_pInterface->fTotalTime = 0;
28+
m_pInterface->pLinkPtr = 0;
29+
}
30+
31+
void CAnimBlendHierarchySA::SetName(const char* szName)
32+
{
33+
DWORD dwThis = (DWORD)m_pInterface;
34+
DWORD dwFunc = FUNC_CAnimBlendHierarchy_SetName;
35+
_asm
36+
{
37+
push szName
38+
mov ecx, dwThis
39+
call dwFunc
40+
}
41+
}
42+
43+
void CAnimBlendHierarchySA::RemoveAnimSequences(void)
44+
{
45+
DWORD dwThis = (DWORD)m_pInterface;
46+
DWORD dwFunc = FUNC_CAnimBlendHierarchy_RemoveAnimSequences;
47+
_asm
48+
{
49+
mov ecx, dwThis
50+
call dwFunc
51+
}
52+
}
53+
54+
void CAnimBlendHierarchySA::RemoveFromUncompressedCache(void)
55+
{
56+
DWORD dwThis = (DWORD)m_pInterface;
57+
DWORD dwFunc = FUNC_CAnimBlendHierarchy_RemoveFromUncompressedCache;
58+
_asm
59+
{
60+
mov ecx, dwThis
61+
call dwFunc
62+
}
63+
}
64+
65+
void CAnimBlendHierarchySA::RemoveQuaternionFlips(void)
66+
{
67+
DWORD dwThis = (DWORD)m_pInterface;
68+
DWORD dwFunc = FUNC_CAnimBlendHierarchy_RemoveQuaternionFlips;
69+
_asm
70+
{
71+
mov ecx, dwThis
72+
call dwFunc
73+
}
74+
}
75+
76+
void CAnimBlendHierarchySA::CalculateTotalTime(void)
77+
{
78+
DWORD dwThis = (DWORD)m_pInterface;
79+
DWORD dwFunc = FUNC_CAnimBlendHierarchy_CalculateTotalTime;
80+
_asm
81+
{
82+
mov ecx, dwThis
83+
call dwFunc
84+
}
85+
}
86+
87+
CAnimBlendSequenceSAInterface* CAnimBlendHierarchySA::GetSequence(DWORD dwIndex)
88+
{
89+
BYTE* pSequences = reinterpret_cast<BYTE*>(m_pInterface->pSequences);
90+
return reinterpret_cast<CAnimBlendSequenceSAInterface*>(pSequences + (sizeof(CAnimBlendSequenceSAInterface) * dwIndex));
91+
}

Client/game_sa/CAnimBlendHierarchySA.h

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,53 @@
1717
#include <game/CAnimBlendHierarchy.h>
1818
#include "Common.h"
1919

20-
#define FUNC_CAnimBlendHierarchy_GetAnimSequence 0x4ce8f0
21-
#define FUNC_CAnimBlendHierarchy_GetAnimSequences 0x4d1350
20+
#define FUNC_CAnimBlendHierarchy_SetName 0x4CF2D0
21+
#define FUNC_CAnimBlendHierarchy_RemoveAnimSequences 0x4CF8E0
22+
#define FUNC_CAnimBlendHierarchy_RemoveFromUncompressedCache 0x4D42A0
23+
#define FUNC_CAnimBlendHierarchy_RemoveQuaternionFlips 0x4CF4E0
24+
#define FUNC_CAnimBlendHierarchy_CalculateTotalTime 0x4CF2F0
25+
#define FUNC_CAnimBlendHierarchy_GetAnimSequence 0x4ce8f0
26+
#define FUNC_CAnimBlendHierarchy_GetAnimSequences 0x4d1350
2227

2328
class CAnimBlendSequence;
2429

2530
class CAnimBlendHierarchySAInterface
2631
{
2732
public:
28-
int GetIndex(void);
29-
int iHashKey;
30-
CAnimBlendSequence* pSequences;
31-
unsigned short usNumSequences;
32-
BYTE pad;
33-
bool bRunningCompressed;
34-
int iAnimBlockID;
35-
float fTotalTime;
33+
// Careful, GetIndex will not work for custom animations
34+
int GetIndex(void);
35+
36+
unsigned int iHashKey;
37+
CAnimBlendSequenceSAInterface* pSequences;
38+
unsigned short usNumSequences;
39+
bool bRunningCompressed;
40+
BYTE pad;
41+
int iAnimBlockID;
42+
float fTotalTime;
43+
DWORD* pLinkPtr;
3644
// class CLink<class CAnimBlendHierarchy *> * pLinkPtr;
3745
};
3846

3947
class CAnimBlendHierarchySA : public CAnimBlendHierarchy
4048
{
4149
public:
4250
CAnimBlendHierarchySA(CAnimBlendHierarchySAInterface* pInterface) { m_pInterface = pInterface; }
43-
44-
CAnimBlendHierarchySAInterface* GetInterface(void) { return m_pInterface; }
51+
void Initialize(void);
52+
void SetName(const char* szName);
53+
void SetSequences(CAnimBlendSequenceSAInterface* pSequences) { m_pInterface->pSequences = pSequences; }
54+
void SetNumSequences(unsigned short uNumSequences) { m_pInterface->usNumSequences = uNumSequences; }
55+
void SetRunningCompressed(bool bCompressed) { m_pInterface->bRunningCompressed = bCompressed; }
56+
void SetAnimationBlockID(int iBlockID) { m_pInterface->iAnimBlockID = iBlockID; }
57+
void RemoveAnimSequences(void);
58+
void RemoveFromUncompressedCache(void);
59+
void RemoveQuaternionFlips(void);
60+
void CalculateTotalTime(void);
61+
CAnimBlendSequenceSAInterface* GetSequence(DWORD dwIndex);
62+
CAnimBlendSequenceSAInterface* GetSequences(void) { return m_pInterface->pSequences; }
63+
unsigned short GetNumSequences(void) { return m_pInterface->usNumSequences; }
64+
bool isRunningCompressed(void) { return m_pInterface->bRunningCompressed; }
4565
int GetAnimBlockID(void) { return m_pInterface->iAnimBlockID; }
66+
CAnimBlendHierarchySAInterface* GetInterface(void) { return m_pInterface; }
4667

4768
protected:
4869
CAnimBlendHierarchySAInterface* m_pInterface;

Client/game_sa/CAnimBlendSequenceSA.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,60 @@
1010
*****************************************************************************/
1111

1212
#include "StdInc.h"
13+
14+
void CAnimBlendSequenceSA::Initialize(void)
15+
{
16+
m_pInterface->m_boneId = -1;
17+
m_pInterface->sFlags = 0;
18+
m_pInterface->sNumKeyFrames = 0;
19+
m_pInterface->pKeyFrames = 0;
20+
}
21+
22+
void CAnimBlendSequenceSA::SetName(const char* szName)
23+
{
24+
DWORD dwThis = (DWORD)m_pInterface;
25+
DWORD dwFunc = FUNC_CAnimBlendSequence_SetName;
26+
_asm
27+
{
28+
push szName
29+
mov ecx, dwThis
30+
call dwFunc
31+
}
32+
}
33+
34+
void CAnimBlendSequenceSA::SetBoneTag(int32_t i32BoneID)
35+
{
36+
DWORD dwThis = (DWORD)m_pInterface;
37+
DWORD dwFunc = FUNC_CAnimBlendSequence_SetBoneTag;
38+
_asm
39+
{
40+
push i32BoneID
41+
mov ecx, dwThis
42+
call dwFunc
43+
}
44+
}
45+
46+
void CAnimBlendSequenceSA::SetKeyFrames(size_t cKeyFrames, bool bRoot, bool bCompressed, void* pKeyFrames)
47+
{
48+
DWORD dwThis = (DWORD)m_pInterface;
49+
DWORD dwFunc = FUNC_CAnimBlendSequence_SetKeyFrames;
50+
_asm
51+
{
52+
push pKeyFrames
53+
push bCompressed
54+
push bRoot
55+
push cKeyFrames
56+
mov ecx, dwThis
57+
call dwFunc
58+
}
59+
}
60+
61+
void CAnimBlendSequenceSA::CopySequenceProperties(CAnimBlendSequenceSAInterface* pAnimSequenceInterface)
62+
{
63+
*m_pInterface = *pAnimSequenceInterface;
64+
}
65+
66+
void* CAnimBlendSequenceSA::GetKeyFrame(size_t iFrame, uint32_t u32FrameSizeInBytes)
67+
{
68+
return (m_pInterface->pKeyFrames + u32FrameSizeInBytes * iFrame);
69+
}

Client/game_sa/CAnimBlendSequenceSA.h

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,38 @@
1414

1515
#include <game/CAnimBlendSequence.h>
1616

17+
#define FUNC_CAnimBlendSequence_SetName 0x4D0C50
18+
#define FUNC_CAnimBlendSequence_SetBoneTag 0x4D0C70
19+
#define FUNC_CAnimBlendSequence_SetKeyFrames 0x4D0CD0
20+
1721
class CAnimBlendSequenceSAInterface
1822
{
1923
public:
20-
unsigned int iHashKey; // Get/SetBoneTag accesses the first? 2 bytes here
21-
short sFlags; // 4 // or16=bHasBoneTag
22-
short sNumKeyFrames; // 6
23-
class CAnimBlendKeyFrame* pKeyFrames; // ?
24+
union {
25+
uint16_t m_boneId; // m_boneId is set if ( sFlags & 0x10u ) is true
26+
uint32_t m_hash; // otherwise m_hash is set
27+
};
28+
unsigned short sFlags;
29+
unsigned short sNumKeyFrames;
30+
BYTE* pKeyFrames;
2431
};
2532

2633
class CAnimBlendSequenceSA : public CAnimBlendSequence
2734
{
2835
public:
2936
CAnimBlendSequenceSA(CAnimBlendSequenceSAInterface* pInterface) { m_pInterface = pInterface; }
37+
void Initialize(void);
38+
void SetName(const char* szName);
39+
void SetBoneTag(int32_t i32BoneID);
40+
void SetKeyFrames(size_t cKeyFrames, bool bRoot, bool bCompressed, void* pKeyFrames);
41+
void* GetKeyFrame(size_t iFrame, uint32_t u32FrameSizeInBytes);
42+
uint32_t GetHash(void) { return m_pInterface->m_hash; }
43+
uint16_t GetBoneTag(void) { return m_pInterface->m_boneId; }
44+
BYTE* GetKeyFrames(void) { return m_pInterface->pKeyFrames; }
45+
unsigned short GetKeyFramesCount(void) { return m_pInterface->sNumKeyFrames; }
46+
bool IsBigChunkForAllSequences(void) { return ((m_pInterface->sFlags >> 3) & 1); }
47+
void CopySequenceProperties(CAnimBlendSequenceSAInterface* pAnimSequenceInterface);
48+
CAnimBlendSequenceSAInterface* GetInterface(void) { return m_pInterface; }
3049

3150
protected:
3251
CAnimBlendSequenceSAInterface* m_pInterface;

Client/game_sa/CAnimBlendStaticAssociationSA.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@
1111

1212
#include "StdInc.h"
1313

14-
CAnimBlendHierarchy* CAnimBlendStaticAssociationSA::GetAnimHierachy(void)
14+
void CAnimBlendStaticAssociationSA::Initialize(RpClump* pClump, CAnimBlendHierarchySAInterface* pAnimBlendHierarchyInterface)
1515
{
16-
return NULL;
16+
DWORD dwThis = (DWORD)m_pInterface;
17+
DWORD dwFunc = FUNC_CAnimBlendStaticAssociation_Initialize;
18+
_asm
19+
{
20+
push pAnimBlendHierarchyInterface
21+
push pClump
22+
mov ecx, dwThis
23+
call dwFunc
24+
}
1725
}

Client/game_sa/CAnimBlendStaticAssociationSA.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,41 @@
1717
#include <game/CAnimBlendStaticAssociation.h>
1818
#include "Common.h"
1919

20+
#define FUNC_CAnimBlendStaticAssociation_Initialize 0x4CEC20
21+
2022
class CAnimBlendAssocGroupSA;
2123
class CAnimBlendHierarchySAInterface;
2224
class CAnimBlendHierarchy;
2325

2426
class CAnimBlendStaticAssociationSAInterface
2527
{
28+
protected:
29+
void* vTable;
30+
2631
public:
27-
BYTE pad[6];
32+
unsigned short nNumBlendNodes;
2833
short sAnimID;
2934
short sAnimGroup;
3035
short sFlags;
31-
BYTE pad2[4];
36+
int* pAnimBlendNodesSequenceArray;
3237
CAnimBlendHierarchySAInterface* pAnimHeirarchy;
3338
};
3439

3540
class CAnimBlendStaticAssociationSA : public CAnimBlendStaticAssociation
3641
{
3742
public:
3843
CAnimBlendStaticAssociationSA(CAnimBlendStaticAssociationSAInterface* pInterface) { m_pInterface = pInterface; }
39-
40-
CAnimBlendHierarchy* GetAnimHierachy(void);
44+
void Initialize(RpClump* pClump, CAnimBlendHierarchySAInterface* pAnimBlendHierarchyInterface);
45+
void SetNumBlendNodes(unsigned short nNumBlendNodes) { m_pInterface->nNumBlendNodes = nNumBlendNodes; };
46+
void SetAnimID(short sAnimID) { m_pInterface->sAnimID = sAnimID; }
47+
void SetAnimGroup(short sAnimGroup) { m_pInterface->sAnimGroup = sAnimGroup; }
48+
void SetFlags(short sFlags) { m_pInterface->sFlags = sFlags; }
49+
50+
unsigned short GetNumBlendNodes(void) { return m_pInterface->nNumBlendNodes; };
51+
short GetAnimID(void) { return m_pInterface->sAnimID; }
52+
short GetAnimGroup(void) { return m_pInterface->sAnimGroup; }
53+
short GetFlags(void) { return m_pInterface->sFlags; }
54+
CAnimBlendHierarchySAInterface* GetAnimHierachyInterface(void) { return m_pInterface->pAnimHeirarchy; }
4155

4256
protected:
4357
CAnimBlendStaticAssociationSAInterface* m_pInterface;

Client/game_sa/CAnimBlockSA.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,13 @@ void CAnimBlockSA::Request(EModelRequestType requestType, bool bAllowBlockingFai
4343
AddRef();
4444
}
4545
}
46+
47+
CAnimBlendHierarchySAInterface* CAnimBlockSA::GetAnimationHierarchyInterface(size_t iAnimation)
48+
{
49+
if (!IsLoaded())
50+
return nullptr;
51+
52+
iAnimation += m_pInterface->idOffset;
53+
BYTE* arrAnimations = reinterpret_cast<BYTE*>(ARRAY_CAnimManager_Animations);
54+
return reinterpret_cast<CAnimBlendHierarchySAInterface*>(arrAnimations + sizeof(CAnimBlendHierarchySAInterface) * iAnimation);
55+
}

0 commit comments

Comments
 (0)