Added the ability to change parameters on the fly.
Added GetHamReturnStatus()
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
CStack< Data * > ReturnStack;
|
||||
CStack< Data * > OrigReturnStack;
|
||||
CStack< CVector< Data * > * > ParamStack;
|
||||
|
||||
CStack< int * > ReturnStatus;
|
||||
#define CHECK_STACK(__STACK__) \
|
||||
if ( ( __STACK__ ).size() <= 0) \
|
||||
{ \
|
||||
@@ -38,7 +38,10 @@ static const char *returntypes[] =
|
||||
"float",
|
||||
"vector",
|
||||
"string",
|
||||
"cbase",
|
||||
"entity",
|
||||
"entity",
|
||||
"traceresult"
|
||||
""
|
||||
};
|
||||
|
||||
static cell AMX_NATIVE_CALL GetHamReturnInteger(AMX *amx, cell *params)
|
||||
@@ -89,20 +92,20 @@ static cell AMX_NATIVE_CALL GetOrigHamReturnVector(AMX *amx, cell *params)
|
||||
int ret=dat->GetVector(MF_GetAmxAddr(amx, params[1]));
|
||||
PARSE_RETURN();
|
||||
}
|
||||
static cell AMX_NATIVE_CALL GetHamReturnCbase(AMX *amx, cell *params)
|
||||
static cell AMX_NATIVE_CALL GetHamReturnEntity(AMX *amx, cell *params)
|
||||
{
|
||||
CHECK_STACK(ReturnStack);
|
||||
Data *dat=ReturnStack.front();
|
||||
|
||||
int ret=dat->GetCbase(MF_GetAmxAddr(amx, params[1]));
|
||||
int ret=dat->GetEntity(MF_GetAmxAddr(amx, params[1]));
|
||||
PARSE_RETURN();
|
||||
}
|
||||
static cell AMX_NATIVE_CALL GetOrigHamReturnCbase(AMX *amx, cell *params)
|
||||
static cell AMX_NATIVE_CALL GetOrigHamReturnEntity(AMX *amx, cell *params)
|
||||
{
|
||||
CHECK_STACK(OrigReturnStack);
|
||||
Data *dat=OrigReturnStack.front();
|
||||
|
||||
int ret=dat->GetCbase(MF_GetAmxAddr(amx, params[1]));
|
||||
int ret=dat->GetEntity(MF_GetAmxAddr(amx, params[1]));
|
||||
PARSE_RETURN();
|
||||
}
|
||||
static cell AMX_NATIVE_CALL GetHamReturnString(AMX *amx, cell *params)
|
||||
@@ -145,12 +148,12 @@ static cell AMX_NATIVE_CALL SetHamReturnVector(AMX *amx, cell *params)
|
||||
int ret=dat->SetVector(MF_GetAmxAddr(amx, params[1]));
|
||||
PARSE_RETURN();
|
||||
}
|
||||
static cell AMX_NATIVE_CALL SetHamReturnCbase(AMX *amx, cell *params)
|
||||
static cell AMX_NATIVE_CALL SetHamReturnEntity(AMX *amx, cell *params)
|
||||
{
|
||||
CHECK_STACK(ReturnStack);
|
||||
Data *dat=ReturnStack.front();
|
||||
|
||||
int ret=dat->SetCbase(¶ms[1]);
|
||||
int ret=dat->SetEntity(¶ms[1]);
|
||||
PARSE_RETURN();
|
||||
}
|
||||
static cell AMX_NATIVE_CALL SetHamReturnString(AMX *amx, cell *params)
|
||||
@@ -161,23 +164,130 @@ static cell AMX_NATIVE_CALL SetHamReturnString(AMX *amx, cell *params)
|
||||
int ret=dat->SetString(MF_GetAmxAddr(amx, params[1]));
|
||||
PARSE_RETURN();
|
||||
}
|
||||
static cell AMX_NATIVE_CALL SetHamParamInteger(AMX *amx, cell *params)
|
||||
{
|
||||
CHECK_STACK(ParamStack);
|
||||
CVector<Data *> *vec=ParamStack.front();
|
||||
if (vec->size() < (unsigned)params[1])
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
|
||||
return 0;
|
||||
}
|
||||
Data *dat=vec->at(params[1] - 1);
|
||||
|
||||
int ret=dat->SetInt(¶ms[2]);
|
||||
PARSE_RETURN();
|
||||
}
|
||||
static cell AMX_NATIVE_CALL SetHamParamTraceResult(AMX *amx, cell *params)
|
||||
{
|
||||
if (params[2] == 0)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Null traceresult provided.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
CHECK_STACK(ParamStack);
|
||||
CVector<Data *> *vec=ParamStack.front();
|
||||
if (vec->size() < (unsigned)params[1])
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
|
||||
return 0;
|
||||
}
|
||||
Data *dat=vec->at(params[1] - 1);
|
||||
|
||||
int ret=dat->SetInt(¶ms[2]);
|
||||
PARSE_RETURN();
|
||||
}
|
||||
static cell AMX_NATIVE_CALL SetHamParamFloat(AMX *amx, cell *params)
|
||||
{
|
||||
CHECK_STACK(ParamStack);
|
||||
CVector<Data *> *vec=ParamStack.front();
|
||||
if (vec->size() < (unsigned)params[1] || params[1] < 1)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
|
||||
return 0;
|
||||
}
|
||||
Data *dat=vec->at(params[1] - 1);
|
||||
|
||||
int ret=dat->SetFloat(¶ms[2]);
|
||||
PARSE_RETURN();
|
||||
}
|
||||
static cell AMX_NATIVE_CALL SetHamParamVector(AMX *amx, cell *params)
|
||||
{
|
||||
CHECK_STACK(ParamStack);
|
||||
CVector<Data *> *vec=ParamStack.front();
|
||||
if (vec->size() < (unsigned)params[1])
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
|
||||
return 0;
|
||||
}
|
||||
Data *dat=vec->at(params[1] - 1);
|
||||
|
||||
int ret=dat->SetVector(MF_GetAmxAddr(amx, params[2]));
|
||||
PARSE_RETURN();
|
||||
}
|
||||
static cell AMX_NATIVE_CALL SetHamParamEntity(AMX *amx, cell *params)
|
||||
{
|
||||
CHECK_STACK(ParamStack);
|
||||
CVector<Data *> *vec=ParamStack.front();
|
||||
if (vec->size() < (unsigned)params[1])
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
|
||||
return 0;
|
||||
}
|
||||
Data *dat=vec->at(params[1] - 1);
|
||||
|
||||
int ret=dat->SetEntity(¶ms[2]);
|
||||
PARSE_RETURN();
|
||||
}
|
||||
static cell AMX_NATIVE_CALL SetHamParamString(AMX *amx, cell *params)
|
||||
{
|
||||
CHECK_STACK(ParamStack);
|
||||
CVector<Data *> *vec=ParamStack.front();
|
||||
if (vec->size() < (unsigned)params[1])
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
|
||||
return 0;
|
||||
}
|
||||
Data *dat=vec->at(params[1] - 1);
|
||||
|
||||
int ret=dat->SetString(MF_GetAmxAddr(amx, params[2]));
|
||||
PARSE_RETURN();
|
||||
}
|
||||
static cell AMX_NATIVE_CALL GetHamReturnStatus(AMX *amx, cell *params)
|
||||
{
|
||||
CHECK_STACK(ReturnStatus);
|
||||
int *i=ReturnStatus.front();
|
||||
|
||||
return *i;
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO ReturnNatives[] =
|
||||
{
|
||||
{ "GetHamReturnInteger", GetHamReturnInteger },
|
||||
{ "GetHamReturnFloat", GetHamReturnFloat },
|
||||
{ "GetHamReturnVector", GetHamReturnVector },
|
||||
{ "GetHamReturnCbase", GetHamReturnCbase },
|
||||
{ "GetHamReturnEntity", GetHamReturnEntity },
|
||||
{ "GetHamReturnString", GetHamReturnString },
|
||||
{ "GetOrigHamReturnInteger", GetOrigHamReturnInteger },
|
||||
{ "GetOrigHamReturnFloat", GetOrigHamReturnFloat },
|
||||
{ "GetOrigHamReturnVector", GetOrigHamReturnVector },
|
||||
{ "GetOrigHamReturnCbase", GetOrigHamReturnCbase },
|
||||
{ "GetOrigHamReturnEntity", GetOrigHamReturnEntity },
|
||||
{ "GetOrigHamReturnString", GetOrigHamReturnString },
|
||||
{ "SetHamReturnInteger", SetHamReturnInteger },
|
||||
{ "SetHamReturnFloat", SetHamReturnFloat },
|
||||
{ "SetHamReturnVector", SetHamReturnVector },
|
||||
{ "SetHamReturnCbase", SetHamReturnCbase },
|
||||
{ "SetHamReturnEntity", SetHamReturnEntity },
|
||||
{ "SetHamReturnString", SetHamReturnString },
|
||||
|
||||
{ "GetHamReturnStatus", GetHamReturnStatus },
|
||||
|
||||
{ "SetHamParamInteger", SetHamParamInteger },
|
||||
{ "SetHamParamFloat", SetHamParamFloat },
|
||||
{ "SetHamParamVector", SetHamParamVector },
|
||||
{ "SetHamParamEntity", SetHamParamEntity },
|
||||
{ "SetHamParamString", SetHamParamString },
|
||||
{ "SetHamParamTraceResult", SetHamParamTraceResult },
|
||||
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user