2
0
mirror of https://github.com/rehlds/reapi.git synced 2024-12-29 08:05:36 +03:00

Avoid unnecessary copying in rg_fire_bullets3

This commit is contained in:
asmodai 2016-04-30 21:02:30 +03:00
parent 12b0573aa5
commit e0fb129f4d
3 changed files with 16 additions and 10 deletions

View File

@ -24,6 +24,7 @@ task publishPrepareFiles << {
//project.file('publish/publishRoot/reapi/addons/amxmodx/scripting/include').mkdirs()
_copyFileToDir('publish/reapi_amxx.dll', 'publish/publishRoot/reapi/addons/amxmodx/modules/')
_copyFileToDir('publish/reapi_amxx.pdb', 'publish/publishRoot/reapi/addons/amxmodx/modules/')
_copyFile('publish/libreapi_amxx_i386.so', 'publish/publishRoot/reapi/addons/amxmodx/modules/reapi_amxx_i386.so')
copy {

View File

@ -7,7 +7,7 @@ class CAmxArg
{
public:
CAmxArg(AMX* amx, cell value) : m_amx(amx), m_value(value) {}
operator float() const
operator float&() const
{
return *(float *)m_value;
}
@ -17,9 +17,8 @@ public:
}
operator entvars_s*() const
{
if (m_value < 0)
return nullptr;
return PEV(m_value);
auto pev = PEV(m_value);
return m_value < 0 ? nullptr : pev;
}
operator int() const
{
@ -35,12 +34,17 @@ public:
}
operator CBaseEntity*() const
{
return g_ReGameFuncs->UTIL_PlayerByIndex(m_value);
auto player = g_ReGameFuncs->UTIL_PlayerByIndex(m_value);
return m_value < 0 ? nullptr : player;
}
operator PLAYER_ANIM() const
{
return static_cast<PLAYER_ANIM>(m_value);
}
operator ICSEntity*() const
{
return g_ReGameFuncs->INDEX_TO_CSENTITY(m_value);
}
Vector& vector() const
{

View File

@ -214,14 +214,14 @@ cell AMX_NATIVE_CALL rg_multidmg_add(AMX *amx, cell *params)
CHECK_ISENTITY(params[arg_inflictor]);
CHECK_ISENTITY(params[arg_victim]);
CAmxArgs args(amx, params);
if (params[arg_victim] < 0) { // null
MF_LogError(amx, AMX_ERR_NATIVE, "rg_multidmg_add: victim == null");
return FALSE;
}
CAmxArgs args(amx, params);
g_ReGameFuncs->AddMultiDamage(args[arg_inflictor], args[arg_victim], args[arg_damage], args[arg_dmg_type]);
return TRUE;
}
@ -251,7 +251,7 @@ cell AMX_NATIVE_CALL rg_fire_bullets(AMX *amx, cell *params)
CHECK_ISENTITY(params[arg_attacker]);
CAmxArgs args(amx, params);
ICSEntity *pInflictor = g_ReGameFuncs->INDEX_TO_CSENTITY(params[arg_inflictor]);
ICSEntity *pInflictor = args[arg_inflictor];
pInflictor->FireBullets
(
@ -297,7 +297,8 @@ cell AMX_NATIVE_CALL rg_fire_bullets3(AMX *amx, cell *params)
CHECK_ISENTITY(params[arg_attacker]);
CAmxArgs args(amx, params);
ICSEntity *pInflictor = g_ReGameFuncs->INDEX_TO_CSENTITY(params[arg_inflictor]);
ICSEntity *pInflictor = args[arg_inflictor];
entvars_t *pAttacker = args[arg_attacker];
args[arg_out].vector() = pInflictor->FireBullets3
(
@ -309,7 +310,7 @@ cell AMX_NATIVE_CALL rg_fire_bullets3(AMX *amx, cell *params)
args[arg_bullet_type],
args[arg_dmg],
args[arg_range_mod],
args[arg_attacker],
pAttacker,
args[arg_pistol],
args[arg_rand]
);