From 49ba85791509982cde218c71c49b0eafe2ceaee6 Mon Sep 17 00:00:00 2001 From: A1mDev <33463136+A1mDev@users.noreply.github.com> Date: Wed, 29 Oct 2025 09:02:04 +0700 Subject: [PATCH] Refine error messages and type handling in GetObjectAddrOrThis --- extensions/dhooks/natives.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/extensions/dhooks/natives.cpp b/extensions/dhooks/natives.cpp index 430ff9730..82b154ada 100644 --- a/extensions/dhooks/natives.cpp +++ b/extensions/dhooks/natives.cpp @@ -42,6 +42,8 @@ enum SDKFuncConfSource SDKConf_Address }; +using ParamVector = SourceHook::CVector; + bool GetHandleIfValidOrError(HandleType_t type, void **object, IPluginContext *pContext, cell_t param) { if(param == BAD_HANDLE) @@ -93,7 +95,7 @@ bool GetObjectAddrOrThis(IPluginContext *pContext, const cell_t *params, void *& if(params[2] != 0) { - const auto ¶msVec = paramStruct->dg->params; + const ParamVector ¶msVec = paramStruct->dg->params; if(params[2] < 0 || params[2] > static_cast(paramsVec.size())) { @@ -101,7 +103,7 @@ bool GetObjectAddrOrThis(IPluginContext *pContext, const cell_t *params, void *& } int index = params[2] - 1; - const auto ¶m = paramsVec.at(index); + const ParamInfo ¶m = paramsVec.at(index); if(param.type != HookParamType_ObjectPtr && param.type != HookParamType_Object) { @@ -113,16 +115,16 @@ bool GetObjectAddrOrThis(IPluginContext *pContext, const cell_t *params, void *& return true; } - const auto &dgInfo = paramStruct->dg; + const DHooksInfo* dgInfo = paramStruct->dg; if(dgInfo->thisFuncCallConv != CallConv_THISCALL) { - return pContext->ThrowNativeError("Parameter 'this' is only available in member functions, specify the calling convention type 'thiscall'"); + return pContext->ThrowNativeError("Parameter 'this' is only available in member functions"); } if(dgInfo->thisType != ThisPointer_Address && dgInfo->thisType != ThisPointer_CBaseEntity - && !(dgInfo->thisType == ThisPointer_Ignore && dgInfo->hookType == HookType_GameRules)) + && dgInfo->hookType != HookType_GameRules) { return pContext->ThrowNativeError("Parameter 'this' is not specified as an address, it is not available"); }