View Single Post
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 07-05-2009 , 05:41   Re: Hooking ConVar::SetValue
Reply With Quote #4

Hello,

1) BAIL is right, don't forget the ()

2) SourceHook can't deduce which one of the overloaded functions you want. I suppose a static_cast would work, but the clean way to slove this would probably be a temporary member function pointer variable:

Code:
void (ConVar::*  mfp) (int) = &ConVar::SetValue;
RETURN_META_NEWPARAMS(MRES_IGNORED, mfp, (0));
I suppose I could add a way to ask for the overload number in SH_DECL_HOOK ( 0 here ) but that would be only more confusing.

BTW: It gives you 82 errors because it lists every deduction function that doesn't fit twice, there are two deduction functions per parameter count and the allowed parameter counts are 0, 1, 2, ... 20. This gives us 2 * 2 * 21 = 84, but the exception is param count 1, where it finds a fitting deduction function but can't deduce the ambigous parameter type, which leads to only one error or something.

Hope this works,
PM


EDIT: or maybe some kind of template thing:
Code:
template <class TYPE>
inline static TYPE MFP_Chooser(TYPE a)
{
   return a;
}

RETURN_META_NEWPARAMS(MRES_IGNORED, MFP_Chooser< void (ConVar::*)(int) > (&ConVar::SetValue) , (0));
__________________
hello, i am pm

Last edited by PM; 07-05-2009 at 05:47.
PM is offline