From bb3796567033a8c4ad043b13eb72c7367b2b218f Mon Sep 17 00:00:00 2001 From: zaCade Date: Sat, 28 Sep 2019 13:19:56 +0200 Subject: [PATCH] Cleanup duplicated code, and a big wtf? offsActiveWeapon was never declared, guess we never found out because the functions where unused. WeaponsGetActiveWeaponSlot is still unused, leaving in might be usefull somewhen in the future. --- src/zr/knockback.inc | 7 +++---- src/zr/tools.inc | 8 -------- src/zr/tools_functions.inc | 10 ---------- src/zr/weapons/weapons.inc | 31 ++++++++++++++++++------------- src/zr/weapons/zmarket.inc | 5 ----- 5 files changed, 21 insertions(+), 40 deletions(-) diff --git a/src/zr/knockback.inc b/src/zr/knockback.inc index 7ffeea0..c75c3b5 100644 --- a/src/zr/knockback.inc +++ b/src/zr/knockback.inc @@ -160,12 +160,11 @@ public void KnockbackOnTakeDamageAlivePost(int victim, int attacker, int inflict GetClientAbsOrigin(victim, clientloc); char weaponname[64]; - int active_weapon = -42; if (inflictor == attacker) { - active_weapon = ToolsGetClientActiveWeapon(attacker); - if (active_weapon > 0) - GetEdictClassname(active_weapon, weaponname, sizeof(weaponname)); + int activeweapon = WeaponsGetActiveWeaponIndex(attacker); + if (activeweapon > 0) + GetEdictClassname(activeweapon, weaponname, sizeof(weaponname)); } else GetEdictClassname(inflictor, weaponname, sizeof(weaponname)); diff --git a/src/zr/tools.inc b/src/zr/tools.inc index a5ff38f..242bba1 100644 --- a/src/zr/tools.inc +++ b/src/zr/tools.inc @@ -33,7 +33,6 @@ new g_iToolsLMV; new g_iToolsHasNightVision; new g_iToolsNightVisionOn; new g_iToolsFOV; -new g_iActiveWeapon; new g_iToolsLastHitGroup; /** @@ -92,13 +91,6 @@ ToolsFindOffsets() LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Offset \"CBasePlayer::m_iFOV\" was not found."); } - // If offset "m_hActiveWeapon" can't be found, then stop the plugin. - g_iActiveWeapon = FindSendPropInfo("CBaseCombatCharacter", "m_hActiveWeapon"); - if (g_iActiveWeapon == -1) - { - LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Offset \"CBaseCombatCharacter::m_hActiveWeapon\" was not found."); - } - Handle hGameConf = LoadGameConfigFile("zombiereloaded"); if (hGameConf != INVALID_HANDLE) { diff --git a/src/zr/tools_functions.inc b/src/zr/tools_functions.inc index 634f178..3d4db7a 100644 --- a/src/zr/tools_functions.inc +++ b/src/zr/tools_functions.inc @@ -251,16 +251,6 @@ stock ToolsGetEntityColor(entity, color[4]) color[i] = GetEntData(entity, offset + i, 1); } -/** - * Get client's m_hActiveWeapon. - * - * @param client The client index. - */ -stock int ToolsGetClientActiveWeapon(int client) -{ - return GetEntDataEnt2(client, g_iActiveWeapon); -} - /** * Get client's m_LastHitGroup. * diff --git a/src/zr/weapons/weapons.inc b/src/zr/weapons/weapons.inc index e397e30..fb9eabf 100644 --- a/src/zr/weapons/weapons.inc +++ b/src/zr/weapons/weapons.inc @@ -76,6 +76,11 @@ enum WeaponsData */ new g_iToolsActiveWeapon; +/** + * Variable to store buyzone offset value. + */ +new g_iToolsInBuyZone; + /** * Weapon slots. */ @@ -749,35 +754,35 @@ stock WeaponsGetClientWeapons(client, weapons[WeaponsSlot]) } /** - * Returns weapon index of the client's deployed weapon. + * Returns weapon index of the client's active weapon. * * @param client The client index. - * @return The weapon index of the deployed weapon. - * -1 if no weapon is deployed. + * @return The weapon index of the active weapon. + * -1 if no weapon is active. */ -stock WeaponsGetDeployedWeaponIndex(client) +stock WeaponsGetActiveWeaponIndex(client) { // Return the client's active weapon. - return GetEntDataEnt2(client, offsActiveWeapon); + return GetEntDataEnt2(client, g_iToolsActiveWeapon); } /** - * Returns slot of client's deployed weapon. + * Returns slot of client's active weapon. * * @param client The client index. - * @return The slot number of deployed weapon. + * @return The slot number of active weapon. */ -stock WeaponsSlot:WeaponsGetDeployedWeaponSlot(client) +stock WeaponsSlot:WeaponsGetActiveWeaponSlot(client) { // Get all client's weapon indexes. new weapons[WeaponsSlot]; WeaponsGetClientWeapons(client, weapons); - // Get client's deployed weapon. - new deployedweapon = WeaponsGetDeployedWeaponIndex(client); + // Get client's active weapon. + new activeweapon = WeaponsGetActiveWeaponIndex(client); - // If client has no deployed weapon, then stop. - if (deployedweapon == -1) + // If client has no active weapon, then stop. + if (activeweapon == -1) { return Type_Invalid; } @@ -785,7 +790,7 @@ stock WeaponsSlot:WeaponsGetDeployedWeaponSlot(client) // x = weapon slot. for (new x = 0; x < WEAPONS_SLOTS_MAX; x++) { - if (weapons[x] == deployedweapon) + if (weapons[x] == activeweapon) { return WeaponsSlot:x; } diff --git a/src/zr/weapons/zmarket.inc b/src/zr/weapons/zmarket.inc index b9be6ed..2601449 100644 --- a/src/zr/weapons/zmarket.inc +++ b/src/zr/weapons/zmarket.inc @@ -39,11 +39,6 @@ */ #define ZMARKET_REBUY_WEAPONS_SLOTS_MAX 1 -/** - * Variable to store buyzone offset value. - */ -new g_iToolsInBuyZone; - /** * Array to store the client's current weapon type within menu. */