move some features from CSSFixes to PhysHooks

This commit is contained in:
BotoX 2019-12-18 12:02:38 +01:00
parent 9db8c39b98
commit e80a065694
5 changed files with 71 additions and 41 deletions

View File

@ -1,6 +1,6 @@
#include <sourcemod> #include <sourcemod>
#include <sdktools> #include <sdktools>
#include <CSSFixes> #include <PhysHooks>
#include <dhooks> #include <dhooks>
#pragma semicolon 1 #pragma semicolon 1

View File

@ -1,7 +1,7 @@
#include <sourcemod> #include <sourcemod>
#include <sdkhooks> #include <sdkhooks>
#include <sdktools> #include <sdktools>
#include <CSSFixes> #include <PhysHooks>
#include <dhooks> #include <dhooks>
#define SetBit(%1,%2) ((%1)[(%2) >> 5] |= (1 << ((%2) & 31))) #define SetBit(%1,%2) ((%1)[(%2) >> 5] |= (1 << ((%2) & 31)))
@ -21,7 +21,7 @@ public Plugin myinfo =
}; };
bool g_bLateLoad = false; bool g_bLateLoad = false;
bool g_bHasCSSFixes = true; bool g_bHasPhysHooks = true;
// Don't change this. // Don't change this.
#define MAX_EDICTS 2048 #define MAX_EDICTS 2048
@ -134,8 +134,8 @@ int g_iSimulationTime;
int g_iCoordinateFrame; int g_iCoordinateFrame;
int g_aLagCompensated[MAX_EDICTS] = {-1, ...}; int g_aLagCompensated[MAX_EDICTS] = {-1, ...};
int g_aFilterTriggerTouch[MAX_EDICTS / 32]; int g_aBlockTriggerTouchPlayers[MAX_EDICTS / 32];
int g_aaFilterClientEntity[((MAXPLAYERS + 1) * MAX_EDICTS) / 32]; int g_aaFilterClientSolidTouch[((MAXPLAYERS + 1) * MAX_EDICTS) / 32];
int g_aBlockTriggerMoved[MAX_EDICTS / 32]; int g_aBlockTriggerMoved[MAX_EDICTS / 32];
int g_aBlacklisted[MAX_EDICTS / 32]; int g_aBlacklisted[MAX_EDICTS / 32];
@ -271,7 +271,7 @@ public void OnPluginStart()
RegAdminCmd("sm_unlag", Command_AddLagCompensation, ADMFLAG_RCON, "sm_unlag <entidx>"); RegAdminCmd("sm_unlag", Command_AddLagCompensation, ADMFLAG_RCON, "sm_unlag <entidx>");
RegAdminCmd("sm_lagged", Command_CheckLagCompensated, ADMFLAG_GENERIC, "sm_lagged"); RegAdminCmd("sm_lagged", Command_CheckLagCompensated, ADMFLAG_GENERIC, "sm_lagged");
FilterClientEntityMap(g_aaFilterClientEntity, true); FilterClientSolidTouch(g_aaFilterClientSolidTouch, true);
BlockTriggerMoved(g_aBlockTriggerMoved, true); BlockTriggerMoved(g_aBlockTriggerMoved, true);
} }
@ -283,18 +283,18 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
public void OnLibraryRemoved(const char[] name) public void OnLibraryRemoved(const char[] name)
{ {
if(StrEqual(name, "CSSFixes")) if(StrEqual(name, "PhysHooks"))
g_bHasCSSFixes = false; g_bHasPhysHooks = false;
} }
public void OnPluginEnd() public void OnPluginEnd()
{ {
g_bCleaningUp = true; g_bCleaningUp = true;
if(g_bHasCSSFixes) if(g_bHasPhysHooks)
{ {
FilterClientEntityMap(g_aaFilterClientEntity, false); FilterClientSolidTouch(g_aaFilterClientSolidTouch, false);
BlockTriggerMoved(g_aBlockTriggerMoved, false); BlockTriggerMoved(g_aBlockTriggerMoved, false);
FilterTriggerTouchPlayers(g_aFilterTriggerTouch, false); BlockTriggerTouchPlayers(g_aBlockTriggerTouchPlayers, false);
} }
DHookDisableDetour(g_hUTIL_Remove, false, Detour_OnUTIL_Remove); DHookDisableDetour(g_hUTIL_Remove, false, Detour_OnUTIL_Remove);
@ -613,12 +613,12 @@ public MRESReturn Detour_OnRestartRound()
int iEntity = g_aEntityLagData[i].iEntity; int iEntity = g_aEntityLagData[i].iEntity;
g_aLagCompensated[iEntity] = -1; g_aLagCompensated[iEntity] = -1;
ClearBit(g_aFilterTriggerTouch, iEntity); ClearBit(g_aBlockTriggerTouchPlayers, iEntity);
ClearBit(g_aBlockTriggerMoved, iEntity); ClearBit(g_aBlockTriggerMoved, iEntity);
for(int client = 1; client <= MaxClients; client++) for(int client = 1; client <= MaxClients; client++)
{ {
ClearBit(g_aaFilterClientEntity, client * MAX_EDICTS + iEntity); ClearBit(g_aaFilterClientSolidTouch, client * MAX_EDICTS + iEntity);
} }
if(g_aEntityLagData[i].iDeleted) if(g_aEntityLagData[i].iDeleted)
@ -693,7 +693,7 @@ public MRESReturn Detour_OnFrameUpdatePostEntityThink()
public void OnRunThinkFunctions(bool simulating) public void OnRunThinkFunctions(bool simulating)
{ {
FilterTriggerTouchPlayers(g_aFilterTriggerTouch, false); BlockTriggerTouchPlayers(g_aBlockTriggerTouchPlayers, false);
for(int i = 0; i < g_iNumEntities; i++) for(int i = 0; i < g_iNumEntities; i++)
{ {
@ -766,19 +766,19 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
// Entity too new, the client couldn't even see it yet. // Entity too new, the client couldn't even see it yet.
if(g_aEntityLagData[i].iSpawned > iPlayerSimTick) if(g_aEntityLagData[i].iSpawned > iPlayerSimTick)
{ {
SetBit(g_aaFilterClientEntity, client * MAX_EDICTS + iEntity); SetBit(g_aaFilterClientSolidTouch, client * MAX_EDICTS + iEntity);
continue; continue;
} }
else if(g_aEntityLagData[i].iSpawned == iPlayerSimTick) else if(g_aEntityLagData[i].iSpawned == iPlayerSimTick)
{ {
ClearBit(g_aaFilterClientEntity, client * MAX_EDICTS + iEntity); ClearBit(g_aaFilterClientSolidTouch, client * MAX_EDICTS + iEntity);
} }
if(g_aEntityLagData[i].iDeleted) if(g_aEntityLagData[i].iDeleted)
{ {
if(g_aEntityLagData[i].iDeleted <= iPlayerSimTick) if(g_aEntityLagData[i].iDeleted <= iPlayerSimTick)
{ {
SetBit(g_aaFilterClientEntity, client * MAX_EDICTS + iEntity); SetBit(g_aaFilterClientSolidTouch, client * MAX_EDICTS + iEntity);
continue; continue;
} }
} }
@ -815,7 +815,7 @@ public void OnPostPlayerThinkFunctions()
g_aEntityLagData[i].bRestore = false; g_aEntityLagData[i].bRestore = false;
} }
FilterTriggerTouchPlayers(g_aFilterTriggerTouch, true); BlockTriggerTouchPlayers(g_aBlockTriggerTouchPlayers, true);
} }
public void OnRunThinkFunctionsPost(bool simulating) public void OnRunThinkFunctionsPost(bool simulating)
@ -999,7 +999,7 @@ bool AddEntityForLagCompensation(int iEntity, bool bLateKill)
if(bLateKill) if(bLateKill)
{ {
SetBit(g_aFilterTriggerTouch, iEntity); SetBit(g_aBlockTriggerTouchPlayers, iEntity);
} }
RecordDataIntoRecord(iEntity, g_aaLagRecords[i][0]); RecordDataIntoRecord(iEntity, g_aaLagRecords[i][0]);
@ -1050,12 +1050,12 @@ void RemoveRecord(int index)
} }
g_aLagCompensated[iEntity] = -1; g_aLagCompensated[iEntity] = -1;
ClearBit(g_aFilterTriggerTouch, iEntity); ClearBit(g_aBlockTriggerTouchPlayers, iEntity);
ClearBit(g_aBlockTriggerMoved, iEntity); ClearBit(g_aBlockTriggerMoved, iEntity);
for(int client = 1; client <= MaxClients; client++) for(int client = 1; client <= MaxClients; client++)
{ {
ClearBit(g_aaFilterClientEntity, client * MAX_EDICTS + iEntity); ClearBit(g_aaFilterClientSolidTouch, client * MAX_EDICTS + iEntity);
} }
g_aEntityLagData[index].iEntity = INVALID_ENT_REFERENCE; g_aEntityLagData[index].iEntity = INVALID_ENT_REFERENCE;
@ -1168,14 +1168,14 @@ public Action Command_CheckLagCompensated(int client, int argc)
bool bDeleted = false; bool bDeleted = false;
for(int j = 1; j <= MaxClients; j++) for(int j = 1; j <= MaxClients; j++)
{ {
if(CheckBit(g_aaFilterClientEntity, j * MAX_EDICTS + iEntity)) if(CheckBit(g_aaFilterClientSolidTouch, j * MAX_EDICTS + iEntity))
{ {
bDeleted = true; bDeleted = true;
break; break;
} }
} }
bool bBlockPhysics = CheckBit(g_aFilterTriggerTouch, iEntity); bool bBlockPhysics = CheckBit(g_aBlockTriggerTouchPlayers, iEntity);
bool bBlockTriggerMoved = CheckBit(g_aBlockTriggerMoved, iEntity); bool bBlockTriggerMoved = CheckBit(g_aBlockTriggerMoved, iEntity);
bool bBlacklisted = CheckBit(g_aBlacklisted, iEntity); bool bBlacklisted = CheckBit(g_aBlacklisted, iEntity);

View File

@ -3,7 +3,7 @@
#include <sourcemod> #include <sourcemod>
#include <sdkhooks> #include <sdkhooks>
#include <CSSFixes> #include <PhysHooks>
#undef REQUIRE_PLUGIN #undef REQUIRE_PLUGIN
#include <zombiereloaded> #include <zombiereloaded>
#define REQUIRE_PLUGIN #define REQUIRE_PLUGIN

View File

@ -3,23 +3,6 @@
#endif #endif
#define _cssfixes_included #define _cssfixes_included
forward void OnRunThinkFunctions(bool simulating);
forward void OnPrePlayerThinkFunctions();
forward void OnPostPlayerThinkFunctions();
forward void OnRunThinkFunctionsPost(bool simulating);
// Block TriggerMoved from being called at all for an entity by setting the bit to 1.
native void BlockTriggerMoved(int map[2048 / 32], bool set);
// Block SolidMoved from being called at all for an entity by setting the bit to 1.
native void BlockSolidMoved(int map[2048 / 32], bool set);
// Block clients SolidMoved from touching an entity by setting the bit to 1 in the clients map.
native void FilterClientEntityMap(int map[((MAXPLAYERS + 1) * 2048) / 32], bool set);
// Block triggers TriggerMoved from touching any client by setting the bit to 1 for the entity index.
native void FilterTriggerTouchPlayers(int map[2048 / 32], bool set);
// Map entities to client entity in FireBullets/SwingOrStab ShouldHitEntity. // Map entities to client entity in FireBullets/SwingOrStab ShouldHitEntity.
// Aka. shoot and knife through physboxes that are parented to teammates (white knight, gandalf, horse, etc.) // Aka. shoot and knife through physboxes that are parented to teammates (white knight, gandalf, horse, etc.)
native void PhysboxToClientMap(char map[2048], bool set); native void PhysboxToClientMap(char map[2048], bool set);

47
includes/PhysHooks.inc Normal file
View File

@ -0,0 +1,47 @@
#if defined _physhooks_included
#endinput
#endif
#define _physhooks_included
forward void OnRunThinkFunctions(bool simulating);
forward void OnPrePlayerThinkFunctions();
forward void OnPostPlayerThinkFunctions();
forward void OnRunThinkFunctionsPost(bool simulating);
// Block TriggerMoved from being called at all for an entity by setting the bit to 1.
native void BlockTriggerMoved(int map[2048 / 32], bool set);
// Block triggers TriggerMoved from touching any client by setting the bit to 1 for the entity index.
native void BlockTriggerTouchPlayers(int map[2048 / 32], bool set);
// Block SolidMoved from being called at all for an entity by setting the bit to 1.
native void BlockSolidMoved(int map[2048 / 32], bool set);
// Block solids SolidMoved from touching any client by setting the bit to 1 for the entity index.
native void BlockSolidTouchPlayers(int map[2048 / 32], bool set);
// Block clients SolidMoved from touching an entity by setting the bit to 1 in the clients map.
native void FilterClientSolidTouch(int map[((MAXPLAYERS + 1) * 2048) / 32], bool set);
public Extension __ext_PhysHooks =
{
name = "PhysHooks",
file = "PhysHooks.ext",
#if defined AUTOLOAD_EXTENSIONS
autoload = 1,
#else
autoload = 0,
#endif
#if defined REQUIRE_EXTENSIONS
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_EXTENSIONS
public __ext_PhysHooks_SetNTVOptional()
{
}
#endif