diff --git a/Makefile b/Makefile index 6ba8f57..cc9b36d 100644 --- a/Makefile +++ b/Makefile @@ -119,7 +119,7 @@ ifeq "$(USEMETA)" "true" LINK += $(LINK_HL2) - INCLUDE += -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I$(METAMOD) \ + INCLUDE += -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I$(HL2SDK)/game/shared -I$(METAMOD) \ -I$(METAMOD)/sourcehook CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_BLOODYGOODTIME=4 -DSE_EYE=5 \ -DSE_CSS=6 -DSE_ORANGEBOXVALVE=7 -DSE_LEFT4DEAD=8 -DSE_LEFT4DEAD2=9 -DSE_ALIENSWARM=10 \ diff --git a/vfunc_call.cpp b/vfunc_call.cpp deleted file mode 100644 index 8616484..0000000 --- a/vfunc_call.cpp +++ /dev/null @@ -1,121 +0,0 @@ -#include "vfunc_call.h" - -#define PARAMINFO_SWITCH(passType) \ - paramInfo[i].flags = dg->params.Element(i).flag; \ - paramInfo[i].size = dg->params.Element(i).size; \ - paramInfo[i].type = passType; - -#define VSTK_PARAM_SWITCH(paramType) \ - if(paramStruct->isChanged[i]) \ - { \ - *(paramType *)vptr = (paramType)(paramStruct->newParams[i]); \ - } \ - else \ - { \ - *(paramType *)vptr = (paramType)(paramStruct->orgParams[i]); \ - } \ - if(i + 1 != dg->params.Count()) \ - { \ - vptr += dg->params.Element(i).size; \ - } \ - break; -#define VSTK_PARAM_SWITCH_FLOAT() \ - if(paramStruct->isChanged[i]) \ - { \ - *(float *)vptr = *(float *)(paramStruct->newParams[i]); \ - } \ - else \ - { \ - *(float *)vptr = *(float *)(paramStruct->orgParams[i]); \ - } \ - if(i + 1 != dg->params.Count()) \ - { \ - vptr += dg->params.Element(i).size; \ - } \ - break; - -void *CallVFunction(DHooksCallback *dg, HookParamsStruct *paramStruct, void *iface) -{ - PassInfo *paramInfo = NULL; - PassInfo returnInfo; - - if(dg->returnType != ReturnType_Void) - { - returnInfo.flags = dg->returnFlag; - returnInfo.size = sizeof(void *); - returnInfo.type = PassType_Basic; - } - - ICallWrapper *pCall; - - size_t size = GetStackArgsSize(dg); - - unsigned char *vstk = (unsigned char *)malloc(sizeof(void *) + size); - unsigned char *vptr = vstk; - - *(void **)vptr = iface; - - if(paramStruct) - { - vptr += sizeof(void *); - paramInfo = (PassInfo *)malloc(sizeof(PassInfo) * dg->params.Count()); - for(int i = 0; i < dg->params.Count(); i++) - { - switch(dg->params.Element(i).type) - { - case HookParamType_Int: - PARAMINFO_SWITCH(PassType_Basic); - VSTK_PARAM_SWITCH(int); - case HookParamType_Bool: - PARAMINFO_SWITCH(PassType_Basic); - VSTK_PARAM_SWITCH(cell_t); - case HookParamType_Float: - PARAMINFO_SWITCH(PassType_Float); - VSTK_PARAM_SWITCH_FLOAT(); - case HookParamType_String: - PARAMINFO_SWITCH(PassType_Object); - VSTK_PARAM_SWITCH(int); - case HookParamType_StringPtr: - PARAMINFO_SWITCH(PassType_Basic); - VSTK_PARAM_SWITCH(string_t *); - case HookParamType_CharPtr: - PARAMINFO_SWITCH(PassType_Basic); - VSTK_PARAM_SWITCH(char *); - case HookParamType_VectorPtr: - PARAMINFO_SWITCH(PassType_Basic); - VSTK_PARAM_SWITCH(Vector *); - case HookParamType_CBaseEntity: - PARAMINFO_SWITCH(PassType_Basic); - VSTK_PARAM_SWITCH(CBaseEntity *); - case HookParamType_Edict: - PARAMINFO_SWITCH(PassType_Basic); - VSTK_PARAM_SWITCH(edict_t *); - default: - PARAMINFO_SWITCH(PassType_Basic); - VSTK_PARAM_SWITCH(void *); - } - } - } - - void *ret = 0; - if(dg->returnType == ReturnType_Void) - { - pCall = g_pBinTools->CreateVCall(dg->offset, 0, 0, NULL, paramInfo, dg->params.Count()); - pCall->Execute(vstk, NULL); - } - else - { - pCall = g_pBinTools->CreateVCall(dg->offset, 0, 0, &returnInfo, paramInfo, dg->params.Count()); - pCall->Execute(vstk, &ret); - } - - pCall->Destroy(); - free(vstk); - - if(paramInfo != NULL) - { - free(paramInfo); - } - - return ret; -} diff --git a/vhook.cpp b/vhook.cpp index 0c9a6f7..d45532b 100644 --- a/vhook.cpp +++ b/vhook.cpp @@ -370,7 +370,7 @@ void *Callback(DHooksCallback *dg, void **argStack) #ifndef __linux__ float Callback_float(DHooksCallback *dg, void **argStack, size_t *argsizep) #else -void *Callback_float(DHooksCallback *dg, void **argStack) +float Callback_float(DHooksCallback *dg, void **argStack) #endif { HookReturnStruct *returnStruct = NULL; @@ -400,7 +400,7 @@ void *Callback_float(DHooksCallback *dg, void **argStack) delete returnStruct; } g_SHPtr->SetRes(MRES_IGNORED); - return NULL; + return 0.0; } dg->plugin_callback->PushCell(rHndl); @@ -426,7 +426,7 @@ void *Callback_float(DHooksCallback *dg, void **argStack) delete paramStruct; } g_SHPtr->SetRes(MRES_IGNORED); - return NULL; + return 0.0; } dg->plugin_callback->PushCell(pHndl); } @@ -517,11 +517,15 @@ void *Callback_float(DHooksCallback *dg, void **argStack) if(dg->returnType == ReturnType_Void || mres <= MRES_HANDLED) { - return NULL; + return 0.0; } return *(float *)ret; } +#ifndef __linux__ Vector *Callback_vector(DHooksCallback *dg, void **argStack, size_t *argsizep) +#else +Vector *Callback_vector(DHooksCallback *dg, void **argStack) +#endif { Vector *vec_result = (Vector *)argStack[0]; // Save the result @@ -670,7 +674,6 @@ Vector *Callback_vector(DHooksCallback *dg, void **argStack, size_t *argsizep) if(dg->returnType == ReturnType_Void || mres <= MRES_HANDLED) { - META_CONPRINT("Returning now\n"); vec_result->x = 0; vec_result->y = 0; vec_result->z = 0; diff --git a/vhook.h b/vhook.h index 8aa7d97..3264f65 100644 --- a/vhook.h +++ b/vhook.h @@ -165,6 +165,7 @@ Vector *Callback_vector(DHooksCallback *dg, void **stack, size_t *argsizep); #else void *Callback(DHooksCallback *dg, void **stack); float Callback_float(DHooksCallback *dg, void **stack); +Vector Callback_vector(DHooksCallback *dg, void **stack, size_t *argsizep); #endif bool SetupHookManager(ISmmAPI *ismm); void CleanupHooks(IPluginContext *pContext);