View Single Post
Author Message
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 03-10-2020 , 10:37   Virtual hooks, bypass only current hook
Reply With Quote #1

I hook a custom virtual function in two extensions:
CBaseEntity* CreateEntityByName(const char * className);

So that control is passed to B function of extension B, then to A from extension A then back to the original CreateEntityByName. It works fine if I use RETURN_META_VALUE_MNEWPARAMS in both A and B. I get this sequence:

O -> B -> A -> CreateEntityByName -> back to O

But I need to know the result CBaseEntity pointer in both A and B. So I replace the RETURN_META_VALUE_MNEWPARAMS with:

SH_CALL and RETURN_META_VALUE(MRES_SUPERCEDE , false);

The problem here is that SH_CALL bypasses both hooks and the original CreateEntityByName is called twice, so 2 entities are created. I get this sequence:

O -> B, SH_CALL-> CreateEntityByName -> back to B -> A, SH_CALL-> CreateEntityByName -> back to A -> back to O

Is there a way to bypass only current hook to get correct sequence?

O -> B, SH_CALL-> A, SH_CALL-> CreateEntityByName -> back to A -> back to B -> back to O

Last edited by kadet.89; 03-11-2020 at 16:57.
kadet.89 is offline
Send a message via Skype™ to kadet.89