diff --git a/reapi/src/hook_callback.h b/reapi/src/hook_callback.h index a6a6863..7ea9990 100644 --- a/reapi/src/hook_callback.h +++ b/reapi/src/hook_callback.h @@ -53,6 +53,7 @@ inline bool hasStringArgs() { return false; } template bool hasStringArgs(T, f_args... args) { + if (sizeof(T) > sizeof(int)) UTIL_SysError("%s: invalid hookchain argument size (%i > %i)", __FUNCTION__, sizeof(T), sizeof(int)); if (getApiType(T()) == ATYPE_STRING) return true; return hasStringArgs(args...); } @@ -257,7 +258,7 @@ template R callForward(size_t func, original_t original, f_args... args) { if (sizeof(R) > sizeof(int)) { - UTIL_SysError("%s: invalid return type size (%i)", __FUNCTION__, sizeof(R)); + UTIL_SysError("%s: invalid return type size (%i > %i)", __FUNCTION__, sizeof(R), sizeof(int)); } hookctx_t hookCtx(sizeof...(args), args...); diff --git a/reapi/src/member_list.cpp b/reapi/src/member_list.cpp index 31ed8a5..b98c441 100644 --- a/reapi/src/member_list.cpp +++ b/reapi/src/member_list.cpp @@ -738,7 +738,7 @@ memberlist_t memberlist; member_t *memberlist_t::operator[](size_t members) const { - #define CASE(h) case mt_##h: if (index < arraysize(memberlist_##h)) return &memberlist_##h[index]; else break; + #define CASE(h) case mt_##h: if (likely(index < arraysize(memberlist_##h))) return &memberlist_##h[index]; else break; const auto table = members_tables_e(members / MAX_REGION_RANGE); const auto index = members & (MAX_REGION_RANGE - 1); diff --git a/reapi/src/reapi_utils.h b/reapi/src/reapi_utils.h index 5793cf4..c8564d2 100644 --- a/reapi/src/reapi_utils.h +++ b/reapi/src/reapi_utils.h @@ -51,14 +51,20 @@ inline edict_t* edictByIndex(int index) } template -T* getPrivate(int index) +inline T* getPrivate(int index) { - return (T *)GET_PRIVATE(edictByIndexAmx(index)); + T* pdata = nullptr; + if (likely(index >= 0)) + pdata = (T *)g_pEdicts[index].pvPrivateData; + return pdata; } inline entvars_t* PEV(int index) { - return VARS(edictByIndexAmx(index)); + entvars_t* pvars = nullptr; + if (likely(index >= 0)) + pvars = &g_pEdicts[index].v; + return pvars; } // HLTypeConversion.h -> AMXModX