diff --git a/LagCompensation/gamedata/LagCompensation.games.txt b/LagCompensation/gamedata/LagCompensation.games.txt index d5b9945..c616d18 100644 --- a/LagCompensation/gamedata/LagCompensation.games.txt +++ b/LagCompensation/gamedata/LagCompensation.games.txt @@ -22,6 +22,12 @@ "linux" "@_ZN21CLogicMeasureMovement9SetTargetEPKc" } + "CEntityTouchManager::FrameUpdatePostEntityThink" + { + "library" "server" + "linux" "@_ZN19CEntityTouchManager26FrameUpdatePostEntityThinkEv" + } + "CalcAbsolutePosition" { "library" "server" @@ -59,6 +65,14 @@ "this" "ignore" } + "CEntityTouchManager__FrameUpdatePostEntityThink" + { + "signature" "CEntityTouchManager::FrameUpdatePostEntityThink" + "callconv" "thiscall" + "return" "void" + "this" "ignore" + } + "CLogicMeasureMovement__SetTarget" { "signature" "CLogicMeasureMovement::SetTarget" diff --git a/LagCompensation/scripting/LagCompensation.sp b/LagCompensation/scripting/LagCompensation.sp index b8642a1..a71fa6b 100644 --- a/LagCompensation/scripting/LagCompensation.sp +++ b/LagCompensation/scripting/LagCompensation.sp @@ -90,6 +90,7 @@ Handle g_hUTIL_Remove; Handle g_hRestartRound; Handle g_hSetTarget; Handle g_hSetTargetPost; +Handle g_hFrameUpdatePostEntityThink; int g_iTouchStamp; int g_iCollision; @@ -188,6 +189,20 @@ public void OnPluginStart() SetFailState("Failed to detour CLogicMeasureMovement__SetTarget_post."); } + // CEntityTouchManager::FrameUpdatePostEntityThink + g_hFrameUpdatePostEntityThink = DHookCreateFromConf(hGameData, "CEntityTouchManager__FrameUpdatePostEntityThink"); + if(!g_hFrameUpdatePostEntityThink) + { + delete hGameData; + SetFailState("Failed to setup detour for CEntityTouchManager__FrameUpdatePostEntityThink"); + } + + if(!DHookEnableDetour(g_hFrameUpdatePostEntityThink, false, Detour_OnFrameUpdatePostEntityThink)) + { + delete hGameData; + SetFailState("Failed to detour CEntityTouchManager__FrameUpdatePostEntityThink."); + } + delete hGameData; RegAdminCmd("sm_unlag", Command_AddLagCompensation, ADMFLAG_RCON, "sm_unlag "); @@ -437,6 +452,8 @@ public void OnMapStart() public void OnRunThinkFunctions(bool simulating) { + FilterTriggerTouchPlayers(g_aBlockTriggerTouch, false); + for(int i = 0; i < g_iNumEntities; i++) { if(!IsValidEntity(g_aEntityLagData[i].iEntity)) @@ -684,8 +701,17 @@ public void OnRunThinkFunctionsPost(bool simulating) ); #endif } +} - FilterTriggerTouchPlayers(g_aBlockTriggerTouch, false); +public MRESReturn Detour_OnFrameUpdatePostEntityThink() +{ + // VPhysics runs stuff again after QPhysics entity simulation so do this again... + for(int i = 0; i < g_iNumEntities; i++) + { + int EFlags = GetEntData(g_aEntityLagData[i].iEntity, g_iEFlags); + EFlags &= ~EFL_CHECK_UNTOUCH; + SetEntData(g_aEntityLagData[i].iEntity, g_iEFlags, EFlags); + } } void RecordDataIntoRecord(int iEntity, LagRecord Record)