diff --git a/publish.gradle b/publish.gradle index 0ca227e..ee206ff 100644 --- a/publish.gradle +++ b/publish.gradle @@ -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 { diff --git a/reapi/src/natives/natives_helper.h b/reapi/src/natives/natives_helper.h index 173f114..82ce7d4 100644 --- a/reapi/src/natives/natives_helper.h +++ b/reapi/src/natives/natives_helper.h @@ -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(m_value); } + operator ICSEntity*() const + { + return g_ReGameFuncs->INDEX_TO_CSENTITY(m_value); + } Vector& vector() const { diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index e8146f5..1b14acf 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -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] );