From 9e13516904f52f6cf49813c24f10bf700b7e6a10 Mon Sep 17 00:00:00 2001 From: KitRifty Date: Fri, 16 Feb 2024 18:01:27 -0800 Subject: [PATCH] Reimplement CBaseAnimating::SequenceDuration Replace sig with Studio_Duration signature Fetch m_flPoseParameter array member --- extension/sourcesdk/baseanimating.cpp | 10 ++++++---- extension/sourcesdk/baseanimating.h | 4 +++- gamedata/cbasenpc.txt | 24 ++++++++++-------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/extension/sourcesdk/baseanimating.cpp b/extension/sourcesdk/baseanimating.cpp index 1b1cf57..3f7e412 100644 --- a/extension/sourcesdk/baseanimating.cpp +++ b/extension/sourcesdk/baseanimating.cpp @@ -8,13 +8,13 @@ FCall fStudio_LookupSequence; FCall fStudio_FindAttachment; FCall fStudio_SelectWeightedSequence; +FCall fStudio_Duration; int CBaseAnimating::offset_HandleAnimEvent = 0; VCall CBaseAnimating::vStudioFrameAdvance; VCall CBaseAnimating::vDispatchAnimEvents; VCall< bool, int, matrix3x4_t& > CBaseAnimating::vGetAttachment; -MCall CBaseAnimating::mSequenceDuration; MCall CBaseAnimating::mResetSequence; MCall CBaseAnimating::mLookupPoseParameter; MCall CBaseAnimating::mGetPoseParameter; @@ -25,6 +25,7 @@ DEFINEVAR(CBaseAnimating, m_pStudioHdr); DEFINEVAR(CBaseAnimating, m_OnIgnite); DEFINEVAR(CBaseAnimating, m_nSequence); DEFINEVAR(CBaseAnimating, m_flModelScale); +DEFINEVAR(CBaseAnimating, m_flPoseParameter); bool CBaseAnimating::Init(SourceMod::IGameConfig* config, char* error, size_t maxlength) { @@ -33,8 +34,8 @@ bool CBaseAnimating::Init(SourceMod::IGameConfig* config, char* error, size_t ma fStudio_LookupSequence.Init(config, "Studio_LookupSequence"); fStudio_FindAttachment.Init(config, "Studio_FindAttachment"); fStudio_SelectWeightedSequence.Init(config, "Studio_SelectWeightedSequence"); + fStudio_Duration.Init(config, "Studio_Duration"); - mSequenceDuration.Init(config, "CBaseAnimating::SequenceDuration"); mResetSequence.Init(config, "CBaseAnimating::ResetSequence"); mLookupPoseParameter.Init(config, "CBaseAnimating::LookupPoseParameter"); mSetPoseParameter.Init(config, "CBaseAnimating::SetPoseParameter"); @@ -64,6 +65,7 @@ bool CBaseAnimating::Init(SourceMod::IGameConfig* config, char* error, size_t ma OFFSETVAR_SEND(CBaseAnimating, m_flModelScale); // m_pStudioHdr is in front of m_OnIgnite VAR_OFFSET_SET(m_pStudioHdr, VAR_OFFSET(m_OnIgnite) + sizeof(COutputEvent)); + OFFSETVAR_SEND(CBaseAnimating, m_flPoseParameter); END_VAR; void* aVal = nullptr; @@ -135,9 +137,9 @@ float CBaseAnimating::GetPoseParameter(const char* name) return GetPoseParameter(LookupPoseParameter(name)); } -float CBaseAnimating::SequenceDuration(CStudioHdr* studio, int sequence) +float CBaseAnimating::SequenceDuration(CStudioHdr* pStudioHdr, int iSequence) { - return mSequenceDuration(this, studio, sequence); + return fStudio_Duration(pStudioHdr, iSequence, GetPoseParameterArray()); } void CBaseAnimating::ResetSequence(int sequence) diff --git a/extension/sourcesdk/baseanimating.h b/extension/sourcesdk/baseanimating.h index 3b327bc..ca0c15e 100644 --- a/extension/sourcesdk/baseanimating.h +++ b/extension/sourcesdk/baseanimating.h @@ -34,6 +34,8 @@ class CBaseAnimating : public CBaseEntity float GetPoseParameter(const char* name); + const float* GetPoseParameterArray() { return m_flPoseParameter(); } + static int offset_HandleAnimEvent; static VCall vStudioFrameAdvance; @@ -42,7 +44,6 @@ class CBaseAnimating : public CBaseEntity static VCall vDispatchAnimEvents; void DispatchAnimEvents(CBaseAnimating*); - static MCall mSequenceDuration; float SequenceDuration(CStudioHdr*, int); static MCall mResetSequence; @@ -67,6 +68,7 @@ class CBaseAnimating : public CBaseEntity DECLAREVAR(CStudioHdr*, m_pStudioHdr); DECLAREVAR(int, m_nSequence); DECLAREVAR(float, m_flModelScale); + DECLAREVAR(float, m_flPoseParameter); }; inline float CBaseAnimating::GetModelScale() const diff --git a/gamedata/cbasenpc.txt b/gamedata/cbasenpc.txt index ec14034..a1eb45b 100644 --- a/gamedata/cbasenpc.txt +++ b/gamedata/cbasenpc.txt @@ -327,6 +327,16 @@ "linux" "@_Z21Studio_FindAttachmentPK10CStudioHdrPKc" "linux64" "@_Z21Studio_FindAttachmentPK10CStudioHdrPKc" } + // Look up data xrefs to string "CBaseAnimating::SequenceDuration( %d ) NULL pstudiohdr on %s!\n" + // Find call that takes 3 parameters + "Studio_Duration" + { + "library" "server" + "windows" "\x55\x8B\xEC\xFF\x75\x2A\x8B\x4D\x2A\xE8\x2A\x2A\x2A\x2A\xFF\x75" + "windows64" "\x48\x89\x5C\x24\x2A\x48\x89\x74\x24\x2A\x57\x48\x83\xEC\x20\x49\x8B\xD8\x8B\xFA" + "linux" "@_Z15Studio_DurationPK10CStudioHdriPKf" + "linux64" "@_Z15Studio_DurationPK10CStudioHdriPKf" + } // Bytes sequence search "00 00 C0 00", go to the only subroutine that uses that number with 'and' & 'cmp' "SimThink_EntityChanged" { @@ -433,20 +443,6 @@ "linux" "@_ZN14CBaseAnimating19LookupPoseParameterEP10CStudioHdrPKc" "linux64" "@_ZN14CBaseAnimating19LookupPoseParameterEP10CStudioHdrPKc" } - // Look up data xrefs to string "CBaseAnimating::SequenceDuration( %d ) NULL pstudiohdr on %s!\n" - // One of them is CBaseAnimating::GetSequenceCycleRate, is referenced by CBaseAnimating::DispatchAnimEvents - // One of them is CBaseAnimating::GetSequenceGroundSpeed, it's a virtual function - // One of them is CBaseAnimating::ScriptGetSequenceDuration, has xref to a VScript init function which has a xref to string "GetAttachmentBone" - // One of them divides the final result - // The last xref left should be CBaseAnimating::SequenceDuration - "CBaseAnimating::SequenceDuration" - { - "library" "server" - "windows" "\x55\x8B\xEC\x56\x8B\x75\x08\x57\x8B\xF9\x85\xF6\x75\x2A\x8B\x47\x5C" - "windows64" "\x48\x89\x5C\x24\x2A\x48\x89\x74\x24\x2A\x57\x48\x83\xEC\x20\x41\x8B\xD8\x48\x8B\xFA\x48\x8B\xF1\x48\x85\xD2\x75\x2A\x48\x8B\x81\x2A\x2A\x2A\x2A\x4C\x8D\x0D\x2A\x2A\x2A\x2A\x48\x85\xC0\x48\x8D\x15\x2A\x2A\x2A\x2A\x8D\x4F\x2A\x4C\x0F\x45\xC8\xFF\x15\x2A\x2A\x2A\x2A\xEB\x2A\x48\x8B\xCF\xE8\x2A\x2A\x2A\x2A\x84\xC0\x74\x2A\x48\x8B\xCF\xE8\x2A\x2A\x2A\x2A\x3B\xD8\x7D\x2A\x85\xDB\x78\x2A\x4C\x8D\x86\x2A\x2A\x2A\x2A\x8B\xD3\x48\x8B\xCF\x48\x8B\x5C\x24" - "linux" "@_ZN14CBaseAnimating16SequenceDurationEP10CStudioHdri" - "linux64" "@_ZN14CBaseAnimating16SequenceDurationEP10CStudioHdri" - } // Go to data xref of string "ResetSequence : %s: %s -> %s\n" "CBaseAnimating::ResetSequence" {