diff --git a/reapi/src/natives/natives_hookchains.cpp b/reapi/src/natives/natives_hookchains.cpp index 5c8b03a..1f6081d 100644 --- a/reapi/src/natives/natives_hookchains.cpp +++ b/reapi/src/natives/natives_hookchains.cpp @@ -123,7 +123,14 @@ cell AMX_NATIVE_CALL SetHookChainReturn(AMX *amx, cell *params) if (unlikely(params[arg_type] != retVal.type)) { - AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: trying to set return value with incompatible type.", __FUNCTION__); + AMXX_LogError(amx, AMX_ERR_NATIVE, + "%s: trying to set return value with incompatible type, expected '%s'; got '%s'", + __FUNCTION__, + getATypeStr(retVal.type), + getATypeStr(static_cast(params[arg_type])) + ); + + printf("> SetHookChainReturn: called #3\n"); return FALSE; } @@ -136,6 +143,9 @@ cell AMX_NATIVE_CALL SetHookChainReturn(AMX *amx, cell *params) case ATYPE_FLOAT: retVal._integer = *srcAddr; break; + case ATYPE_BOOL: + retVal._integer = (*srcAddr != 0) ? TRUE : FALSE; + break; case ATYPE_STRING: { @@ -188,7 +198,13 @@ cell AMX_NATIVE_CALL GetHookChainReturn(AMX *amx, cell *params) if (unlikely(params[arg_type] != retVal.type)) { - AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: trying to get return value with incompatible type.", __FUNCTION__); + AMXX_LogError(amx, AMX_ERR_NATIVE, + "%s: trying to get return value with incompatible type, expected '%s'; got '%s'", + __FUNCTION__, + getATypeStr(retVal.type), + getATypeStr(static_cast(params[arg_type])) + ); + return FALSE; } @@ -205,6 +221,8 @@ cell AMX_NATIVE_CALL GetHookChainReturn(AMX *amx, cell *params) case ATYPE_INTEGER: case ATYPE_FLOAT: return retVal._integer; + case ATYPE_BOOL: + return retVal._integer != 0 ? TRUE : FALSE; case ATYPE_STRING: { if (PARAMS_COUNT != 2) @@ -258,7 +276,13 @@ cell AMX_NATIVE_CALL SetHookChainArg(AMX *amx, cell *params) AType type = g_hookCtx->args[number].type; if (unlikely(params[arg_type] != type)) { - AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: invalid argument type provided.", __FUNCTION__); + AMXX_LogError(amx, AMX_ERR_NATIVE, + "%s: invalid argument type provided, expected '%s'; got '%s'", + __FUNCTION__, + getATypeStr(type), + getATypeStr(static_cast(params[arg_type])) + ); + return FALSE; } diff --git a/reapi/src/reapi_utils.cpp b/reapi/src/reapi_utils.cpp index 0996765..e0b2016 100644 --- a/reapi/src/reapi_utils.cpp +++ b/reapi/src/reapi_utils.cpp @@ -220,3 +220,22 @@ void RemoveOrDropItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem, GiveType typ break; } } + +const char *getATypeStr(AType type) +{ + static constexpr const char *s_ATypes[] + { + "ATYPE_INTEGER", + "ATYPE_FLOAT", + "ATYPE_STRING", + "ATYPE_CLASSPTR", + "ATYPE_EDICT", + "ATYPE_EVARS", + "ATYPE_BOOL" + }; + + if (type >= arraysize(s_ATypes)) + return ""; + + return s_ATypes[type]; +} diff --git a/reapi/src/reapi_utils.h b/reapi/src/reapi_utils.h index 7e73aca..86a8adf 100644 --- a/reapi/src/reapi_utils.h +++ b/reapi/src/reapi_utils.h @@ -57,4 +57,6 @@ void GetBonePosition(CBaseEntity *pEntity, int iBone, Vector *vecOrigin, Vector void GetAttachment(CBaseEntity *pEntity, int iBone, Vector *pVecOrigin, Vector *pVecAngles); void RemoveOrDropItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem, GiveType type); +const char *getATypeStr(AType type); + extern void NORETURN UTIL_SysError(const char *fmt, ...);