2
0
mirror of https://github.com/rehlds/reapi.git synced 2025-03-15 06:50:20 +03:00

Fixed names collision with fakemeta

Fixed hookctx for recursive hookchain calls
This commit is contained in:
asmodai 2016-06-06 17:55:07 +03:00
parent 7350d696e8
commit 6fb4fc6779
7 changed files with 43 additions and 31 deletions

View File

@ -113,7 +113,7 @@ native SetHookChainArg(number, AType:type, any:...);
* @return 1/0 * @return 1/0
* *
*/ */
native is_rehlds(); native bool:is_rehlds();
/* /*
* Check if the regamedll is available * Check if the regamedll is available
@ -121,7 +121,7 @@ native is_rehlds();
* @return 1/0 * @return 1/0
* *
*/ */
native is_regamedll(); native bool:is_regamedll();
/* /*
* Check if the reunion is available * Check if the reunion is available
@ -129,7 +129,7 @@ native is_regamedll();
* @return 1/0 * @return 1/0
* *
*/ */
native is_has_reunion(); native bool:has_reunion();
/* /*
* Check if the vtc is available * Check if the vtc is available
@ -137,7 +137,7 @@ native is_has_reunion();
* @return 1/0 * @return 1/0
* *
*/ */
native is_has_vtc(); native bool:has_vtc();
/* /*
* This is the callback from the module that gives major/minor versions for verifying compatibility reapi API versions * This is the callback from the module that gives major/minor versions for verifying compatibility reapi API versions

View File

@ -20,15 +20,15 @@ native any:get_entvar(const index, const EntVars:var, any:...);
/* /*
* Sets usercmd data. * Sets usercmd data.
* Use the var_* EntVars enum * Use the ucmd_* UCmd enum
*/ */
native set_ucmd(const ucmd, const UserCmd:var, any:...); native set_ucmd(const ucmd, const UCmd:var, any:...);
/* /*
* Returns entvar data from an entity. * Returns entvar data from an entity.
* Use the var_* EntVars enum * Use the ucmd_* UCmd enum
*/ */
native any:get_ucmd(const ucmd, const UserCmd:var, any:...); native any:get_ucmd(const ucmd, const UCmd:var, any:...);
/* /*
* Set name of the map * Set name of the map

View File

@ -1024,7 +1024,7 @@ enum EntVars
var_euser4 var_euser4
}; };
enum UserCmd enum UCmd
{ {
/* /*
* Description: - * Description: -

View File

@ -50,23 +50,41 @@ inline AType getApiType(T *) { return ATYPE_INTEGER; }
#define MAX_ARGS 12u #define MAX_ARGS 12u
template<size_t current = 0, typename T1, typename T2, typename T3, typename T4, typename ...t_args>
void setupArgTypes(AType args_type[MAX_ARGS], T1, T2, T3, T4, t_args... args)
{
*(uint32 *)&args_type[current] = getApiType(T1()) | (getApiType(T2()) << 8) | (getApiType(T3()) << 16) | (getApiType(T4()) << 24);
if (sizeof...(args) && current + 1 < MAX_ARGS)
setupArgTypes<current + 4>(args_type, args...);
}
template<size_t current = 0, typename T1, typename T2, typename T3>
void setupArgTypes(AType args_type[MAX_ARGS], T1, T2, T3)
{
*(uint32 *)&args_type[current] = getApiType(T1()) | (getApiType(T2()) << 8) | (getApiType(T3()) << 16);
}
template<size_t current = 0, typename T1, typename T2>
void setupArgTypes(AType args_type[MAX_ARGS], T1, T2)
{
*(uint16 *)&args_type[current] = getApiType(T1()) | (getApiType(T2()) << 8);
}
template<size_t current = 0, typename T>
void setupArgTypes(AType args_type[MAX_ARGS], T)
{
args_type[current] = getApiType(T());
}
template<size_t current = 0> template<size_t current = 0>
void setupArgTypes(AType args_type[MAX_ARGS]) void setupArgTypes(AType args_type[MAX_ARGS])
{ {
} }
template<size_t current = 0, typename T, typename ...t_args>
void setupArgTypes(AType args_type[MAX_ARGS], T, t_args... args)
{
args_type[current] = getApiType(T());
if (sizeof...(args) && current + 1 < MAX_ARGS)
setupArgTypes<current + 1>(args_type, args...);
}
struct hookctx_t struct hookctx_t
{ {
template<typename ...t_args> template<typename ...t_args>
hookctx_t(size_t arg_count, t_args... args) : args_ptr() hookctx_t(size_t arg_count, t_args... args)
{ {
args_count = min(arg_count, MAX_ARGS); args_count = min(arg_count, MAX_ARGS);
setupArgTypes(args_type, args...); setupArgTypes(args_type, args...);
@ -128,9 +146,6 @@ NOINLINE void DLLEXPORT _callVoidForward(const hook_t* hook, original_t original
template <typename original_t, typename ...f_args> template <typename original_t, typename ...f_args>
void callVoidForward(size_t func, original_t original, f_args... args) void callVoidForward(size_t func, original_t original, f_args... args)
{ {
#ifndef _WIN32
static
#endif
hookctx_t hookCtx(sizeof...(args), args...); hookctx_t hookCtx(sizeof...(args), args...);
g_hookCtx = &hookCtx; g_hookCtx = &hookCtx;
@ -193,9 +208,6 @@ NOINLINE R DLLEXPORT _callForward(const hook_t* hook, original_t original, volat
template <typename R, typename original_t, typename ...f_args> template <typename R, typename original_t, typename ...f_args>
R callForward(size_t func, original_t original, f_args... args) R callForward(size_t func, original_t original, f_args... args)
{ {
#ifndef _WIN32
static
#endif
hookctx_t hookCtx(sizeof...(args), args...); hookctx_t hookCtx(sizeof...(args), args...);
g_hookCtx = &hookCtx; g_hookCtx = &hookCtx;

View File

@ -3,7 +3,7 @@
#define CLASS_MEMBERS(cx, mx, pref) ((!(pref##mx & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (pref##mx & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltype(##cx::##mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(##cx, ##mx);ptr->type = getMemberType(f);}) : regmember(#mx) #define CLASS_MEMBERS(cx, mx, pref) ((!(pref##mx & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (pref##mx & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltype(##cx::##mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(##cx, ##mx);ptr->type = getMemberType(f);}) : regmember(#mx)
#define GM_MEMBERS(mx) CLASS_MEMBERS(CHalfLifeMultiplay, mx,) #define GM_MEMBERS(mx) CLASS_MEMBERS(CHalfLifeMultiplay, mx,)
#define GM_VOICE_MEMBERS(mx) CLASS_MEMBERS(CVoiceGameMgr, mx,) #define GM_VOICE_MEMBERS(mx) CLASS_MEMBERS(CVoiceGameMgr, mx,)
#define BASE_MEMBERS(mx) CLASS_MEMBERS(CBaseEntity, mx,) #define BASE_MEMBERS(mx) CLASS_MEMBERS(CBaseEntity, mx,)
#define ANIM_MEMBERS(mx) CLASS_MEMBERS(CBaseAnimating, mx,) #define ANIM_MEMBERS(mx) CLASS_MEMBERS(CBaseAnimating, mx,)
#define MONST_MEMBERS(mx) CLASS_MEMBERS(CBaseMonster, mx,) #define MONST_MEMBERS(mx) CLASS_MEMBERS(CBaseMonster, mx,)

View File

@ -5,7 +5,7 @@
// member types // member types
enum MType enum MType
{ {
MEMBER_FLOAT = 0, // Any floating popm_value MEMBER_FLOAT = 0, // Any floating point value
MEMBER_DOUBLE, // double value MEMBER_DOUBLE, // double value
MEMBER_ENTITY, // An entity offset (EOFFSET) MEMBER_ENTITY, // An entity offset (EOFFSET)
MEMBER_CLASSPTR, // CBaseEntity * MEMBER_CLASSPTR, // CBaseEntity *
@ -13,7 +13,7 @@ enum MType
MEMBER_EVARS, // EVARS * MEMBER_EVARS, // EVARS *
MEMBER_EDICT, // edict_t *, or edict_t * (same thing) MEMBER_EDICT, // edict_t *, or edict_t * (same thing)
MEMBER_VECTOR, // Any vector MEMBER_VECTOR, // Any vector
MEMBER_STRING, // pm_*, pm_[] MEMBER_STRING, // char *, char []
MEMBER_QSTRING, // quake string, like string_t MEMBER_QSTRING, // quake string, like string_t
MEMBER_RSTRING, // reverse of qstring to string MEMBER_RSTRING, // reverse of qstring to string
MEMBER_INTEGER, // Any integer or enum MEMBER_INTEGER, // Any integer or enum

View File

@ -1330,7 +1330,7 @@ cell AMX_NATIVE_CALL is_regamedll(AMX *amx, cell *params)
* *
* native is_has_reunion(); * native is_has_reunion();
*/ */
cell AMX_NATIVE_CALL is_has_reunion(AMX *amx, cell *params) cell AMX_NATIVE_CALL has_reunion(AMX *amx, cell *params)
{ {
return (cell)api_cfg.hasReunion(); return (cell)api_cfg.hasReunion();
} }
@ -1342,7 +1342,7 @@ cell AMX_NATIVE_CALL is_has_reunion(AMX *amx, cell *params)
* *
* native is_has_vtc(); * native is_has_vtc();
*/ */
cell AMX_NATIVE_CALL is_has_vtc(AMX *amx, cell *params) cell AMX_NATIVE_CALL has_vtc(AMX *amx, cell *params)
{ {
return (cell)api_cfg.hasVTC(); return (cell)api_cfg.hasVTC();
} }
@ -1351,8 +1351,8 @@ AMX_NATIVE_INFO Misc_Natives_Checks[] =
{ {
{ "is_rehlds", is_rehlds }, { "is_rehlds", is_rehlds },
{ "is_regamedll", is_regamedll }, { "is_regamedll", is_regamedll },
{ "is_has_reunion", is_has_reunion }, { "has_reunion", has_reunion },
{ "is_has_vtc", is_has_vtc } { "has_vtc", has_vtc }
}; };
void RegisterNatives_Misc() void RegisterNatives_Misc()