This commit is contained in:
parent
97df408d51
commit
779a4d9e59
|
@ -238,20 +238,32 @@ static cell AMX_NATIVE_CALL SetHamParamVector(AMX *amx, cell *params)
|
||||||
int ret=dat->SetVector(MF_GetAmxAddr(amx, params[2]));
|
int ret=dat->SetVector(MF_GetAmxAddr(amx, params[2]));
|
||||||
PARSE_RETURN();
|
PARSE_RETURN();
|
||||||
}
|
}
|
||||||
static cell AMX_NATIVE_CALL SetHamParamEntity(AMX *amx, cell *params)
|
|
||||||
|
cell SetParamEntity(AMX *amx, cell *params, bool updateIndex)
|
||||||
{
|
{
|
||||||
CHECK_STACK(ParamStack);
|
CHECK_STACK(ParamStack);
|
||||||
ke::Vector<Data *> *vec = ParamStack.front();
|
ke::Vector<Data *> *vec = ParamStack.front();
|
||||||
if (vec->length() < (unsigned)params[1])
|
if (vec->length() < (unsigned)params[1])
|
||||||
{
|
{
|
||||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->length());
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->length());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Data *dat=vec->at(params[1] - 1);
|
Data *dat = vec->at(params[1] - 1);
|
||||||
|
|
||||||
int ret=dat->SetEntity(¶ms[2]);
|
int ret = dat->SetEntity(¶ms[2], updateIndex);
|
||||||
PARSE_RETURN();
|
PARSE_RETURN();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL SetHamParamEntity(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
return SetParamEntity(amx, params, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL SetHamParamEntity2(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
return SetParamEntity(amx, params, true);
|
||||||
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL SetHamParamString(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL SetHamParamString(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
CHECK_STACK(ParamStack);
|
CHECK_STACK(ParamStack);
|
||||||
|
@ -483,6 +495,7 @@ AMX_NATIVE_INFO ReturnNatives[] =
|
||||||
{ "SetHamParamFloat", SetHamParamFloat },
|
{ "SetHamParamFloat", SetHamParamFloat },
|
||||||
{ "SetHamParamVector", SetHamParamVector },
|
{ "SetHamParamVector", SetHamParamVector },
|
||||||
{ "SetHamParamEntity", SetHamParamEntity },
|
{ "SetHamParamEntity", SetHamParamEntity },
|
||||||
|
{ "SetHamParamEntity2", SetHamParamEntity2 },
|
||||||
{ "SetHamParamString", SetHamParamString },
|
{ "SetHamParamString", SetHamParamString },
|
||||||
{ "SetHamParamTraceResult", SetHamParamTraceResult },
|
{ "SetHamParamTraceResult", SetHamParamTraceResult },
|
||||||
{ "SetHamParamItemInfo", SetHamParamItemInfo },
|
{ "SetHamParamItemInfo", SetHamParamItemInfo },
|
||||||
|
|
|
@ -210,7 +210,7 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
int SetEntity(cell *data)
|
int SetEntity(cell *data, bool updateIndex = false)
|
||||||
{
|
{
|
||||||
if (!IsSet())
|
if (!IsSet())
|
||||||
{
|
{
|
||||||
|
@ -219,7 +219,7 @@ public:
|
||||||
if (IsType(RET_CBASE))
|
if (IsType(RET_CBASE))
|
||||||
{
|
{
|
||||||
*(reinterpret_cast<void **>(m_data))= TypeConversion.id_to_cbase(*data);
|
*(reinterpret_cast<void **>(m_data))= TypeConversion.id_to_cbase(*data);
|
||||||
if (m_index != 0)
|
if (updateIndex && m_index)
|
||||||
{
|
{
|
||||||
*m_index=*data;
|
*m_index=*data;
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ public:
|
||||||
else if (IsType(RET_ENTVAR))
|
else if (IsType(RET_ENTVAR))
|
||||||
{
|
{
|
||||||
*(reinterpret_cast<entvars_t **>(m_data))= TypeConversion.id_to_entvars(*data);
|
*(reinterpret_cast<entvars_t **>(m_data))= TypeConversion.id_to_entvars(*data);
|
||||||
if (m_index != 0)
|
if (updateIndex && m_index)
|
||||||
{
|
{
|
||||||
*m_index=*data;
|
*m_index=*data;
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ public:
|
||||||
else if (IsType(RET_EDICT))
|
else if (IsType(RET_EDICT))
|
||||||
{
|
{
|
||||||
*(reinterpret_cast<edict_t **>(m_data)) = TypeConversion.id_to_edict(*data);
|
*(reinterpret_cast<edict_t **>(m_data)) = TypeConversion.id_to_edict(*data);
|
||||||
if (m_index != 0)
|
if (updateIndex && m_index)
|
||||||
{
|
{
|
||||||
*m_index = *data;
|
*m_index = *data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,11 +265,25 @@ native SetHamParamVector(which, const Float:value[3]);
|
||||||
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
|
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
|
||||||
* Use this on parameters that are entities.
|
* Use this on parameters that are entities.
|
||||||
*
|
*
|
||||||
|
* @note Due to a historical bug, the changes made by this native are not reflected in the corresponding post forward
|
||||||
|
* for backward compatibility reasons. Use SetHamParamEntity2 if this is required.
|
||||||
|
*
|
||||||
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
|
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
|
||||||
* @param value The value to change it to.
|
* @param value The value to change it to.
|
||||||
*/
|
*/
|
||||||
native SetHamParamEntity(which, value);
|
native SetHamParamEntity(which, value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
|
||||||
|
* Use this on parameters that are entities.
|
||||||
|
*
|
||||||
|
* @note Same as SetHamParamEntity except the changes made by this native are reflected in the corresponding post forward.
|
||||||
|
*
|
||||||
|
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
|
||||||
|
* @param value The value to change it to.
|
||||||
|
*/
|
||||||
|
native SetHamParamEntity2(which, value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
|
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
|
||||||
* Use this on parameters that are strings.
|
* Use this on parameters that are strings.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user