From 1074db27117594e3ad0f45ea622adc0fdf599279 Mon Sep 17 00:00:00 2001 From: xen Date: Fri, 3 Mar 2023 18:46:27 +0200 Subject: [PATCH] add vprof nodes to entity creation detours --- extension.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/extension.cpp b/extension.cpp index 777a2b0..69934c5 100644 --- a/extension.cpp +++ b/extension.cpp @@ -40,6 +40,9 @@ #include #include +#define VPROF_ENABLED +#include + #define SetBit(A,I) ((A)[(I) >> 5] |= (1 << ((I) & 31))) #define ClearBit(A,I) ((A)[(I) >> 5] &= ~(1 << ((I) & 31))) #define CheckBit(A,I) !!((A)[(I) >> 5] & (1 << ((I) & 31))) @@ -341,6 +344,8 @@ const char *pszNonEdicts[] = DETOUR_DECL_MEMBER1(DETOUR_PostConstructor, void, const char *, szClassname) { + VPROF_ENTER_SCOPE("CSSFixes::DETOUR_PostConstructor"); + CBaseEntity *pEntity = (CBaseEntity *)this; static datamap_t *pMap = gamehelpers->GetDataMap(pEntity); @@ -370,6 +375,8 @@ DETOUR_DECL_MEMBER1(DETOUR_PostConstructor, void, const char *, szClassname) } DETOUR_MEMBER_CALL(DETOUR_PostConstructor)(szClassname); + + VPROF_EXIT_SCOPE(); } // Implementation for custom filter entities @@ -423,15 +430,23 @@ DETOUR_DECL_MEMBER2(DETOUR_PassesFilterImpl, bool, CBaseEntity*, pCaller, CBaseE // Switch new entity classnames to ones that can be instantiated while keeping the classname keyvalue intact so it can be used later DETOUR_DECL_STATIC2(DETOUR_CreateEntityByName, CBaseEntity*, const char*, className, int, iForceEdictIndex) { + VPROF_ENTER_SCOPE("CSSFixes::DETOUR_CreateEntityByName"); + // Nice of valve to expose CBaseFilter as filter_base :) if (strcasecmp(className, "filter_activator_context") == 0) className = "filter_base"; - return DETOUR_STATIC_CALL(DETOUR_CreateEntityByName)(className, iForceEdictIndex); + CBaseEntity *pEntity = DETOUR_STATIC_CALL(DETOUR_CreateEntityByName)(className, iForceEdictIndex); + + VPROF_EXIT_SCOPE(); + + return pEntity; } DETOUR_DECL_MEMBER2(DETOUR_KeyValue, bool, const char *, szKeyName, const char *, szValue) { + VPROF_ENTER_SCOPE("CSSFixes::DETOUR_KeyValue"); + CBaseEntity *pEntity = (CBaseEntity *)this; // Fix crash bug in engine @@ -472,8 +487,12 @@ DETOUR_DECL_MEMBER2(DETOUR_KeyValue, bool, const char *, szKeyName, const char * Vector *vecAbsVelocity = (Vector*)((uint8_t*)pEntity + m_AbsVelocity_offset); vecAbsVelocity->Init(tmp[0], tmp[1], tmp[2]); } + + bool bHandled = DETOUR_MEMBER_CALL(DETOUR_KeyValue)(szKeyName, szValue); + + VPROF_EXIT_SCOPE(); - return DETOUR_MEMBER_CALL(DETOUR_KeyValue)(szKeyName, szValue); + return bHandled; } /* Ignore players in +USE trace */