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() //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.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') _copyFile('publish/libreapi_amxx_i386.so', 'publish/publishRoot/reapi/addons/amxmodx/modules/reapi_amxx_i386.so')
copy { copy {

View File

@ -7,7 +7,7 @@ class CAmxArg
{ {
public: public:
CAmxArg(AMX* amx, cell value) : m_amx(amx), m_value(value) {} CAmxArg(AMX* amx, cell value) : m_amx(amx), m_value(value) {}
operator float() const operator float&() const
{ {
return *(float *)m_value; return *(float *)m_value;
} }
@ -17,9 +17,8 @@ public:
} }
operator entvars_s*() const operator entvars_s*() const
{ {
if (m_value < 0) auto pev = PEV(m_value);
return nullptr; return m_value < 0 ? nullptr : pev;
return PEV(m_value);
} }
operator int() const operator int() const
{ {
@ -35,12 +34,17 @@ public:
} }
operator CBaseEntity*() const 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 operator PLAYER_ANIM() const
{ {
return static_cast<PLAYER_ANIM>(m_value); return static_cast<PLAYER_ANIM>(m_value);
} }
operator ICSEntity*() const
{
return g_ReGameFuncs->INDEX_TO_CSENTITY(m_value);
}
Vector& vector() const 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_inflictor]);
CHECK_ISENTITY(params[arg_victim]); CHECK_ISENTITY(params[arg_victim]);
CAmxArgs args(amx, params);
if (params[arg_victim] < 0) { // null if (params[arg_victim] < 0) { // null
MF_LogError(amx, AMX_ERR_NATIVE, "rg_multidmg_add: victim == null"); MF_LogError(amx, AMX_ERR_NATIVE, "rg_multidmg_add: victim == null");
return FALSE; return FALSE;
} }
CAmxArgs args(amx, params);
g_ReGameFuncs->AddMultiDamage(args[arg_inflictor], args[arg_victim], args[arg_damage], args[arg_dmg_type]); g_ReGameFuncs->AddMultiDamage(args[arg_inflictor], args[arg_victim], args[arg_damage], args[arg_dmg_type]);
return TRUE; return TRUE;
} }
@ -251,7 +251,7 @@ cell AMX_NATIVE_CALL rg_fire_bullets(AMX *amx, cell *params)
CHECK_ISENTITY(params[arg_attacker]); CHECK_ISENTITY(params[arg_attacker]);
CAmxArgs args(amx, params); CAmxArgs args(amx, params);
ICSEntity *pInflictor = g_ReGameFuncs->INDEX_TO_CSENTITY(params[arg_inflictor]); ICSEntity *pInflictor = args[arg_inflictor];
pInflictor->FireBullets pInflictor->FireBullets
( (
@ -297,7 +297,8 @@ cell AMX_NATIVE_CALL rg_fire_bullets3(AMX *amx, cell *params)
CHECK_ISENTITY(params[arg_attacker]); CHECK_ISENTITY(params[arg_attacker]);
CAmxArgs args(amx, params); 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 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_bullet_type],
args[arg_dmg], args[arg_dmg],
args[arg_range_mod], args[arg_range_mod],
args[arg_attacker], pAttacker,
args[arg_pistol], args[arg_pistol],
args[arg_rand] args[arg_rand]
); );