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.
This commit is contained in:
Greyscale 2009-07-23 15:05:14 -07:00
parent ac2fed1451
commit 151b255994
5 changed files with 34 additions and 36 deletions

View File

@ -28,28 +28,28 @@
/** /**
* @section Collision values. * @section Collision values.
*/ */
#define ANTISTICK_COLLISIONS_OFF 2 #define COLLISION_GROUP_NONE 0 /** Default; collides with static and dynamic objects. */
#define ANTISTICK_COLLISIONS_ON 5 #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_NONE 0 /** Default; collides with static and dynamic objects. */ #define COLLISION_GROUP_INTERACTIVE_DEBRIS 3 /** Collides with everything except other interactive debris or debris. */
#define COLLISION_GROUP_DEBRIS 1 /** Collides with nothing but world and static stuff. */ #define COLLISION_GROUP_INTERACTIVE 4 /** Collides with everything except interactive debris or debris. */
#define COLLISION_GROUP_DEBRIS_TRIGGER 2 /** Same as debris, but hits triggers. */ #define COLLISION_GROUP_PLAYER 5 /** This is the default behavior expected for most prop_physics. */
#define COLLISION_GROUP_INTERACTIVE_DEBRIS 3 /** Collides with everything except other interactive debris or debris. */ #define COLLISION_GROUP_BREAKABLE_GLASS 6 /** Special group for glass debris. */
#define COLLISION_GROUP_INTERACTIVE 4 /** Collides with everything except interactive debris or debris. */ #define COLLISION_GROUP_VEHICLE 7 /** Collision group for driveable vehicles. */
#define COLLISION_GROUP_PLAYER 5 /** This is the default behavior expected for most prop_physics. */ #define COLLISION_GROUP_PLAYER_MOVEMENT 8 /** For HL2, same as Collision_Group_Player. */
#define COLLISION_GROUP_BREAKABLE_GLASS 6 /** Special group for glass debris. */ #define COLLISION_GROUP_NPC 9 /** Generic NPC group. */
#define COLLISION_GROUP_VEHICLE 7 /** Collision group for driveable vehicles. */ #define COLLISION_GROUP_IN_VEHICLE 10 /** For any entity inside a vehicle. */
#define COLLISION_GROUP_PLAYER_MOVEMENT 8 /** For HL2, same as Collision_Group_Player. */ #define COLLISION_GROUP_WEAPON 11 /** For any weapons that need collision detection. */
#define COLLISION_GROUP_NPC 9 /** Generic NPC group. */ #define COLLISION_GROUP_VEHICLE_CLIP 12 /** Vehicle clip brush to restrict vehicle movement. */
#define COLLISION_GROUP_IN_VEHICLE 10 /** For any entity inside a vehicle. */ #define COLLISION_GROUP_PROJECTILE 13 /** Projectiles. */
#define COLLISION_GROUP_WEAPON 11 /** For any weapons that need collision detection. */ #define COLLISION_GROUP_DOOR_BLOCKER 14 /** Blocks entities not permitted to get near moving doors. */
#define COLLISION_GROUP_VEHICLE_CLIP 12 /** Vehicle clip brush to restrict vehicle movement. */ #define COLLISION_GROUP_PASSABLE_DOOR 15 /** Doors that the player shouldn't collide with. */
#define COLLISION_GROUP_PROJECTILE 13 /** Projectiles. */ #define COLLISION_GROUP_DISSOLVING 16 /** Things that are dissolving are in this group. */
#define COLLISION_GROUP_DOOR_BLOCKER 14 /** Blocks entities not permitted to get near moving doors. */ #define COLLISION_GROUP_PUSHAWAY 17 /** Nonsolid on client and server, pushaway in player code. */
#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 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 * @endsection
*/ */
@ -306,26 +306,18 @@ public ZRTools_Action:AntiStickStartTouch(client, entity)
// Get current collision groups of client and entity. // Get current collision groups of client and entity.
new clientcollisiongroup = AntiStickGetCollisionGroup(client); new clientcollisiongroup = AntiStickGetCollisionGroup(client);
new entitycollisiongroup = AntiStickGetCollisionGroup(entity);
// Note: If zombies get stuck on infection or stuck in a teleport, they'll // Note: If zombies get stuck on infection or stuck in a teleport, they'll
// get the COLLISION_GROUP_PUSHAWAY collision group, so check this // get the COLLISION_GROUP_PUSHAWAY collision group, so check this
// one too. // one too.
// Check if the client have collisions enabled, or have the pushaway collision group. // If the client is in any other collision group than "off", than we must set them to off, to unstick.
if (clientcollisiongroup == ANTISTICK_COLLISIONS_ON || clientcollisiongroup == COLLISION_GROUP_PUSHAWAY) if (clientcollisiongroup != ANTISTICK_COLLISIONS_OFF)
{ {
// Disable collisions to unstick, and start timers to re-solidify. // Disable collisions to unstick, and start timers to re-solidify.
AntiStickSetCollisionGroup(client, ANTISTICK_COLLISIONS_OFF); AntiStickSetCollisionGroup(client, ANTISTICK_COLLISIONS_OFF);
CreateTimer(0.0, AntiStickSolidifyTimer, client, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT); 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);
}
} }
/** /**

View File

@ -66,12 +66,15 @@ DamageOnCommandsHook()
new String:arrayCmds[DAMAGE_SUICIDE_MAX_CMDS][DAMAGE_SUICIDE_MAX_LENGTH]; new String:arrayCmds[DAMAGE_SUICIDE_MAX_CMDS][DAMAGE_SUICIDE_MAX_LENGTH];
// Explode string into array indexes. // 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. // x = Array index.
// arrayCmds[x] = suicide command. // arrayCmds[x] = suicide command.
for (new x = 0; x <= cmdcount - 1; x++) for (new x = 0; x <= cmdcount - 1; x++)
{ {
// Trim whitespace.
TrimString(arrayCmds[x]);
// Prepare intercept for this command. // Prepare intercept for this command.
RegConsoleCmd(arrayCmds[x], DamageSuicideIntercept); RegConsoleCmd(arrayCmds[x], DamageSuicideIntercept);
} }

View File

@ -96,7 +96,7 @@ ModelsLoad()
ModelReturnPath(x, modelbase, sizeof(modelbase)); ModelReturnPath(x, modelbase, sizeof(modelbase));
// Explode path into pieces. (separated by "/") // 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. // Get model file name.
strcopy(modelname, sizeof(modelname), baseexploded[strings - 1]); strcopy(modelname, sizeof(modelname), baseexploded[strings - 1]);

View File

@ -57,12 +57,15 @@ ClassOverlayOnCommandsHook()
new String:arrayCmds[CLASSOVERLAY_TOGGLE_MAX_CMDS][CLASSOVERLAY_TOGGLE_MAX_LENGTH]; new String:arrayCmds[CLASSOVERLAY_TOGGLE_MAX_CMDS][CLASSOVERLAY_TOGGLE_MAX_LENGTH];
// Explode string into array indexes. // 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. // x = Array index.
// arrayCmds[x] = suicide command. // arrayCmds[x] = suicide command.
for (new x = 0; x <= cmdcount - 1; x++) for (new x = 0; x <= cmdcount - 1; x++)
{ {
// Trim whitespace.
TrimString(arrayCmds[x]);
// Prepare intercept for this command. // Prepare intercept for this command.
RegConsoleCmd(arrayCmds[x], ClassOverlayEnableCommand); RegConsoleCmd(arrayCmds[x], ClassOverlayEnableCommand);
} }

View File

@ -98,7 +98,7 @@ RestrictLoad()
{ {
WeaponsGetType(x, weapontype, sizeof(weapontype)); 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++) for (new y = 0; y < WEAPONS_RESTRICT_MAX_TYPES; y++)
{ {
// Cut off whitespace. // Cut off whitespace.
@ -498,7 +498,7 @@ stock RestrictGetTypeWeapons(index, &Handle:arrayTypeWeapons)
{ {
WeaponsGetType(x, weapontype, sizeof(weapontype)); 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++) for (new y = 0; y < WEAPONS_RESTRICT_MAX_TYPES; y++)
{ {
// Cut off whitespace. // Cut off whitespace.