From 151b255994c7c39f2d21561f08c03e4bf5eaabe9 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Thu, 23 Jul 2009 15:05:14 -0700 Subject: [PATCH] Updated antistick, small performance gain. Modified any multi-valued cvars to accept "1,2" instead of only "1, 2" and made a cosmetic change to get array sizes. --- src/zr/antistick.inc | 54 +++++++++++-------------- src/zr/damage.inc | 5 ++- src/zr/models.inc | 2 +- src/zr/playerclasses/clientoverlays.inc | 5 ++- src/zr/weapons/restrict.inc | 4 +- 5 files changed, 34 insertions(+), 36 deletions(-) diff --git a/src/zr/antistick.inc b/src/zr/antistick.inc index 4b8a516..7963972 100644 --- a/src/zr/antistick.inc +++ b/src/zr/antistick.inc @@ -28,28 +28,28 @@ /** * @section Collision values. */ -#define ANTISTICK_COLLISIONS_OFF 2 -#define ANTISTICK_COLLISIONS_ON 5 - -#define COLLISION_GROUP_NONE 0 /** Default; collides with static and dynamic objects. */ -#define COLLISION_GROUP_DEBRIS 1 /** Collides with nothing but world and static stuff. */ -#define COLLISION_GROUP_DEBRIS_TRIGGER 2 /** Same as debris, but hits triggers. */ -#define COLLISION_GROUP_INTERACTIVE_DEBRIS 3 /** Collides with everything except other interactive debris or debris. */ -#define COLLISION_GROUP_INTERACTIVE 4 /** Collides with everything except interactive debris or debris. */ -#define COLLISION_GROUP_PLAYER 5 /** This is the default behavior expected for most prop_physics. */ -#define COLLISION_GROUP_BREAKABLE_GLASS 6 /** Special group for glass debris. */ -#define COLLISION_GROUP_VEHICLE 7 /** Collision group for driveable vehicles. */ -#define COLLISION_GROUP_PLAYER_MOVEMENT 8 /** For HL2, same as Collision_Group_Player. */ -#define COLLISION_GROUP_NPC 9 /** Generic NPC group. */ -#define COLLISION_GROUP_IN_VEHICLE 10 /** For any entity inside a vehicle. */ -#define COLLISION_GROUP_WEAPON 11 /** For any weapons that need collision detection. */ -#define COLLISION_GROUP_VEHICLE_CLIP 12 /** Vehicle clip brush to restrict vehicle movement. */ -#define COLLISION_GROUP_PROJECTILE 13 /** Projectiles. */ -#define COLLISION_GROUP_DOOR_BLOCKER 14 /** Blocks entities not permitted to get near moving doors. */ -#define COLLISION_GROUP_PASSABLE_DOOR 15 /** Doors that the player shouldn't collide with. */ -#define COLLISION_GROUP_DISSOLVING 16 /** Things that are dissolving are in this group. */ -#define COLLISION_GROUP_PUSHAWAY 17 /** Nonsolid on client and server, pushaway in player code. */ +#define COLLISION_GROUP_NONE 0 /** Default; collides with static and dynamic objects. */ +#define COLLISION_GROUP_DEBRIS 1 /** Collides with nothing but world and static stuff. */ +#define COLLISION_GROUP_DEBRIS_TRIGGER 2 /** Same as debris, but hits triggers. */ +#define COLLISION_GROUP_INTERACTIVE_DEBRIS 3 /** Collides with everything except other interactive debris or debris. */ +#define COLLISION_GROUP_INTERACTIVE 4 /** Collides with everything except interactive debris or debris. */ +#define COLLISION_GROUP_PLAYER 5 /** This is the default behavior expected for most prop_physics. */ +#define COLLISION_GROUP_BREAKABLE_GLASS 6 /** Special group for glass debris. */ +#define COLLISION_GROUP_VEHICLE 7 /** Collision group for driveable vehicles. */ +#define COLLISION_GROUP_PLAYER_MOVEMENT 8 /** For HL2, same as Collision_Group_Player. */ +#define COLLISION_GROUP_NPC 9 /** Generic NPC group. */ +#define COLLISION_GROUP_IN_VEHICLE 10 /** For any entity inside a vehicle. */ +#define COLLISION_GROUP_WEAPON 11 /** For any weapons that need collision detection. */ +#define COLLISION_GROUP_VEHICLE_CLIP 12 /** Vehicle clip brush to restrict vehicle movement. */ +#define COLLISION_GROUP_PROJECTILE 13 /** Projectiles. */ +#define COLLISION_GROUP_DOOR_BLOCKER 14 /** Blocks entities not permitted to get near moving doors. */ +#define COLLISION_GROUP_PASSABLE_DOOR 15 /** Doors that the player shouldn't collide with. */ +#define COLLISION_GROUP_DISSOLVING 16 /** Things that are dissolving are in this group. */ +#define COLLISION_GROUP_PUSHAWAY 17 /** Nonsolid on client and server, pushaway in player code. */ #define COLLISION_GROUP_NPC_ACTOR 18 /** Used so NPCs in scripts ignore the player. */ + +#define ANTISTICK_COLLISIONS_OFF COLLISION_GROUP_DEBRIS_TRIGGER +#define ANTISTICK_COLLISIONS_ON COLLISION_GROUP_PLAYER /** * @endsection */ @@ -306,26 +306,18 @@ public ZRTools_Action:AntiStickStartTouch(client, entity) // Get current collision groups of client and entity. new clientcollisiongroup = AntiStickGetCollisionGroup(client); - new entitycollisiongroup = AntiStickGetCollisionGroup(entity); // Note: If zombies get stuck on infection or stuck in a teleport, they'll // get the COLLISION_GROUP_PUSHAWAY collision group, so check this // one too. - // Check if the client have collisions enabled, or have the pushaway collision group. - if (clientcollisiongroup == ANTISTICK_COLLISIONS_ON || clientcollisiongroup == COLLISION_GROUP_PUSHAWAY) + // If the client is in any other collision group than "off", than we must set them to off, to unstick. + if (clientcollisiongroup != ANTISTICK_COLLISIONS_OFF) { // Disable collisions to unstick, and start timers to re-solidify. AntiStickSetCollisionGroup(client, ANTISTICK_COLLISIONS_OFF); CreateTimer(0.0, AntiStickSolidifyTimer, client, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT); } - - // Check if the entity have collisions enabled, or have the pushaway collision group. - if (entitycollisiongroup == ANTISTICK_COLLISIONS_ON || entitycollisiongroup == COLLISION_GROUP_PUSHAWAY) - { - AntiStickSetCollisionGroup(entity, ANTISTICK_COLLISIONS_OFF); - CreateTimer(0.0, AntiStickSolidifyTimer, entity, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT); - } } /** diff --git a/src/zr/damage.inc b/src/zr/damage.inc index e69a5df..008a218 100644 --- a/src/zr/damage.inc +++ b/src/zr/damage.inc @@ -66,12 +66,15 @@ DamageOnCommandsHook() new String:arrayCmds[DAMAGE_SUICIDE_MAX_CMDS][DAMAGE_SUICIDE_MAX_LENGTH]; // Explode string into array indexes. - new cmdcount = ExplodeString(suicidecmds, ", ", arrayCmds, DAMAGE_SUICIDE_MAX_CMDS, DAMAGE_SUICIDE_MAX_LENGTH); + new cmdcount = ExplodeString(suicidecmds, ",", arrayCmds, sizeof(arrayCmds), sizeof(arrayCmds[])); // x = Array index. // arrayCmds[x] = suicide command. for (new x = 0; x <= cmdcount - 1; x++) { + // Trim whitespace. + TrimString(arrayCmds[x]); + // Prepare intercept for this command. RegConsoleCmd(arrayCmds[x], DamageSuicideIntercept); } diff --git a/src/zr/models.inc b/src/zr/models.inc index 44389f4..1386157 100644 --- a/src/zr/models.inc +++ b/src/zr/models.inc @@ -96,7 +96,7 @@ ModelsLoad() ModelReturnPath(x, modelbase, sizeof(modelbase)); // Explode path into pieces. (separated by "/") - new strings = ExplodeString(modelbase, "/", baseexploded, MODELS_PATH_MAX_DEPTH, MODELS_PATH_DIR_MAX_LENGTH); + new strings = ExplodeString(modelbase, "/", baseexploded, sizeof(baseexploded), sizeof(baseexploded[])); // Get model file name. strcopy(modelname, sizeof(modelname), baseexploded[strings - 1]); diff --git a/src/zr/playerclasses/clientoverlays.inc b/src/zr/playerclasses/clientoverlays.inc index b34baec..687eaed 100644 --- a/src/zr/playerclasses/clientoverlays.inc +++ b/src/zr/playerclasses/clientoverlays.inc @@ -57,12 +57,15 @@ ClassOverlayOnCommandsHook() new String:arrayCmds[CLASSOVERLAY_TOGGLE_MAX_CMDS][CLASSOVERLAY_TOGGLE_MAX_LENGTH]; // Explode string into array indexes. - new cmdcount = ExplodeString(togglecmds, ", ", arrayCmds, CLASSOVERLAY_TOGGLE_MAX_CMDS, CLASSOVERLAY_TOGGLE_MAX_LENGTH); + new cmdcount = ExplodeString(togglecmds, ",", arrayCmds, sizeof(arrayCmds), sizeof(arrayCmds[])); // x = Array index. // arrayCmds[x] = suicide command. for (new x = 0; x <= cmdcount - 1; x++) { + // Trim whitespace. + TrimString(arrayCmds[x]); + // Prepare intercept for this command. RegConsoleCmd(arrayCmds[x], ClassOverlayEnableCommand); } diff --git a/src/zr/weapons/restrict.inc b/src/zr/weapons/restrict.inc index d4196f8..60146e1 100644 --- a/src/zr/weapons/restrict.inc +++ b/src/zr/weapons/restrict.inc @@ -98,7 +98,7 @@ RestrictLoad() { WeaponsGetType(x, weapontype, sizeof(weapontype)); - ExplodeString(weapontype, ",", weapontypes, WEAPONS_RESTRICT_MAX_TYPES, WEAPONS_MAX_LENGTH); + ExplodeString(weapontype, ",", weapontypes, sizeof(weapontypes), sizeof(weapontypes[])); for (new y = 0; y < WEAPONS_RESTRICT_MAX_TYPES; y++) { // Cut off whitespace. @@ -498,7 +498,7 @@ stock RestrictGetTypeWeapons(index, &Handle:arrayTypeWeapons) { WeaponsGetType(x, weapontype, sizeof(weapontype)); - ExplodeString(weapontype, ",", weapontypes, WEAPONS_RESTRICT_MAX_TYPES, WEAPONS_MAX_LENGTH); + ExplodeString(weapontype, ",", weapontypes, sizeof(weapontypes), sizeof(weapontypes[])); for (new y = 0; y < WEAPONS_RESTRICT_MAX_TYPES; y++) { // Cut off whitespace.