New plugin: FixLagCompensation. Disables engine lag comp for players on moving objects.

This commit is contained in:
BotoX 2019-12-21 21:53:09 +01:00
parent 4c52227886
commit 0388e606d9
2 changed files with 118 additions and 0 deletions

View File

@ -0,0 +1,45 @@
"Games"
{
"cstrike"
{
"Offsets"
{
"IsMoving"
{
"windows" "74"
"linux" "75"
}
}
"Signatures"
{
"CLagCompensationManager::BacktrackPlayer"
{
"library" "server"
"linux" "@_ZN23CLagCompensationManager15BacktrackPlayerEP11CBasePlayerf"
}
}
"Functions"
{
"CLagCompensationManager__BacktrackPlayer"
{
"signature" "CLagCompensationManager::BacktrackPlayer"
"callconv" "thiscall"
"return" "void"
"this" "ignore"
"arguments"
{
"pPlayer"
{
"type" "cbaseentity"
}
"flTargetTime"
{
"type" "float"
}
}
}
}
}
}

View File

@ -0,0 +1,73 @@
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <dhooks>
#pragma semicolon 1
#pragma newdecls required
public Plugin myinfo =
{
name = "FixLagCompensation",
author = "BotoX",
description = "",
version = "1.0",
url = ""
};
Handle g_hBacktrackPlayer;
Handle g_hIsMoving;
public void OnPluginStart()
{
Handle hGameData = LoadGameConfigFile("FixLagCompensation.games");
if(!hGameData)
SetFailState("Failed to load FixLagCompensation gamedata.");
// void CLagCompensationManager::BacktrackPlayer( CBasePlayer *pPlayer, float flTargetTime )
g_hBacktrackPlayer = DHookCreateFromConf(hGameData, "CLagCompensationManager__BacktrackPlayer");
if(!g_hBacktrackPlayer)
{
delete hGameData;
SetFailState("Failed to setup detour for CLagCompensationManager__BacktrackPlayer");
}
if(!DHookEnableDetour(g_hBacktrackPlayer, false, Detour_OnBacktrackPlayer))
{
delete hGameData;
SetFailState("Failed to detour CLagCompensationManager__BacktrackPlayer.");
}
// CBaseEntity::IsMoving
StartPrepSDKCall(SDKCall_Entity);
if(!PrepSDKCall_SetFromConf(hGameData, SDKConf_Virtual, "IsMoving"))
{
delete hGameData;
SetFailState("PrepSDKCall_SetFromConf(hGameData, SDKConf_Virtual, \"IsMoving\") failed!");
}
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
g_hIsMoving = EndPrepSDKCall();
delete hGameData;
}
public MRESReturn Detour_OnBacktrackPlayer(Handle hParams)
{
if(DHookIsNullParam(hParams, 1))
return MRES_Ignored;
int client = DHookGetParam(hParams, 1);
if(client < 1 || client > MaxClients)
return MRES_Ignored;
int GroundEntity = GetEntPropEnt(client, Prop_Data, "m_hGroundEntity");
if(GroundEntity <= 0)
return MRES_Ignored;
bool bIsMoving = SDKCall(g_hIsMoving, GroundEntity);
if(bIsMoving)
return MRES_Supercede;
return MRES_Ignored;
}