Update - working

This commit is contained in:
Dr!fter 2013-08-20 20:18:50 -04:00
parent 61c887f042
commit ae3ca716ce
3 changed files with 25 additions and 16 deletions

View File

@ -37,6 +37,7 @@ cell_t Native_CreateHook(IPluginContext *pContext, const cell_t *params)
return hndl;
}
//native bool:DHookAddParam(Handle:setup, HookParamType:type);
//native bool:DHookAddParam(Handle:setup, HookParamType:type, size=-1, flag=-1);
cell_t Native_AddParam(IPluginContext *pContext, const cell_t *params)
{
if(params[1] == BAD_HANDLE)
@ -54,17 +55,19 @@ cell_t Native_AddParam(IPluginContext *pContext, const cell_t *params)
}
ParamInfo info;
if(params[0] == 3)
//Add support for setting this
info.flag = PASSFLAG_BYVAL;
info.type = (HookParamType)params[2];
if(params[0] == 3 && params[3] != -1)
{
info.flag = params[3];
info.size = params[3];
}
else
{
info.flag = PASSFLAG_BYVAL;
info.size = GetParamTypeSize(info.type);
}
info.type = (HookParamType)params[2];
info.size = GetParamTypeSize(info.type);
info.pass_type = GetParamTypePassType(info.type);
setup->params.AddToTail(info);
@ -190,7 +193,7 @@ cell_t Native_GetReturn(IPluginContext *pContext, const cell_t *params)
case ReturnType_Int:
return *(int *)returnStruct->orgResult;
case ReturnType_Bool:
return *(cell_t *)returnStruct->orgResult;
return *(bool *)returnStruct->orgResult? 1 : 0;
case ReturnType_CBaseEntity:
return gamehelpers->EntityToBCompatRef((CBaseEntity *)returnStruct->orgResult);
case ReturnType_Edict:
@ -224,10 +227,10 @@ cell_t Native_SetReturn(IPluginContext *pContext, const cell_t *params)
switch(returnStruct->type)
{
case ReturnType_Int:
returnStruct->newResult = (void *)((int)params[2]);
returnStruct->newResult = (int *)params[2];
break;
case ReturnType_Bool:
returnStruct->newResult = (void *)(params[2] != 0);
returnStruct->newResult = (bool *)(params[2]);
break;
case ReturnType_CBaseEntity:
pEnt = UTIL_GetCBaseEntity(params[2]);

View File

@ -80,6 +80,8 @@ SourceHook::PassInfo::PassType GetParamTypePassType(HookParamType type)
{
case HookParamType_Float:
return SourceHook::PassInfo::PassType_Float;
case HookParamType_Object:
return SourceHook::PassInfo::PassType_Object;
}
return SourceHook::PassInfo::PassType_Basic;
}
@ -123,15 +125,18 @@ HookReturnStruct *GetReturnStruct(DHooksCallback *dg, const void *result)
//ReturnType_String,
//ReturnType_Vector,
case ReturnType_Int:
case ReturnType_Bool:
res->orgResult = (int *)result;
case ReturnType_Bool:
res->orgResult = (bool *)result;
break;
case ReturnType_Float:
res->orgResult = new float;
*fpVal = *(float *)result;
res->orgResult = fpVal;
break;
default:
res->orgResult = (void *)result;
break;
}
}
else
@ -217,7 +222,7 @@ void *Callback(DHooksCallback *dg, void **argStack)
dg->plugin_callback->Execute(&result);
void *ret = g_SHPtr->GetOverrideRetPtr();
ret = 0;
switch((MRESReturn)result)
{
case MRES_Handled:
@ -243,12 +248,12 @@ void *Callback(DHooksCallback *dg, void **argStack)
if(dg->returnType != ReturnType_Void)
{
if(returnStruct->isChanged)
{
{
ret = returnStruct->newResult;
}
else if(dg->post)
{
ret = (void *)returnStruct->orgResult;
ret = returnStruct->orgResult;
}
}
break;
@ -257,7 +262,7 @@ void *Callback(DHooksCallback *dg, void **argStack)
if(dg->returnType != ReturnType_Void)
{
if(returnStruct->isChanged)
{
{
ret = returnStruct->newResult;
}
else if(dg->post)
@ -283,4 +288,4 @@ void *Callback(DHooksCallback *dg, void **argStack)
}
return ret;
}
}

View File

@ -27,7 +27,8 @@ enum HookParamType
HookParamType_VectorPtr,
HookParamType_CBaseEntity,
HookParamType_ObjectPtr,
HookParamType_Edict
HookParamType_Edict,
HookParamType_Object
};
enum ReturnType