Add cvars for triggers and physboxes
Also comment out the toggle since it doesn't serve a purpose anymore
This commit is contained in:
parent
c4ecc7f2df
commit
7b60560a7c
@ -155,14 +155,22 @@ 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];
|
||||||
|
|
||||||
Handle g_hCookie_DisableLagComp;
|
//Handle g_hCookie_DisableLagComp;
|
||||||
bool g_bDisableLagComp[MAXPLAYERS+1];
|
//bool g_bDisableLagComp[MAXPLAYERS + 1];
|
||||||
int g_iDisableLagComp[MAXPLAYERS+1];
|
//int g_iDisableLagComp[MAXPLAYERS + 1];
|
||||||
|
|
||||||
|
ConVar g_bLagCompTriggers;
|
||||||
|
ConVar g_bLagCompPhysboxes;
|
||||||
|
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
CreateConVar("sm_lagcomp_version", PLUGIN_VERSION, "LagCompensation Version", FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD).SetString(PLUGIN_VERSION);
|
CreateConVar("sm_lagcomp_version", PLUGIN_VERSION, "LagCompensation Version", FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD).SetString(PLUGIN_VERSION);
|
||||||
|
|
||||||
|
g_bLagCompTriggers = CreateConVar("sm_lagcomp_triggers", "1", "Lag compensate triggers", FCVAR_NONE, true, 0.0, true, 1.0);
|
||||||
|
g_bLagCompPhysboxes = CreateConVar("sm_lagcomp_physboxes", "1", "Lag compensate physboxes", FCVAR_NONE, true, 0.0, true, 1.0);
|
||||||
|
|
||||||
|
AutoExecConfig(true);
|
||||||
|
|
||||||
Handle hGameData = LoadGameConfigFile("LagCompensation.games");
|
Handle hGameData = LoadGameConfigFile("LagCompensation.games");
|
||||||
if(!hGameData)
|
if(!hGameData)
|
||||||
SetFailState("Failed to load LagCompensation gamedata.");
|
SetFailState("Failed to load LagCompensation gamedata.");
|
||||||
@ -324,14 +332,15 @@ public void OnPluginStart()
|
|||||||
|
|
||||||
delete hGameData;
|
delete hGameData;
|
||||||
|
|
||||||
g_bHasOnEntitySpawned = GetFeatureStatus(FeatureType_Capability, "SDKHook_OnEntitySpawned") == FeatureStatus_Available;
|
// Capability provider from https://github.com/alliedmodders/sourcemod/pull/1078
|
||||||
|
g_bHasOnEntitySpawned = true;
|
||||||
|
|
||||||
g_hCookie_DisableLagComp = RegClientCookie("disable_lagcomp", "", CookieAccess_Private);
|
//g_hCookie_DisableLagComp = RegClientCookie("disable_lagcomp", "", CookieAccess_Private);
|
||||||
RegConsoleCmd("sm_lagcomp", OnToggleLagCompSettings);
|
//RegConsoleCmd("sm_lagcomp", OnToggleLagCompSettings);
|
||||||
RegConsoleCmd("sm_0ping", OnToggleLagCompSettings);
|
//RegConsoleCmd("sm_0ping", OnToggleLagCompSettings);
|
||||||
SetCookieMenuItem(MenuHandler_CookieMenu, 0, "LagCompensation");
|
//SetCookieMenuItem(MenuHandler_CookieMenu, 0, "LagCompensation");
|
||||||
|
|
||||||
CreateTimer(0.1, DisableLagCompTimer, _, TIMER_REPEAT);
|
//CreateTimer(0.1, DisableLagCompTimer, _, TIMER_REPEAT);
|
||||||
|
|
||||||
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");
|
||||||
@ -443,13 +452,23 @@ public void OnMapEnd()
|
|||||||
g_bCleaningUp = true;
|
g_bCleaningUp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClientConnected(int client)
|
//public void OnClientConnected(int client)
|
||||||
{
|
//{
|
||||||
g_bDisableLagComp[client] = false;
|
// g_bDisableLagComp[client] = false;
|
||||||
g_iDisableLagComp[client] = 0;
|
// g_iDisableLagComp[client] = 0;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//public void OnClientCookiesCached(int client)
|
||||||
|
//{
|
||||||
|
// char sBuffer[16];
|
||||||
|
// GetClientCookie(client, g_hCookie_DisableLagComp, sBuffer, sizeof(sBuffer));
|
||||||
|
// if(sBuffer[0])
|
||||||
|
// g_bDisableLagComp[client] = true;
|
||||||
|
// else
|
||||||
|
// g_bDisableLagComp[client] = false;
|
||||||
|
//}
|
||||||
|
|
||||||
public void OnClientCookiesCached(int client)
|
public void OnClientSettingsChanged(int client)
|
||||||
{
|
{
|
||||||
if(!IsClientInGame(client))
|
if(!IsClientInGame(client))
|
||||||
return;
|
return;
|
||||||
@ -458,11 +477,11 @@ public void OnClientCookiesCached(int client)
|
|||||||
g_aLerpTicks[client] = RoundToNearest(fLerpTime / g_fTickInterval);
|
g_aLerpTicks[client] = RoundToNearest(fLerpTime / g_fTickInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClientDisconnect(int client)
|
//public void OnClientDisconnect(int client)
|
||||||
{
|
//{
|
||||||
g_bDisableLagComp[client] = false;
|
// g_bDisableLagComp[client] = false;
|
||||||
g_iDisableLagComp[client] = 0;
|
// g_iDisableLagComp[client] = 0;
|
||||||
}
|
//}
|
||||||
|
|
||||||
public void OnEntityCreated(int entity, const char[] classname)
|
public void OnEntityCreated(int entity, const char[] classname)
|
||||||
{
|
{
|
||||||
@ -588,8 +607,14 @@ bool CheckEntityForLagComp(int entity, const char[] classname, bool bRecursive=f
|
|||||||
StrEqual(classname, "trigger_push", false) ||
|
StrEqual(classname, "trigger_push", false) ||
|
||||||
StrEqual(classname, "trigger_teleport", false);
|
StrEqual(classname, "trigger_teleport", false);
|
||||||
|
|
||||||
|
if(bTrigger && !g_bLagCompTriggers.BoolValue)
|
||||||
|
return false;
|
||||||
|
|
||||||
bool bPhysbox = !strncmp(classname, "func_physbox", 12, false);
|
bool bPhysbox = !strncmp(classname, "func_physbox", 12, false);
|
||||||
|
|
||||||
|
if(bPhysbox && !g_bLagCompPhysboxes.BoolValue)
|
||||||
|
return false;
|
||||||
|
|
||||||
bool bBlacklisted = CheckBit(g_aBlacklisted, entity);
|
bool bBlacklisted = CheckBit(g_aBlacklisted, entity);
|
||||||
|
|
||||||
if(!bTrigger && !bPhysbox || bBlacklisted)
|
if(!bTrigger && !bPhysbox || bBlacklisted)
|
||||||
@ -837,7 +862,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
|||||||
// To get the original behavior back lets assume they actually have 0 latency.
|
// To get the original behavior back lets assume they actually have 0 latency.
|
||||||
// To avoid abusing toggling lagcomp we increase/decrease this var by 1 every 100ms.
|
// To avoid abusing toggling lagcomp we increase/decrease this var by 1 every 100ms.
|
||||||
// This is so we only skip single ticks at a time. Fully ON = 0, Fully OFF = MAX_RECORDS
|
// This is so we only skip single ticks at a time. Fully ON = 0, Fully OFF = MAX_RECORDS
|
||||||
iDelta -= g_iDisableLagComp[client];
|
//iDelta -= g_iDisableLagComp[client];
|
||||||
|
|
||||||
if(iDelta < 0)
|
if(iDelta < 0)
|
||||||
iDelta = 0;
|
iDelta = 0;
|
||||||
@ -1318,91 +1343,94 @@ stock void PrintToBoth(const char[] format, any ...)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action DisableLagCompTimer(Handle timer)
|
//public Action DisableLagCompTimer(Handle timer)
|
||||||
{
|
//{
|
||||||
for(int client = 1; client <= MaxClients; client++)
|
// for(int client = 1; client <= MaxClients; client++)
|
||||||
{
|
// {
|
||||||
if(g_bDisableLagComp[client] && g_iDisableLagComp[client] < MAX_RECORDS)
|
// if(g_bDisableLagComp[client] && g_iDisableLagComp[client] < MAX_RECORDS)
|
||||||
{
|
// {
|
||||||
g_iDisableLagComp[client]++;
|
// g_iDisableLagComp[client]++;
|
||||||
}
|
// }
|
||||||
else if(!g_bDisableLagComp[client] && g_iDisableLagComp[client] > 0)
|
// else if(!g_bDisableLagComp[client] && g_iDisableLagComp[client] > 0)
|
||||||
{
|
// {
|
||||||
g_iDisableLagComp[client]--;
|
// g_iDisableLagComp[client]--;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// return Plugin_Continue;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//public Action OnLagCompSettings(int client, int args)
|
||||||
|
//{
|
||||||
|
// ShowSettingsMenu(client);
|
||||||
|
// return Plugin_Handled;
|
||||||
|
//}
|
||||||
|
|
||||||
return Plugin_Continue;
|
//public Action OnToggleLagCompSettings(int client, int args)
|
||||||
}
|
//{
|
||||||
|
// ToggleLagCompSettings(client);
|
||||||
public Action OnLagCompSettings(int client, int args)
|
// return Plugin_Handled;
|
||||||
{
|
//}
|
||||||
ShowSettingsMenu(client);
|
//
|
||||||
return Plugin_Handled;
|
//public void ToggleLagCompSettings(int client)
|
||||||
}
|
//{
|
||||||
|
// if(!client)
|
||||||
public Action OnToggleLagCompSettings(int client, int args)
|
// return;
|
||||||
{
|
//
|
||||||
ToggleLagCompSettings(client);
|
// g_bDisableLagComp[client] = !g_bDisableLagComp[client];
|
||||||
return Plugin_Handled;
|
// SetClientCookie(client, g_hCookie_DisableLagComp, g_bDisableLagComp[client] ? "1" : "");
|
||||||
}
|
//
|
||||||
|
// PrintToChat(client, "\x04[LagCompensation]\x01 LagCompensation has been %s.", g_bDisableLagComp[client] ? "disabled" : "enabled");
|
||||||
public void ToggleLagCompSettings(int client)
|
//}
|
||||||
{
|
//
|
||||||
g_bDisableLagComp[client] = !g_bDisableLagComp[client];
|
//public void ShowSettingsMenu(int client)
|
||||||
SetClientCookie(client, g_hCookie_DisableLagComp, g_bDisableLagComp[client] ? "1" : "");
|
//{
|
||||||
|
// Menu menu = new Menu(MenuHandler_MainMenu);
|
||||||
PrintToChat(client, "\x04[LagCompensation]\x01 LagCompensation has been %s.", g_bDisableLagComp[client] ? "disabled" : "enabled");
|
// menu.SetTitle("LagCompensation Settings", client);
|
||||||
}
|
// menu.ExitBackButton = true;
|
||||||
|
//
|
||||||
public void ShowSettingsMenu(int client)
|
// char sBuffer[128];
|
||||||
{
|
// Format(sBuffer, sizeof(sBuffer), "LagCompensation: %s", g_bDisableLagComp[client] ? "Disabled" : "Enabled");
|
||||||
Menu menu = new Menu(MenuHandler_MainMenu);
|
// menu.AddItem("0", sBuffer);
|
||||||
menu.SetTitle("LagCompensation Settings", client);
|
//
|
||||||
menu.ExitBackButton = true;
|
// menu.Display(client, MENU_TIME_FOREVER);
|
||||||
|
//}
|
||||||
char sBuffer[128];
|
//
|
||||||
Format(sBuffer, sizeof(sBuffer), "LagCompensation: %s", g_bDisableLagComp[client] ? "Disabled" : "Enabled");
|
//public void MenuHandler_CookieMenu(int client, CookieMenuAction action, any info, char[] buffer, int maxlen)
|
||||||
menu.AddItem("0", sBuffer);
|
//{
|
||||||
|
// switch(action)
|
||||||
menu.Display(client, MENU_TIME_FOREVER);
|
// {
|
||||||
}
|
// case(CookieMenuAction_DisplayOption):
|
||||||
|
// {
|
||||||
public void MenuHandler_CookieMenu(int client, CookieMenuAction action, any info, char[] buffer, int maxlen)
|
// Format(buffer, maxlen, "LagCompensation", client);
|
||||||
{
|
// }
|
||||||
switch(action)
|
// case(CookieMenuAction_SelectOption):
|
||||||
{
|
// {
|
||||||
case(CookieMenuAction_DisplayOption):
|
// ShowSettingsMenu(client);
|
||||||
{
|
// }
|
||||||
Format(buffer, maxlen, "LagCompensation", client);
|
// }
|
||||||
}
|
//}
|
||||||
case(CookieMenuAction_SelectOption):
|
//
|
||||||
{
|
//public int MenuHandler_MainMenu(Menu menu, MenuAction action, int client, int selection)
|
||||||
ShowSettingsMenu(client);
|
//{
|
||||||
}
|
// switch(action)
|
||||||
}
|
// {
|
||||||
}
|
// case(MenuAction_Select):
|
||||||
|
// {
|
||||||
public int MenuHandler_MainMenu(Menu menu, MenuAction action, int client, int selection)
|
// switch(selection)
|
||||||
{
|
// {
|
||||||
switch(action)
|
// case(0): ToggleLagCompSettings(client);
|
||||||
{
|
// }
|
||||||
case(MenuAction_Select):
|
//
|
||||||
{
|
// ShowSettingsMenu(client);
|
||||||
switch(selection)
|
// }
|
||||||
{
|
// case(MenuAction_Cancel):
|
||||||
case(0): ToggleLagCompSettings(client);
|
// {
|
||||||
}
|
// ShowCookieMenu(client);
|
||||||
|
// }
|
||||||
ShowSettingsMenu(client);
|
// case(MenuAction_End):
|
||||||
}
|
// {
|
||||||
case(MenuAction_Cancel):
|
// delete menu;
|
||||||
{
|
// }
|
||||||
ShowCookieMenu(client);
|
// }
|
||||||
}
|
//}
|
||||||
case(MenuAction_End):
|
|
||||||
{
|
|
||||||
delete menu;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user