From 4c52227886c5a4b4d9462161fee73a2503ee9a81 Mon Sep 17 00:00:00 2001 From: BotoX Date: Sat, 21 Dec 2019 21:52:53 +0100 Subject: [PATCH] LagCompensation: fix PVS issues? --- .../gamedata/LagCompensation.games.txt | 6 +++++ LagCompensation/scripting/LagCompensation.sp | 24 ++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/LagCompensation/gamedata/LagCompensation.games.txt b/LagCompensation/gamedata/LagCompensation.games.txt index c616d185..13b61126 100644 --- a/LagCompensation/gamedata/LagCompensation.games.txt +++ b/LagCompensation/gamedata/LagCompensation.games.txt @@ -39,6 +39,12 @@ "library" "server" "linux" "@_ZN18CCollisionProperty24MarkPartitionHandleDirtyEv" } + + "RecomputePVSInformation" + { + "library" "server" + "linux" "@_ZN22CServerNetworkProperty23RecomputePVSInformationEv" + } } "Functions" diff --git a/LagCompensation/scripting/LagCompensation.sp b/LagCompensation/scripting/LagCompensation.sp index 8298431c..663baa14 100644 --- a/LagCompensation/scripting/LagCompensation.sp +++ b/LagCompensation/scripting/LagCompensation.sp @@ -16,7 +16,7 @@ public Plugin myinfo = name = "LagCompensation", author = "BotoX", description = "", - version = "1.0", + version = "1.1", url = "" }; @@ -112,6 +112,7 @@ bool g_bCleaningUp = true; Handle g_hCalcAbsolutePosition; Handle g_hMarkPartitionHandleDirty; +Handle g_hRecomputePVSInformation; Handle g_hUTIL_Remove; Handle g_hRestartRound; @@ -167,6 +168,15 @@ public void OnPluginStart() } g_hMarkPartitionHandleDirty = EndPrepSDKCall(); + // CServerNetworkProperty::RecomputePVSInformation + StartPrepSDKCall(SDKCall_Raw); + if(!PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, "RecomputePVSInformation")) + { + delete hGameData; + SetFailState("PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, \"RecomputePVSInformation\") failed!"); + } + g_hRecomputePVSInformation = EndPrepSDKCall(); + // ::UTIL_Remove g_hUTIL_Remove = DHookCreateFromConf(hGameData, "UTIL_Remove"); @@ -892,6 +902,14 @@ void RecordDataIntoRecord(int iEntity, LagRecord Record) GetEntDataArray(iEntity, g_iCoordinateFrame, view_as(Record.rgflCoordinateFrame), COORDINATE_FRAME_SIZE); Record.flSimulationTime = GetEntDataFloat(iEntity, g_iSimulationTime); + // Make sure to have fresh PVS info before caching it. + // NetworkProp()->RecomputePVSInformation(); + Address NetworkProp = GetEntityAddress(iEntity) + view_as
(g_iNetwork); + SDKCall(g_hRecomputePVSInformation, NetworkProp); + + if(GetEdictFlags(iEntity) & FL_EDICT_DIRTY_PVS_INFORMATION) + PrintToBoth("POST FL_EDICT_DIRTY_PVS_INFORMATION !!!!!!!!"); + // CServerNetworkProperty::GetPVSInfo(): return this + 16; GetEntDataArray(iEntity, g_iNetwork + PVSINFO_OFFSET, view_as(Record.PVSInfo), PVSINFO_SIZE); } @@ -942,6 +960,10 @@ void InvalidatePhysicsRecursive(int iEntity, LagRecord Record) fStateFlags |= FL_EDICT_DIRTY_PVS_INFORMATION; SetEdictFlags(iEntity, fStateFlags); */ + + if(GetEdictFlags(iEntity) & FL_EDICT_DIRTY_PVS_INFORMATION) + PrintToBoth("RESTORE FL_EDICT_DIRTY_PVS_INFORMATION !!!!!!!!"); + SetEntDataArray(iEntity, g_iNetwork + PVSINFO_OFFSET, view_as(Record.PVSInfo), PVSINFO_SIZE); // CollisionProp()->MarkPartitionHandleDirty();