Update - working
This commit is contained in:
		
							parent
							
								
									61c887f042
								
							
						
					
					
						commit
						ae3ca716ce
					
				
							
								
								
									
										21
									
								
								natives.cpp
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								natives.cpp
									
									
									
									
									
								
							@ -37,6 +37,7 @@ cell_t Native_CreateHook(IPluginContext *pContext, const cell_t *params)
 | 
				
			|||||||
	return hndl;
 | 
						return hndl;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
//native bool:DHookAddParam(Handle:setup, HookParamType:type);
 | 
					//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)
 | 
					cell_t Native_AddParam(IPluginContext *pContext, const cell_t *params)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if(params[1] == BAD_HANDLE)
 | 
						if(params[1] == BAD_HANDLE)
 | 
				
			||||||
@ -54,17 +55,19 @@ cell_t Native_AddParam(IPluginContext *pContext, const cell_t *params)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	ParamInfo info;
 | 
						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
 | 
						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);
 | 
						info.pass_type = GetParamTypePassType(info.type);
 | 
				
			||||||
	setup->params.AddToTail(info);
 | 
						setup->params.AddToTail(info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -190,7 +193,7 @@ cell_t Native_GetReturn(IPluginContext *pContext, const cell_t *params)
 | 
				
			|||||||
		case ReturnType_Int:
 | 
							case ReturnType_Int:
 | 
				
			||||||
			return *(int *)returnStruct->orgResult;
 | 
								return *(int *)returnStruct->orgResult;
 | 
				
			||||||
		case ReturnType_Bool:
 | 
							case ReturnType_Bool:
 | 
				
			||||||
			return *(cell_t *)returnStruct->orgResult;
 | 
								return *(bool *)returnStruct->orgResult? 1 : 0;
 | 
				
			||||||
		case ReturnType_CBaseEntity:
 | 
							case ReturnType_CBaseEntity:
 | 
				
			||||||
			return gamehelpers->EntityToBCompatRef((CBaseEntity *)returnStruct->orgResult);
 | 
								return gamehelpers->EntityToBCompatRef((CBaseEntity *)returnStruct->orgResult);
 | 
				
			||||||
		case ReturnType_Edict:
 | 
							case ReturnType_Edict:
 | 
				
			||||||
@ -224,10 +227,10 @@ cell_t Native_SetReturn(IPluginContext *pContext, const cell_t *params)
 | 
				
			|||||||
	switch(returnStruct->type)
 | 
						switch(returnStruct->type)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		case ReturnType_Int:
 | 
							case ReturnType_Int:
 | 
				
			||||||
			returnStruct->newResult = (void *)((int)params[2]);
 | 
								returnStruct->newResult = (int *)params[2];
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case ReturnType_Bool:
 | 
							case ReturnType_Bool:
 | 
				
			||||||
			returnStruct->newResult = (void *)(params[2] != 0);
 | 
								returnStruct->newResult = (bool *)(params[2]);
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case ReturnType_CBaseEntity:
 | 
							case ReturnType_CBaseEntity:
 | 
				
			||||||
			pEnt = UTIL_GetCBaseEntity(params[2]);
 | 
								pEnt = UTIL_GetCBaseEntity(params[2]);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										17
									
								
								vhook.cpp
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								vhook.cpp
									
									
									
									
									
								
							@ -80,6 +80,8 @@ SourceHook::PassInfo::PassType GetParamTypePassType(HookParamType type)
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		case HookParamType_Float:
 | 
							case HookParamType_Float:
 | 
				
			||||||
			return SourceHook::PassInfo::PassType_Float;
 | 
								return SourceHook::PassInfo::PassType_Float;
 | 
				
			||||||
 | 
							case HookParamType_Object:
 | 
				
			||||||
 | 
								return SourceHook::PassInfo::PassType_Object;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return SourceHook::PassInfo::PassType_Basic;
 | 
						return SourceHook::PassInfo::PassType_Basic;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -123,15 +125,18 @@ HookReturnStruct *GetReturnStruct(DHooksCallback *dg, const void *result)
 | 
				
			|||||||
			//ReturnType_String,
 | 
								//ReturnType_String,
 | 
				
			||||||
			//ReturnType_Vector,
 | 
								//ReturnType_Vector,
 | 
				
			||||||
			case ReturnType_Int:
 | 
								case ReturnType_Int:
 | 
				
			||||||
			case ReturnType_Bool:
 | 
					 | 
				
			||||||
				res->orgResult = (int *)result;
 | 
									res->orgResult = (int *)result;
 | 
				
			||||||
 | 
								case ReturnType_Bool:
 | 
				
			||||||
 | 
									res->orgResult = (bool *)result;
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
			case ReturnType_Float:
 | 
								case ReturnType_Float:
 | 
				
			||||||
				res->orgResult = new float;
 | 
									res->orgResult = new float;
 | 
				
			||||||
				*fpVal = *(float *)result;
 | 
									*fpVal = *(float *)result;
 | 
				
			||||||
				res->orgResult = fpVal;
 | 
									res->orgResult = fpVal;
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
			default:
 | 
								default:
 | 
				
			||||||
				res->orgResult = (void *)result;
 | 
									res->orgResult = (void *)result;
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
@ -217,7 +222,7 @@ void *Callback(DHooksCallback *dg, void **argStack)
 | 
				
			|||||||
	dg->plugin_callback->Execute(&result);
 | 
						dg->plugin_callback->Execute(&result);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void *ret = g_SHPtr->GetOverrideRetPtr();
 | 
						void *ret = g_SHPtr->GetOverrideRetPtr();
 | 
				
			||||||
	ret = 0;
 | 
					
 | 
				
			||||||
	switch((MRESReturn)result)
 | 
						switch((MRESReturn)result)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		case MRES_Handled:
 | 
							case MRES_Handled:
 | 
				
			||||||
@ -243,12 +248,12 @@ void *Callback(DHooksCallback *dg, void **argStack)
 | 
				
			|||||||
			if(dg->returnType != ReturnType_Void)
 | 
								if(dg->returnType != ReturnType_Void)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				if(returnStruct->isChanged)
 | 
									if(returnStruct->isChanged)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ret = returnStruct->newResult;
 | 
										ret = returnStruct->newResult;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				else if(dg->post)
 | 
									else if(dg->post)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ret = (void *)returnStruct->orgResult;
 | 
										ret = returnStruct->orgResult;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
@ -257,7 +262,7 @@ void *Callback(DHooksCallback *dg, void **argStack)
 | 
				
			|||||||
			if(dg->returnType != ReturnType_Void)
 | 
								if(dg->returnType != ReturnType_Void)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				if(returnStruct->isChanged)
 | 
									if(returnStruct->isChanged)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ret = returnStruct->newResult;
 | 
										ret = returnStruct->newResult;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				else if(dg->post)
 | 
									else if(dg->post)
 | 
				
			||||||
@ -283,4 +288,4 @@ void *Callback(DHooksCallback *dg, void **argStack)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										3
									
								
								vhook.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								vhook.h
									
									
									
									
									
								
							@ -27,7 +27,8 @@ enum HookParamType
 | 
				
			|||||||
	HookParamType_VectorPtr,
 | 
						HookParamType_VectorPtr,
 | 
				
			||||||
	HookParamType_CBaseEntity,
 | 
						HookParamType_CBaseEntity,
 | 
				
			||||||
	HookParamType_ObjectPtr,
 | 
						HookParamType_ObjectPtr,
 | 
				
			||||||
	HookParamType_Edict
 | 
						HookParamType_Edict,
 | 
				
			||||||
 | 
						HookParamType_Object
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum ReturnType
 | 
					enum ReturnType
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user