From 6550dd9e024fa44535f85240727b4e9527561951 Mon Sep 17 00:00:00 2001 From: Richard Helgeby Date: Sat, 1 Aug 2015 15:31:03 +0200 Subject: [PATCH] Remove unused legacy ZRTools code. --- src/zombiereloaded.sp | 17 +---- src/zr/antistick.inc | 31 +------- src/zr/damage.inc | 136 ++++++++++----------------------- src/zr/napalm.inc | 2 +- src/zr/weapons/restrict.inc | 66 +++++----------- src/zr/weapons/weaponalpha.inc | 31 +------- 6 files changed, 66 insertions(+), 217 deletions(-) diff --git a/src/zombiereloaded.sp b/src/zombiereloaded.sp index 8502a71..b6d29e5 100644 --- a/src/zombiereloaded.sp +++ b/src/zombiereloaded.sp @@ -25,9 +25,6 @@ * ============================================================================ */ -// Comment to use ZR Tools Extension, otherwise SDK Hooks Extension will be used. -#define USE_SDKHOOKS - #pragma semicolon 1 #include #include @@ -37,19 +34,7 @@ #include #undef INCLUDED_BY_ZOMBIERELOADED -#if defined USE_SDKHOOKS - #include - - #define ACTION_CONTINUE Plugin_Continue - #define ACTION_CHANGED Plugin_Changed - #define ACTION_HANDLED Plugin_Handled -#else - #include - - #define ACTION_CONTINUE ZRTools_Continue - #define ACTION_CHANGED ZRTools_Changed - #define ACTION_HANDLED ZRTools_Handled -#endif +#include #define VERSION "3.1" diff --git a/src/zr/antistick.inc b/src/zr/antistick.inc index 90ba4b8..c960fc2 100644 --- a/src/zr/antistick.inc +++ b/src/zr/antistick.inc @@ -59,11 +59,6 @@ */ #define ANTISTICK_DEFAULT_HULL_WIDTH 32.0 -/** - * Stores "StartTouch" HookID's for each client. - */ -new g_iStartTouchHookID[MAXPLAYERS + 1] = {-1, ...}; - /** * List of components that make up the model's rectangular boundaries. * @@ -100,15 +95,7 @@ AntiStickOnCommandsCreate() */ AntiStickClientInit(client) { - // Hook "StartTouch" and "EndTouch" on client. - #if defined USE_SDKHOOKS - SDKHook(client, SDKHook_StartTouch, AntiStickStartTouch); - - // Set dummy value so it think it's hooked. - g_iStartTouchHookID[client] = 1; - #else - g_iStartTouchHookID[client] = ZRTools_HookStartTouch(client, AntiStickStartTouch); - #endif + SDKHook(client, SDKHook_StartTouch, AntiStickStartTouch); } /** @@ -118,17 +105,7 @@ AntiStickClientInit(client) */ AntiStickOnClientDisconnect(client) { - // Unhook "StartTouch" callback, and reset variable. - if (g_iStartTouchHookID[client] != -1) - { - #if defined USE_SDKHOOKS - SDKUnhook(client, SDKHook_StartTouch, AntiStickStartTouch); - #else - ZRTools_UnhookStartTouch(g_iStartTouchHookID[client]); - #endif - - g_iStartTouchHookID[client] = -1; - } + SDKUnhook(client, SDKHook_StartTouch, AntiStickStartTouch); } /** @@ -137,11 +114,7 @@ AntiStickOnClientDisconnect(client) * @param client The client index. * @param entity The entity index of the entity being touched. */ -#if defined USE_SDKHOOKS public AntiStickStartTouch(client, entity) -#else -public ZRTools_Action:AntiStickStartTouch(client, entity) -#endif { // If antistick is disabled, then stop. new bool:antistick = GetConVarBool(g_hCvarsList[CVAR_ANTISTICK]); diff --git a/src/zr/damage.inc b/src/zr/damage.inc index dddba44..ae98d4c 100644 --- a/src/zr/damage.inc +++ b/src/zr/damage.inc @@ -25,19 +25,17 @@ * ============================================================================ */ -#if defined USE_SDKHOOKS - /** - * @section Counter Strike: Source specific damage flags. - */ - #define DMG_CSS_FALL (DMG_FALL) // Client was damaged by falling. - #define DMG_CSS_BLAST (DMG_BLAST) // Client was damaged by explosion. - #define DMG_CSS_BURN (DMG_DIRECT) // Client was damaged by fire. - #define DMG_CSS_BULLET (DMG_NEVERGIB) // Client was shot or knifed. - #define DMG_CSS_HEADSHOT (1 << 30) // Client was shot in the head. - /** - * @endsection - */ -#endif +/** + * @section Counter Strike: Source specific damage flags. + */ +#define DMG_CSS_FALL (DMG_FALL) // Client was damaged by falling. +#define DMG_CSS_BLAST (DMG_BLAST) // Client was damaged by explosion. +#define DMG_CSS_BURN (DMG_DIRECT) // Client was damaged by fire. +#define DMG_CSS_BULLET (DMG_NEVERGIB) // Client was shot or knifed. +#define DMG_CSS_HEADSHOT (1 << 30) // Client was shot in the head. +/** + * @endsection + */ /** * @section Suicide intercept defines. @@ -48,16 +46,6 @@ * @endsection */ -/** - * Array to store TraceAttack HookIDs. - */ -new g_iDamageTraceAttackHookID[MAXPLAYERS + 1] = {-1, ...}; - -/** - * Array to store OnTakeDamage HookIDs. - */ -new g_iDamageOnTakeDamageHookID[MAXPLAYERS + 1] = {-1, ...}; - /** * Array to keep track of normal/mother zombies. */ @@ -108,17 +96,8 @@ DamageLoad() DamageClientInit(client) { // Hook damage callbacks. - #if defined USE_SDKHOOKS - SDKHook(client, SDKHook_TraceAttack, DamageTraceAttack); - SDKHook(client, SDKHook_OnTakeDamage, DamageOnTakeDamage); - - // Set dummy values so it think it's hooked. - g_iDamageTraceAttackHookID[client] = 1; - g_iDamageOnTakeDamageHookID[client] = 1; - #else - g_iDamageTraceAttackHookID[client] = ZRTools_HookTraceAttack(client, DamageTraceAttack); - g_iDamageOnTakeDamageHookID[client] = ZRTools_HookOnTakeDamage(client, DamageOnTakeDamage); - #endif + SDKHook(client, SDKHook_TraceAttack, DamageTraceAttack); + SDKHook(client, SDKHook_OnTakeDamage, DamageOnTakeDamage); } /** @@ -128,29 +107,8 @@ DamageClientInit(client) */ DamageOnClientDisconnect(client) { - // Unhook damage callbacks, and reset variables. - - if (g_iDamageTraceAttackHookID[client] != -1) - { - #if defined USE_SDKHOOKS - SDKUnhook(client, SDKHook_TraceAttack, DamageTraceAttack); - #else - ZRTools_UnhookTraceAttack(g_iDamageTraceAttackHookID[client]); - #endif - - g_iDamageTraceAttackHookID[client] = -1; - } - - if (g_iDamageOnTakeDamageHookID[client] != -1) - { - #if defined USE_SDKHOOKS - SDKUnhook(client, SDKHook_OnTakeDamage, DamageOnTakeDamage); - #else - ZRTools_UnhookOnTakeDamage(g_iDamageOnTakeDamageHookID[client]); - #endif - - g_iDamageOnTakeDamageHookID[client] = -1; - } + SDKUnhook(client, SDKHook_TraceAttack, DamageTraceAttack); + SDKUnhook(client, SDKHook_OnTakeDamage, DamageOnTakeDamage); } /** @@ -178,22 +136,18 @@ DamageOnClientInfected(client, bool:motherinfect) * @return Return ZRTools_Handled to stop bullet from hitting client. * ZRTools_Continue to allow bullet to hit client. */ -#if defined USE_SDKHOOKS public Action:DamageTraceAttack(client, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup) -#else -public ZRTools_Action:DamageTraceAttack(client, inflictor, attacker, Float:damage, hitbox, hitgroup) -#endif { // If attacker isn't valid, then stop. if (!ZRIsClientValid(attacker)) { - return ACTION_CONTINUE; + return Plugin_Continue; } // If client is attacking himself, then stop. if(attacker == client) { - return ACTION_CONTINUE; + return Plugin_Continue; } // Get zombie flag for each client. @@ -207,11 +161,11 @@ public ZRTools_Action:DamageTraceAttack(client, inflictor, attacker, Float:damag new bool:damageblockff = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_BLOCK_FF]); if (!damageblockff) { - return ACTION_CONTINUE; + return Plugin_Continue; } // Stop bullet from hurting client. - return ACTION_HANDLED; + return Plugin_Handled; } // Here we know that attacker and client are different teams. @@ -220,14 +174,14 @@ public ZRTools_Action:DamageTraceAttack(client, inflictor, attacker, Float:damag if (ImmunityOnClientTraceAttack(client, attacker, damage, hitgroup, damagetype)) { // Block damage. - return ACTION_HANDLED; + return Plugin_Handled; } // If client is a human, then allow damage. if (InfectIsClientHuman(client)) { // Allow damage. - return ACTION_CONTINUE; + return Plugin_Continue; } // If damage hitgroups cvar is disabled, then allow damage. @@ -237,7 +191,7 @@ public ZRTools_Action:DamageTraceAttack(client, inflictor, attacker, Float:damag if (!damagehitgroups) { // Allow damage. - return ACTION_CONTINUE; + return Plugin_Continue; } // If damage is disabled for this hitgroup, then stop. @@ -247,18 +201,18 @@ public ZRTools_Action:DamageTraceAttack(client, inflictor, attacker, Float:damag if (index == -1) { // Allow damage. - return ACTION_CONTINUE; + return Plugin_Continue; } new bool:candamage = HitgroupsCanDamage(index); if (!candamage) { // Stop bullet from hurting client. - return ACTION_HANDLED; + return Plugin_Handled; } // Allow damage. - return ACTION_CONTINUE; + return Plugin_Continue; } /** @@ -274,11 +228,7 @@ public ZRTools_Action:DamageTraceAttack(client, inflictor, attacker, Float:damag * @return Return ZRTools_Handled to stop the damage to client. * ZRTools_Continue to allow damage to client. */ -#if defined USE_SDKHOOKS public Action:DamageOnTakeDamage(client, &attacker, &inflictor, &Float:damage, &damagetype) -#else -public ZRTools_Action:DamageOnTakeDamage(client, inflictor, attacker, Float:damage, damagetype, ammotype) -#endif { // Get classname of the inflictor. decl String:classname[64]; @@ -287,22 +237,18 @@ public ZRTools_Action:DamageOnTakeDamage(client, inflictor, attacker, Float:dama // If entity is a trigger, then allow damage. (Map is damaging client) if (StrContains(classname, "trigger") > -1) { - return ACTION_CONTINUE; + return Plugin_Continue; } - new action; + new Action:action; // Forward this hook to another module an return (or not) what it wants. - action = NapalmOnTakeDamage(client, damagetype); + action = Action:NapalmOnTakeDamage(client, damagetype); // If the napalm module wants to return here, then return the int casted into the action type. - if (action > -1) + if (action > Action:-1) { - #if defined USE_SDKHOOKS - return Action:action; - #else - return ZRTools_Action:action; - #endif + return action; } // Client was shot or knifed. @@ -311,7 +257,7 @@ public ZRTools_Action:DamageOnTakeDamage(client, inflictor, attacker, Float:dama // If attacker isn't valid, then allow damage. if (!ZRIsClientValid(attacker)) { - return ACTION_CONTINUE; + return Plugin_Continue; } // Get zombie flag for each client. @@ -321,7 +267,7 @@ public ZRTools_Action:DamageOnTakeDamage(client, inflictor, attacker, Float:dama // If client and attacker are on the same team, then let CS:S handle the rest. if (clientzombie == attackerzombie) { - return ACTION_CONTINUE; + return Plugin_Continue; } // We know that clientzombie is the opposite of attacker zombie. @@ -329,7 +275,7 @@ public ZRTools_Action:DamageOnTakeDamage(client, inflictor, attacker, Float:dama // If the client is a zombie, then allow damage. if (clientzombie) { - return ACTION_CONTINUE; + return Plugin_Continue; } // Check if immunity module blocked or modified the damage. @@ -367,7 +313,7 @@ public ZRTools_Action:DamageOnTakeDamage(client, inflictor, attacker, Float:dama SetEntityHealth(client, health + RoundToNearest(damage)); // Allow damage. - return ACTION_CONTINUE; + return Plugin_Continue; } } // Client was damaged by explosion. @@ -377,23 +323,23 @@ public ZRTools_Action:DamageOnTakeDamage(client, inflictor, attacker, Float:dama new bool:damageblockblast = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_BLOCK_BLAST]); if (!damageblockblast) { - return ACTION_CONTINUE; + return Plugin_Continue; } // If attacker isn't valid, then allow damage. if (!ZRIsClientValid(attacker)) { - return ACTION_CONTINUE; + return Plugin_Continue; } // If client is a zombie, then allow damage. if (InfectIsClientInfected(client)) { - return ACTION_CONTINUE; + return Plugin_Continue; } // Stop damage. - return ACTION_HANDLED; + return Plugin_Handled; } // Client was damaged by falling. else if (damagetype & DMG_CSS_FALL) @@ -402,15 +348,15 @@ public ZRTools_Action:DamageOnTakeDamage(client, inflictor, attacker, Float:dama new bool:blockfalldamage = ClassGetNoFallDamage(client); if (!blockfalldamage) { - return ACTION_CONTINUE; + return Plugin_Continue; } // Stop damage. - return ACTION_HANDLED; + return Plugin_Handled; } // Allow damage. - return ACTION_CONTINUE; + return Plugin_Continue; } /** diff --git a/src/zr/napalm.inc b/src/zr/napalm.inc index a2aeb14..e7b8b6e 100644 --- a/src/zr/napalm.inc +++ b/src/zr/napalm.inc @@ -104,7 +104,7 @@ NapalmOnTakeDamage(client, damagetype) } } - return _:ACTION_CONTINUE; + return _:Plugin_Continue; } } } diff --git a/src/zr/weapons/restrict.inc b/src/zr/weapons/restrict.inc index bb5fb0f..72e7b4f 100644 --- a/src/zr/weapons/restrict.inc +++ b/src/zr/weapons/restrict.inc @@ -38,11 +38,6 @@ enum RestrictData RESTRICT_DATA_NAME = 0, } -/** - * Array that stores the "HookID" to be later unhooked on player disconnect. - */ -new g_iCanUseHookID[MAXPLAYERS + 1] = {-1, ...}; - /** * Array to block any client from picking up weapons. */ @@ -137,17 +132,7 @@ RestrictOnCommandsCreate() */ RestrictClientInit(client) { - // Hook "Weapon_CanUse" on client. - #if defined USE_SDKHOOKS - SDKHook(client, SDKHook_WeaponCanUse, RestrictCanUse); - - // Set dummy value so it think it's hooked. - g_iCanUseHookID[client] = 1; - #else - g_iCanUseHookID[client] = ZRTools_HookWeapon_CanUse(client, RestrictCanUse); - #endif - - // Reset block weapons flag. + SDKHook(client, SDKHook_WeaponCanUse, RestrictCanUse); g_bRestrictBlockWeapon[client] = false; } @@ -158,17 +143,7 @@ RestrictClientInit(client) */ RestrictOnClientDisconnect(client) { - // Unhook "Weapon_CanUse" callback, and reset variable. - if (g_iCanUseHookID[client] != -1) - { - #if defined USE_SDKHOOKS - SDKUnhook(client, SDKHook_WeaponCanUse, RestrictCanUse); - #else - ZRTools_UnhookWeapon_CanUse(g_iCanUseHookID[client]); - #endif - - g_iCanUseHookID[client] = -1; - } + SDKUnhook(client, SDKHook_WeaponCanUse, RestrictCanUse); } /** @@ -179,17 +154,15 @@ RestrictOnClientDisconnect(client) RestrictOnClientSpawn(client) { // Re-hook "canuse" on client. - #if defined USE_SDKHOOKS - SDKUnhook(client, SDKHook_WeaponCanUse, RestrictCanUse); // <--- What happens if it's not already hooked??? - SDKHook(client, SDKHook_WeaponCanUse, RestrictCanUse); - g_iCanUseHookID[client] = 1; - #else - ZRTools_UnhookWeapon_CanUse(g_iCanUseHookID[client]); - g_iCanUseHookID[client] = ZRTools_HookWeapon_CanUse(client, RestrictCanUse); - #endif + SDKUnhook(client, SDKHook_WeaponCanUse, RestrictCanUse); + SDKHook(client, SDKHook_WeaponCanUse, RestrictCanUse); // H4x. Unfortunately I can't disable this flag early enough for CS:S to give start USP/Glock. // So I have to give BOOTLEG weapons. (Sorry Valve) + + // CS:GO TODO: Move this into separate functions for CS:S and CS:GO. And + // call the correct function. + if (g_bRestrictBlockWeapon[client]) { // Reset block weapons flag. @@ -613,45 +586,44 @@ stock bool:RestrictIsTypeUniform(bool:restricted, index) * @return Return ZRTools_Handled to stop weapon pickup. * ZRTools_Continue to allow weapon pickup. */ -#if defined USE_SDKHOOKS public Action:RestrictCanUse(client, weapon) -#else -public ZRTools_Action:RestrictCanUse(client, weapon) -#endif { + // WARNING: This function is called _frequently_. Every game tick per + // player, I think. Make sure any code here is optimized. + new String:weaponentity[WEAPONS_MAX_LENGTH]; GetEdictClassname(weapon, weaponentity, sizeof(weaponentity)); // If weapon is a knife, then allow pickup. if (StrEqual(weaponentity, "weapon_knife")) { - return ACTION_CONTINUE; + return Plugin_Continue; } // If the player is a zombie, then prevent pickup. if (InfectIsClientInfected(client)) { - return ACTION_HANDLED; + return Plugin_Handled; } // If client is flagged for not picking up weapons, then stop. if (g_bRestrictBlockWeapon[client]) { - return ACTION_HANDLED; + return Plugin_Handled; } // If weapons module is disabled, then stop. new bool:weapons = GetConVarBool(g_hCvarsList[CVAR_WEAPONS]); if (!weapons) { - return ACTION_CONTINUE; + return Plugin_Continue; } // If restrict module is disabled, then stop. new bool:restrict = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_RESTRICT]); if (!restrict) { - return ACTION_CONTINUE; + return Plugin_Continue; } // If the weapon is restricted, then prevent pickup. @@ -662,20 +634,20 @@ public ZRTools_Action:RestrictCanUse(client, weapon) if (weaponindex == -1) { // Allow pickup. - return ACTION_CONTINUE; + return Plugin_Continue; } // If weapon is restricted, then stop. if (RestrictIsWeaponRestricted(weaponindex)) { - return ACTION_HANDLED; + return Plugin_Handled; } // Forward event to weapons module. WeaponsOnItemPickup(client, weapon); // Allow pickup. - return ACTION_CONTINUE; + return Plugin_Continue; } /** diff --git a/src/zr/weapons/weaponalpha.inc b/src/zr/weapons/weaponalpha.inc index 7750769..121a6b0 100644 --- a/src/zr/weapons/weaponalpha.inc +++ b/src/zr/weapons/weaponalpha.inc @@ -30,11 +30,6 @@ */ #define WEAPONALPHA_DEFAULT_VALUE 255 -/** - * Array that stores the "HookID" to be later unhooked on player disconnect. - */ -new g_iWeaponDropHookID[MAXPLAYERS + 1] = {-1, ...}; - /** * Client is joining the server. * @@ -43,15 +38,7 @@ new g_iWeaponDropHookID[MAXPLAYERS + 1] = {-1, ...}; WeaponAlphaClientInit(client) { return; - // Hook "Weapon_Drop" on client. - #if defined USE_SDKHOOKS - SDKHook(client, SDKHook_WeaponDrop, WeaponAlphaDrop); - - // Set dummy value so it think it's hooked. - g_iWeaponDropHookID[client] = 1; - #else - g_iWeaponDropHookID[client] = ZRTools_HookWeapon_Drop(client, WeaponAlphaDrop); - #endif + SDKHook(client, SDKHook_WeaponDrop, WeaponAlphaDrop); } /** @@ -62,17 +49,7 @@ WeaponAlphaClientInit(client) WeaponAlphaOnClientDisconnect(client) { return; - // Unhook "Weapon_Drop" callback, and reset variable. - if (g_iWeaponDropHookID[client] != -1) - { - #if defined USE_SDKHOOKS - SDKUnhook(client, SDKHook_WeaponDrop, WeaponAlphaDrop); - #else - ZRTools_UnhookWeapon_Drop(g_iWeaponDropHookID[client]); - #endif - - g_iWeaponDropHookID[client] = -1; - } + SDKUnhook(client, SDKHook_WeaponDrop, WeaponAlphaDrop); } /** @@ -108,11 +85,7 @@ WeaponAlphaOnItemPickupPost(client, weapon) * @param client The client index. * @param weapon The weapon index. */ -#if defined USE_SDKHOOKS public Action:WeaponAlphaDrop(client, weapon) -#else -public ZRTools_Action:WeaponAlphaDrop(client, weapon) -#endif { return; // If weapon isn't a valid entity, then stop.