2007-05-08 17:26:51 +00:00
|
|
|
#include "sdk/amxxmodule.h"
|
|
|
|
|
|
|
|
#include "CVector.h"
|
|
|
|
#include "CString.h"
|
|
|
|
#include "sh_stack.h"
|
|
|
|
#include "DataHandler.h"
|
|
|
|
|
|
|
|
#include "ham_const.h"
|
|
|
|
#include "ham_utils.h"
|
|
|
|
#include "NEW_Util.h"
|
|
|
|
|
|
|
|
CStack< Data * > ReturnStack;
|
|
|
|
CStack< Data * > OrigReturnStack;
|
|
|
|
CStack< CVector< Data * > * > ParamStack;
|
2007-05-09 14:58:55 +00:00
|
|
|
CStack< int * > ReturnStatus;
|
2007-05-08 17:26:51 +00:00
|
|
|
#define CHECK_STACK(__STACK__) \
|
|
|
|
if ( ( __STACK__ ).size() <= 0) \
|
|
|
|
{ \
|
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "%s is empty!", #__STACK__); \
|
|
|
|
return 0; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define PARSE_RETURN() \
|
|
|
|
if (ret==-2) \
|
|
|
|
{ \
|
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Data pointer is NULL!"); \
|
|
|
|
} \
|
|
|
|
else if (ret==-1) \
|
|
|
|
{ \
|
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Wrong data type (data is of type %s)", returntypes[dat->GetType()]); \
|
|
|
|
} \
|
|
|
|
return ret
|
|
|
|
|
|
|
|
static const char *returntypes[] =
|
|
|
|
{
|
|
|
|
"void",
|
|
|
|
"integer",
|
|
|
|
"float",
|
|
|
|
"vector",
|
|
|
|
"string",
|
2007-05-09 14:58:55 +00:00
|
|
|
"entity",
|
|
|
|
"entity",
|
2007-05-10 16:08:02 +00:00
|
|
|
"traceresult",
|
|
|
|
"iteminfo"
|
2007-05-08 17:26:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL GetHamReturnInteger(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
CHECK_STACK(ReturnStack);
|
|
|
|
Data *dat=ReturnStack.front();
|
|
|
|
|
|
|
|
int ret=dat->GetInt(MF_GetAmxAddr(amx, params[1]));
|
|
|
|
PARSE_RETURN();
|
|
|
|
}
|
|
|
|
static cell AMX_NATIVE_CALL GetOrigHamReturnInteger(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
CHECK_STACK(OrigReturnStack);
|
|
|
|
Data *dat=OrigReturnStack.front();
|
|
|
|
|
|
|
|
int ret=dat->GetInt(MF_GetAmxAddr(amx, params[1]));
|
|
|
|
PARSE_RETURN();
|
|
|
|
}
|
|
|
|
static cell AMX_NATIVE_CALL GetHamReturnFloat(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
CHECK_STACK(ReturnStack);
|
|
|
|
Data *dat=ReturnStack.front();
|
|
|
|
|
|
|
|
int ret=dat->GetFloat(MF_GetAmxAddr(amx, params[1]));
|
|
|
|
PARSE_RETURN();
|
|
|
|
}
|
|
|
|
static cell AMX_NATIVE_CALL GetOrigHamReturnFloat(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
CHECK_STACK(OrigReturnStack);
|
|
|
|
Data *dat=OrigReturnStack.front();
|
|
|
|
|
|
|
|
int ret=dat->GetFloat(MF_GetAmxAddr(amx, params[1]));
|
|
|
|
PARSE_RETURN();
|
|
|
|
}
|
|
|
|
static cell AMX_NATIVE_CALL GetHamReturnVector(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
CHECK_STACK(ReturnStack);
|
|
|
|
Data *dat=ReturnStack.front();
|
|
|
|
|
|
|
|
int ret=dat->GetVector(MF_GetAmxAddr(amx, params[1]));
|
|
|
|
PARSE_RETURN();
|
|
|
|
}
|
|
|
|
static cell AMX_NATIVE_CALL GetOrigHamReturnVector(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
CHECK_STACK(OrigReturnStack);
|
|
|
|
Data *dat=OrigReturnStack.front();
|
|
|
|
|
|
|
|
int ret=dat->GetVector(MF_GetAmxAddr(amx, params[1]));
|
|
|
|
PARSE_RETURN();
|
|
|
|
}
|
2007-05-09 14:58:55 +00:00
|
|
|
static cell AMX_NATIVE_CALL GetHamReturnEntity(AMX *amx, cell *params)
|
2007-05-08 17:26:51 +00:00
|
|
|
{
|
|
|
|
CHECK_STACK(ReturnStack);
|
|
|
|
Data *dat=ReturnStack.front();
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
int ret=dat->GetEntity(MF_GetAmxAddr(amx, params[1]));
|
2007-05-08 17:26:51 +00:00
|
|
|
PARSE_RETURN();
|
|
|
|
}
|
2007-05-09 14:58:55 +00:00
|
|
|
static cell AMX_NATIVE_CALL GetOrigHamReturnEntity(AMX *amx, cell *params)
|
2007-05-08 17:26:51 +00:00
|
|
|
{
|
|
|
|
CHECK_STACK(OrigReturnStack);
|
|
|
|
Data *dat=OrigReturnStack.front();
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
int ret=dat->GetEntity(MF_GetAmxAddr(amx, params[1]));
|
2007-05-08 17:26:51 +00:00
|
|
|
PARSE_RETURN();
|
|
|
|
}
|
|
|
|
static cell AMX_NATIVE_CALL GetHamReturnString(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
CHECK_STACK(ReturnStack);
|
|
|
|
Data *dat=ReturnStack.front();
|
|
|
|
|
|
|
|
int ret=dat->GetString(MF_GetAmxAddr(amx, params[1]), params[2]);
|
|
|
|
PARSE_RETURN();
|
|
|
|
}
|
|
|
|
static cell AMX_NATIVE_CALL GetOrigHamReturnString(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
CHECK_STACK(OrigReturnStack);
|
|
|
|
Data *dat=OrigReturnStack.front();
|
|
|
|
|
|
|
|
int ret=dat->GetString(MF_GetAmxAddr(amx, params[1]), params[2]);
|
|
|
|
PARSE_RETURN();
|
|
|
|
}
|
|
|
|
static cell AMX_NATIVE_CALL SetHamReturnInteger(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
CHECK_STACK(ReturnStack);
|
|
|
|
Data *dat=ReturnStack.front();
|
|
|
|
|
|
|
|
int ret=dat->SetInt(¶ms[1]);
|
|
|
|
PARSE_RETURN();
|
|
|
|
}
|
|
|
|
static cell AMX_NATIVE_CALL SetHamReturnFloat(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
CHECK_STACK(ReturnStack);
|
|
|
|
Data *dat=ReturnStack.front();
|
|
|
|
|
|
|
|
int ret=dat->SetFloat(¶ms[1]);
|
|
|
|
PARSE_RETURN();
|
|
|
|
}
|
|
|
|
static cell AMX_NATIVE_CALL SetHamReturnVector(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
CHECK_STACK(ReturnStack);
|
|
|
|
Data *dat=ReturnStack.front();
|
|
|
|
|
|
|
|
int ret=dat->SetVector(MF_GetAmxAddr(amx, params[1]));
|
|
|
|
PARSE_RETURN();
|
|
|
|
}
|
2007-05-09 14:58:55 +00:00
|
|
|
static cell AMX_NATIVE_CALL SetHamReturnEntity(AMX *amx, cell *params)
|
2007-05-08 17:26:51 +00:00
|
|
|
{
|
|
|
|
CHECK_STACK(ReturnStack);
|
|
|
|
Data *dat=ReturnStack.front();
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
int ret=dat->SetEntity(¶ms[1]);
|
2007-05-08 17:26:51 +00:00
|
|
|
PARSE_RETURN();
|
|
|
|
}
|
|
|
|
static cell AMX_NATIVE_CALL SetHamReturnString(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
CHECK_STACK(ReturnStack);
|
|
|
|
Data *dat=ReturnStack.front();
|
|
|
|
|
|
|
|
int ret=dat->SetString(MF_GetAmxAddr(amx, params[1]));
|
|
|
|
PARSE_RETURN();
|
|
|
|
}
|
2007-05-09 14:58:55 +00:00
|
|
|
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;
|
|
|
|
}
|
2007-05-08 17:26:51 +00:00
|
|
|
|
|
|
|
AMX_NATIVE_INFO ReturnNatives[] =
|
|
|
|
{
|
|
|
|
{ "GetHamReturnInteger", GetHamReturnInteger },
|
|
|
|
{ "GetHamReturnFloat", GetHamReturnFloat },
|
|
|
|
{ "GetHamReturnVector", GetHamReturnVector },
|
2007-05-09 14:58:55 +00:00
|
|
|
{ "GetHamReturnEntity", GetHamReturnEntity },
|
2007-05-08 17:26:51 +00:00
|
|
|
{ "GetHamReturnString", GetHamReturnString },
|
|
|
|
{ "GetOrigHamReturnInteger", GetOrigHamReturnInteger },
|
|
|
|
{ "GetOrigHamReturnFloat", GetOrigHamReturnFloat },
|
|
|
|
{ "GetOrigHamReturnVector", GetOrigHamReturnVector },
|
2007-05-09 14:58:55 +00:00
|
|
|
{ "GetOrigHamReturnEntity", GetOrigHamReturnEntity },
|
2007-05-08 17:26:51 +00:00
|
|
|
{ "GetOrigHamReturnString", GetOrigHamReturnString },
|
|
|
|
{ "SetHamReturnInteger", SetHamReturnInteger },
|
|
|
|
{ "SetHamReturnFloat", SetHamReturnFloat },
|
|
|
|
{ "SetHamReturnVector", SetHamReturnVector },
|
2007-05-09 14:58:55 +00:00
|
|
|
{ "SetHamReturnEntity", SetHamReturnEntity },
|
2007-05-08 17:26:51 +00:00
|
|
|
{ "SetHamReturnString", SetHamReturnString },
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
{ "GetHamReturnStatus", GetHamReturnStatus },
|
|
|
|
|
|
|
|
{ "SetHamParamInteger", SetHamParamInteger },
|
|
|
|
{ "SetHamParamFloat", SetHamParamFloat },
|
|
|
|
{ "SetHamParamVector", SetHamParamVector },
|
|
|
|
{ "SetHamParamEntity", SetHamParamEntity },
|
|
|
|
{ "SetHamParamString", SetHamParamString },
|
|
|
|
{ "SetHamParamTraceResult", SetHamParamTraceResult },
|
|
|
|
|
2007-05-08 17:26:51 +00:00
|
|
|
{ NULL, NULL },
|
|
|
|
};
|