Raised This Month: $ Target: $400
 0% 

Question about RegisterHam (wildcard)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 04-15-2016 , 10:03   Question about RegisterHam (wildcard)
Reply With Quote #1

RegisterHam requires an EntityClass in order to register the hook.
Can I use a wildcard in this EntityClass? For example: RegisterHam on trigger_* will work on all trigger_ entities.
Or I need to create a RegisterHam for each one?

Thanks in advance.
__________________
gabuch2 is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 04-15-2016 , 10:18   Re: Question about RegisterHam (wildcard)
Reply With Quote #2

You cant use trigger_*
SpeeDeeR is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 04-15-2016 , 11:00   Re: Question about RegisterHam (wildcard)
Reply With Quote #3

You can try , If the callback is compared with something like contain function then it would be possible but if is compared by equal function then you'll have to write exact name.

try to put "trigger_"
siriusmd99 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 04-15-2016 , 12:02   Re: Question about RegisterHam (wildcard)
Reply With Quote #4

Hamsandwich doesn't really work by entity class, but rather C++ class that entity is linked to.

As an example, if you hooked spawn on "info_target", you would also hook it for "info_player_start" and "info_player_deathmatch" (and possibly few more) as they are all linked to the CPointEntity class.

https://mxr.alliedmods.net/hlsdk/sou...ls/cbase.h#388
https://mxr.alliedmods.net/hlsdk/sou...effects.cpp#32
https://mxr.alliedmods.net/hlsdk/sou...ls/subs.cpp#70

That also explains some confusion I've seen around this forums, there were a few topics asking about why some other entity's virtual functions were hooked when they didn't tell Hamsandwich to hook them.

Well, you can't use wildcards because of what I've said above. Hamsandwich doesn't make classname checks at run-time each time some virtual function is called, it just changes some function pointers around in virtual tables, and each C++ class has its own.
klippy is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 04-15-2016 , 13:24   Re: Question about RegisterHam (wildcard)
Reply With Quote #5

From what I can understand, if I hook monster_generic, for example, all entities linked to CBaseMonster will be hooked?
__________________
gabuch2 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 04-15-2016 , 13:31   Re: Question about RegisterHam (wildcard)
Reply With Quote #6

Correct, altough monster_generic is linked to CGenericMonster. Here, take a look yourself.

All you would have to do in your hooks to get around that is to check for the classname yourself.
klippy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:35.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode