Change Vector classname to SDKVector.

This commit is contained in:
Dr!fter 2016-06-26 13:00:27 -04:00
parent 08f67ac307
commit 97c3cdf304
5 changed files with 51 additions and 51 deletions

View File

@ -439,9 +439,9 @@ cell_t Native_GetParamVector(IPluginContext *pContext, const cell_t *params)
{ {
cell_t *buffer; cell_t *buffer;
pContext->LocalToPhysAddr(params[3], &buffer); pContext->LocalToPhysAddr(params[3], &buffer);
buffer[0] = sp_ftoc(((Vector *)paramStruct->orgParams[index])->x); buffer[0] = sp_ftoc(((SDKVector *)paramStruct->orgParams[index])->x);
buffer[1] = sp_ftoc(((Vector *)paramStruct->orgParams[index])->y); buffer[1] = sp_ftoc(((SDKVector *)paramStruct->orgParams[index])->y);
buffer[2] = sp_ftoc(((Vector *)paramStruct->orgParams[index])->z); buffer[2] = sp_ftoc(((SDKVector *)paramStruct->orgParams[index])->z);
return 1; return 1;
} }
} }
@ -470,12 +470,12 @@ cell_t Native_SetParamVector(IPluginContext *pContext, const cell_t *params)
case HookParamType_VectorPtr: case HookParamType_VectorPtr:
{ {
if(paramStruct->newParams[index] != NULL) if(paramStruct->newParams[index] != NULL)
delete (Vector *)paramStruct->newParams[index]; delete (SDKVector *)paramStruct->newParams[index];
cell_t *buffer; cell_t *buffer;
pContext->LocalToPhysAddr(params[3], &buffer); pContext->LocalToPhysAddr(params[3], &buffer);
paramStruct->newParams[index] = new Vector(sp_ctof(buffer[0]), sp_ctof(buffer[1]), sp_ctof(buffer[2])); paramStruct->newParams[index] = new SDKVector(sp_ctof(buffer[0]), sp_ctof(buffer[1]), sp_ctof(buffer[2]));
paramStruct->isChanged[index] = true; paramStruct->isChanged[index] = true;
return 1; return 1;
} }
@ -817,11 +817,11 @@ cell_t Native_GetParamObjectPtrVarVector(IPluginContext *pContext, const cell_t
if((ObjectValueType)params[4] == ObjectValueType_VectorPtr || (ObjectValueType)params[4] == ObjectValueType_Vector) if((ObjectValueType)params[4] == ObjectValueType_VectorPtr || (ObjectValueType)params[4] == ObjectValueType_Vector)
{ {
Vector *vec; SDKVector *vec;
if((ObjectValueType)params[4] == ObjectValueType_VectorPtr) if((ObjectValueType)params[4] == ObjectValueType_VectorPtr)
{ {
vec = *(Vector **)(addr + params[3]); vec = *(SDKVector **)(addr + params[3]);
if(vec == NULL) if(vec == NULL)
{ {
return pContext->ThrowNativeError("Trying to get value for null pointer."); return pContext->ThrowNativeError("Trying to get value for null pointer.");
@ -829,7 +829,7 @@ cell_t Native_GetParamObjectPtrVarVector(IPluginContext *pContext, const cell_t
} }
else else
{ {
vec = (Vector *)(addr + params[3]); vec = (SDKVector *)(addr + params[3]);
} }
buffer[0] = sp_ftoc(vec->x); buffer[0] = sp_ftoc(vec->x);
@ -870,11 +870,11 @@ cell_t Native_SetParamObjectPtrVarVector(IPluginContext *pContext, const cell_t
if((ObjectValueType)params[4] == ObjectValueType_VectorPtr || (ObjectValueType)params[4] == ObjectValueType_Vector) if((ObjectValueType)params[4] == ObjectValueType_VectorPtr || (ObjectValueType)params[4] == ObjectValueType_Vector)
{ {
Vector *vec; SDKVector *vec;
if((ObjectValueType)params[4] == ObjectValueType_VectorPtr) if((ObjectValueType)params[4] == ObjectValueType_VectorPtr)
{ {
vec = *(Vector **)(addr + params[3]); vec = *(SDKVector **)(addr + params[3]);
if(vec == NULL) if(vec == NULL)
{ {
return pContext->ThrowNativeError("Trying to set value for null pointer."); return pContext->ThrowNativeError("Trying to set value for null pointer.");
@ -882,7 +882,7 @@ cell_t Native_SetParamObjectPtrVarVector(IPluginContext *pContext, const cell_t
} }
else else
{ {
vec = (Vector *)(addr + params[3]); vec = (SDKVector *)(addr + params[3]);
} }
vec->x = sp_ctof(buffer[0]); vec->x = sp_ctof(buffer[0]);
@ -952,17 +952,17 @@ cell_t Native_GetReturnVector(IPluginContext *pContext, const cell_t *params)
if(returnStruct->type == ReturnType_Vector) if(returnStruct->type == ReturnType_Vector)
{ {
buffer[0] = sp_ftoc((*(Vector *)returnStruct->orgResult).x); buffer[0] = sp_ftoc((*(SDKVector *)returnStruct->orgResult).x);
buffer[1] = sp_ftoc((*(Vector *)returnStruct->orgResult).y); buffer[1] = sp_ftoc((*(SDKVector *)returnStruct->orgResult).y);
buffer[2] = sp_ftoc((*(Vector *)returnStruct->orgResult).z); buffer[2] = sp_ftoc((*(SDKVector *)returnStruct->orgResult).z);
return 1; return 1;
} }
else if(returnStruct->type == ReturnType_VectorPtr) else if(returnStruct->type == ReturnType_VectorPtr)
{ {
buffer[0] = sp_ftoc(((Vector *)returnStruct->orgResult)->x); buffer[0] = sp_ftoc(((SDKVector *)returnStruct->orgResult)->x);
buffer[1] = sp_ftoc(((Vector *)returnStruct->orgResult)->y); buffer[1] = sp_ftoc(((SDKVector *)returnStruct->orgResult)->y);
buffer[2] = sp_ftoc(((Vector *)returnStruct->orgResult)->z); buffer[2] = sp_ftoc(((SDKVector *)returnStruct->orgResult)->z);
return 1; return 1;
} }
@ -984,13 +984,13 @@ cell_t Native_SetReturnVector(IPluginContext *pContext, const cell_t *params)
if(returnStruct->type == ReturnType_Vector) if(returnStruct->type == ReturnType_Vector)
{ {
*(Vector *)returnStruct->newResult = Vector(sp_ctof(buffer[0]), sp_ctof(buffer[1]), sp_ctof(buffer[2])); *(SDKVector *)returnStruct->newResult = SDKVector(sp_ctof(buffer[0]), sp_ctof(buffer[1]), sp_ctof(buffer[2]));
return 1; return 1;
} }
else if(returnStruct->type == ReturnType_VectorPtr) else if(returnStruct->type == ReturnType_VectorPtr)
{ {
returnStruct->newResult = new Vector(sp_ctof(buffer[0]), sp_ctof(buffer[1]), sp_ctof(buffer[2])); returnStruct->newResult = new SDKVector(sp_ctof(buffer[0]), sp_ctof(buffer[1]), sp_ctof(buffer[2]));
} }
return pContext->ThrowNativeError("Return type is not a vector type"); return pContext->ThrowNativeError("Return type is not a vector type");
} }

View File

@ -1,16 +1,16 @@
#ifndef _INCLUDE_SDK_HACKS_H_ #ifndef _INCLUDE_SDK_HACKS_H_
#define _INCLUDE_SDK_HACKS_H_ #define _INCLUDE_SDK_HACKS_H_
class Vector class SDKVector
{ {
public: public:
Vector(float x1, float y1, float z1) SDKVector(float x1, float y1, float z1)
{ {
this->x = x1; this->x = x1;
this->y = y1; this->y = y1;
this->z = z1; this->z = z1;
} }
Vector(void) SDKVector(void)
{ {
this->x = 0.0; this->x = 0.0;
this->y = 0.0; this->y = 0.0;

View File

@ -95,7 +95,7 @@ T CallVFunction(DHooksCallback *dg, HookParamsStruct *paramStruct, void *iface)
VSTK_PARAM_SWITCH(char *); VSTK_PARAM_SWITCH(char *);
case HookParamType_VectorPtr: case HookParamType_VectorPtr:
PARAMINFO_SWITCH(PassType_Basic); PARAMINFO_SWITCH(PassType_Basic);
VSTK_PARAM_SWITCH(Vector *); VSTK_PARAM_SWITCH(SDKVector *);
case HookParamType_CBaseEntity: case HookParamType_CBaseEntity:
PARAMINFO_SWITCH(PassType_Basic); PARAMINFO_SWITCH(PassType_Basic);
VSTK_PARAM_SWITCH(CBaseEntity *); VSTK_PARAM_SWITCH(CBaseEntity *);
@ -133,7 +133,7 @@ T CallVFunction(DHooksCallback *dg, HookParamsStruct *paramStruct, void *iface)
return ret; return ret;
} }
template <> template <>
Vector CallVFunction<Vector>(DHooksCallback *dg, HookParamsStruct *paramStruct, void *iface) SDKVector CallVFunction<SDKVector>(DHooksCallback *dg, HookParamsStruct *paramStruct, void *iface)
{ {
SourceMod::PassInfo *paramInfo = NULL; SourceMod::PassInfo *paramInfo = NULL;
SourceMod::PassInfo returnInfo; SourceMod::PassInfo returnInfo;
@ -141,7 +141,7 @@ Vector CallVFunction<Vector>(DHooksCallback *dg, HookParamsStruct *paramStruct,
if(dg->returnType != ReturnType_Void) if(dg->returnType != ReturnType_Void)
{ {
returnInfo.flags = dg->returnFlag; returnInfo.flags = dg->returnFlag;
returnInfo.size = sizeof(Vector); returnInfo.size = sizeof(SDKVector);
returnInfo.type = PassType_Object; returnInfo.type = PassType_Object;
} }
@ -182,7 +182,7 @@ Vector CallVFunction<Vector>(DHooksCallback *dg, HookParamsStruct *paramStruct,
VSTK_PARAM_SWITCH(char *); VSTK_PARAM_SWITCH(char *);
case HookParamType_VectorPtr: case HookParamType_VectorPtr:
PARAMINFO_SWITCH(PassType_Basic); PARAMINFO_SWITCH(PassType_Basic);
VSTK_PARAM_SWITCH(Vector *); VSTK_PARAM_SWITCH(SDKVector *);
case HookParamType_CBaseEntity: case HookParamType_CBaseEntity:
PARAMINFO_SWITCH(PassType_Basic); PARAMINFO_SWITCH(PassType_Basic);
VSTK_PARAM_SWITCH(CBaseEntity *); VSTK_PARAM_SWITCH(CBaseEntity *);
@ -196,7 +196,7 @@ Vector CallVFunction<Vector>(DHooksCallback *dg, HookParamsStruct *paramStruct,
} }
} }
Vector ret; SDKVector ret;
pCall = g_pBinTools->CreateVCall(dg->offset, 0, 0, &returnInfo, paramInfo, dg->params.size()); pCall = g_pBinTools->CreateVCall(dg->offset, 0, 0, &returnInfo, paramInfo, dg->params.size());
pCall->Execute(vstk, &ret); pCall->Execute(vstk, &ret);
@ -262,7 +262,7 @@ string_t CallVFunction<string_t>(DHooksCallback *dg, HookParamsStruct *paramStru
VSTK_PARAM_SWITCH(char *); VSTK_PARAM_SWITCH(char *);
case HookParamType_VectorPtr: case HookParamType_VectorPtr:
PARAMINFO_SWITCH(PassType_Basic); PARAMINFO_SWITCH(PassType_Basic);
VSTK_PARAM_SWITCH(Vector *); VSTK_PARAM_SWITCH(SDKVector *);
case HookParamType_CBaseEntity: case HookParamType_CBaseEntity:
PARAMINFO_SWITCH(PassType_Basic); PARAMINFO_SWITCH(PassType_Basic);
VSTK_PARAM_SWITCH(CBaseEntity *); VSTK_PARAM_SWITCH(CBaseEntity *);

View File

@ -61,7 +61,7 @@ DHooksManager::DHooksManager(HookSetup *setup, void *iface, IPluginFunction *rem
} }
else if(this->callback->returnType == ReturnType_Vector) else if(this->callback->returnType == ReturnType_Vector)
{ {
protoInfo.SetReturnType(sizeof(Vector), SourceHook::PassInfo::PassType_Object, setup->returnFlag, NULL, NULL, NULL, NULL); protoInfo.SetReturnType(sizeof(SDKVector), SourceHook::PassInfo::PassType_Object, setup->returnFlag, NULL, NULL, NULL, NULL);
} }
else else
{ {
@ -187,10 +187,10 @@ HookReturnStruct *GetReturnStruct(DHooksCallback *dg)
break; break;
case ReturnType_Vector: case ReturnType_Vector:
{ {
res->orgResult = malloc(sizeof(Vector)); res->orgResult = malloc(sizeof(SDKVector));
res->newResult = malloc(sizeof(Vector)); res->newResult = malloc(sizeof(SDKVector));
Vector vec = META_RESULT_ORIG_RET(Vector); SDKVector vec = META_RESULT_ORIG_RET(SDKVector);
*(Vector *)res->orgResult = vec; *(SDKVector *)res->orgResult = vec;
break; break;
} }
default: default:
@ -208,9 +208,9 @@ HookReturnStruct *GetReturnStruct(DHooksCallback *dg)
*(string_t *)res->orgResult = NULL_STRING; *(string_t *)res->orgResult = NULL_STRING;
break; break;
case ReturnType_Vector: case ReturnType_Vector:
res->orgResult = malloc(sizeof(Vector)); res->orgResult = malloc(sizeof(SDKVector));
res->newResult = malloc(sizeof(Vector)); res->newResult = malloc(sizeof(SDKVector));
*(Vector *)res->orgResult = Vector(); *(SDKVector *)res->orgResult = SDKVector();
break; break;
case ReturnType_Int: case ReturnType_Int:
res->orgResult = malloc(sizeof(int)); res->orgResult = malloc(sizeof(int));
@ -581,12 +581,12 @@ float Callback_float(DHooksCallback *dg, void **argStack)
return *(float *)ret; return *(float *)ret;
} }
#ifdef WIN32 #ifdef WIN32
Vector *Callback_vector(DHooksCallback *dg, void **argStack, size_t *argsizep) SDKVector *Callback_vector(DHooksCallback *dg, void **argStack, size_t *argsizep)
#else #else
Vector *Callback_vector(DHooksCallback *dg, void **argStack) SDKVector *Callback_vector(DHooksCallback *dg, void **argStack)
#endif #endif
{ {
Vector *vec_result = (Vector *)argStack[0]; // Save the result SDKVector *vec_result = (SDKVector *)argStack[0]; // Save the result
HookReturnStruct *returnStruct = NULL; HookReturnStruct *returnStruct = NULL;
HookParamsStruct *paramStruct = NULL; HookParamsStruct *paramStruct = NULL;
@ -658,14 +658,14 @@ Vector *Callback_vector(DHooksCallback *dg, void **argStack)
g_SHPtr->DoRecall(); g_SHPtr->DoRecall();
g_SHPtr->SetRes(MRES_SUPERCEDE); g_SHPtr->SetRes(MRES_SUPERCEDE);
mres = MRES_SUPERCEDE; mres = MRES_SUPERCEDE;
*vec_result = CallVFunction<Vector>(dg, paramStruct, g_SHPtr->GetIfacePtr()); *vec_result = CallVFunction<SDKVector>(dg, paramStruct, g_SHPtr->GetIfacePtr());
break; break;
case MRES_ChangedOverride: case MRES_ChangedOverride:
if(dg->returnType != ReturnType_Void) if(dg->returnType != ReturnType_Void)
{ {
if(returnStruct->isChanged) if(returnStruct->isChanged)
{ {
*vec_result = **(Vector **)returnStruct->newResult; *vec_result = **(SDKVector **)returnStruct->newResult;
} }
else //Throw an error if no override was set else //Throw an error if no override was set
{ {
@ -678,7 +678,7 @@ Vector *Callback_vector(DHooksCallback *dg, void **argStack)
g_SHPtr->DoRecall(); g_SHPtr->DoRecall();
g_SHPtr->SetRes(MRES_SUPERCEDE); g_SHPtr->SetRes(MRES_SUPERCEDE);
mres = MRES_SUPERCEDE; mres = MRES_SUPERCEDE;
CallVFunction<Vector>(dg, paramStruct, g_SHPtr->GetIfacePtr()); CallVFunction<SDKVector>(dg, paramStruct, g_SHPtr->GetIfacePtr());
break; break;
case MRES_Override: case MRES_Override:
if(dg->returnType != ReturnType_Void) if(dg->returnType != ReturnType_Void)
@ -687,7 +687,7 @@ Vector *Callback_vector(DHooksCallback *dg, void **argStack)
{ {
g_SHPtr->SetRes(MRES_OVERRIDE); g_SHPtr->SetRes(MRES_OVERRIDE);
mres = MRES_OVERRIDE; mres = MRES_OVERRIDE;
*vec_result = **(Vector **)returnStruct->newResult; *vec_result = **(SDKVector **)returnStruct->newResult;
} }
else //Throw an error if no override was set else //Throw an error if no override was set
{ {
@ -704,7 +704,7 @@ Vector *Callback_vector(DHooksCallback *dg, void **argStack)
{ {
g_SHPtr->SetRes(MRES_SUPERCEDE); g_SHPtr->SetRes(MRES_SUPERCEDE);
mres = MRES_SUPERCEDE; mres = MRES_SUPERCEDE;
*vec_result = **(Vector **)returnStruct->newResult; *vec_result = **(SDKVector **)returnStruct->newResult;
} }
else //Throw an error if no override was set else //Throw an error if no override was set
{ {
@ -826,7 +826,7 @@ string_t *Callback_stringt(DHooksCallback *dg, void **argStack)
g_SHPtr->DoRecall(); g_SHPtr->DoRecall();
g_SHPtr->SetRes(MRES_SUPERCEDE); g_SHPtr->SetRes(MRES_SUPERCEDE);
mres = MRES_SUPERCEDE; mres = MRES_SUPERCEDE;
CallVFunction<Vector>(dg, paramStruct, g_SHPtr->GetIfacePtr()); CallVFunction<SDKVector>(dg, paramStruct, g_SHPtr->GetIfacePtr());
break; break;
case MRES_Override: case MRES_Override:
if(dg->returnType != ReturnType_Void) if(dg->returnType != ReturnType_Void)

12
vhook.h
View File

@ -104,7 +104,7 @@ public:
} }
else if(this->type == ReturnType_VectorPtr) else if(this->type == ReturnType_VectorPtr)
{ {
delete (Vector *)this->newResult; delete (SDKVector *)this->newResult;
} }
} }
@ -150,11 +150,11 @@ public:
#ifdef WIN32 #ifdef WIN32
void *Callback(DHooksCallback *dg, void **stack, size_t *argsizep); void *Callback(DHooksCallback *dg, void **stack, size_t *argsizep);
float Callback_float(DHooksCallback *dg, void **stack, size_t *argsizep); float Callback_float(DHooksCallback *dg, void **stack, size_t *argsizep);
Vector *Callback_vector(DHooksCallback *dg, void **stack, size_t *argsizep); SDKVector *Callback_vector(DHooksCallback *dg, void **stack, size_t *argsizep);
#else #else
void *Callback(DHooksCallback *dg, void **stack); void *Callback(DHooksCallback *dg, void **stack);
float Callback_float(DHooksCallback *dg, void **stack); float Callback_float(DHooksCallback *dg, void **stack);
Vector *Callback_vector(DHooksCallback *dg, void **stack); SDKVector *Callback_vector(DHooksCallback *dg, void **stack);
string_t *Callback_stringt(DHooksCallback *dg, void **stack); string_t *Callback_stringt(DHooksCallback *dg, void **stack);
#endif #endif
@ -166,7 +166,7 @@ SourceHook::PassInfo::PassType GetParamTypePassType(HookParamType type);
#ifndef WIN32 #ifndef WIN32
static void *GenerateThunk(ReturnType type) static void *GenerateThunk(ReturnType type)
{ {
MacroAssemblerX86 masm; sp::MacroAssemblerX86 masm;
static const size_t kStackNeeded = (2) * 4; // 2 args max static const size_t kStackNeeded = (2) * 4; // 2 args max
static const size_t kReserve = ke::Align(kStackNeeded+8, 16)-8; static const size_t kReserve = ke::Align(kStackNeeded+8, 16)-8;
@ -215,7 +215,7 @@ static void *GenerateThunk(ReturnType type)
// HUGE THANKS TO BAILOPAN (dvander)! // HUGE THANKS TO BAILOPAN (dvander)!
static void *GenerateThunk(ReturnType type) static void *GenerateThunk(ReturnType type)
{ {
MacroAssemblerX86 masm; sp::MacroAssemblerX86 masm;
static const size_t kStackNeeded = (3 + 1) * 4; // 3 args max, 1 locals max static const size_t kStackNeeded = (3 + 1) * 4; // 3 args max, 1 locals max
static const size_t kReserve = ke::Align(kStackNeeded+8, 16)-8; static const size_t kReserve = ke::Align(kStackNeeded+8, 16)-8;
@ -294,7 +294,7 @@ public:
if(dg->params.at(i).type == HookParamType_VectorPtr) if(dg->params.at(i).type == HookParamType_VectorPtr)
{ {
delete (Vector *)this->newParams[i]; delete (SDKVector *)this->newParams[i];
} }
else if(dg->params.at(i).type == HookParamType_CharPtr) else if(dg->params.at(i).type == HookParamType_CharPtr)
{ {