From 8d8b9e33d4a542c0c8b8951455aabc5a80c37373 Mon Sep 17 00:00:00 2001 From: ricardoofnl Date: Sat, 5 Sep 2026 09:12:10 +0700 Subject: [PATCH] [saco] Implement/match `FUNC_10014C40`, the 3D position resync; the lerp factor is a mutable global so it lands in `st(1)` instead of an `fmul` operand --- saco/net/remoteplayer.cpp | 44 +++++++++++++++++++++++++++++++++++++++ saco/net/remoteplayer.h | 3 ++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/saco/net/remoteplayer.cpp b/saco/net/remoteplayer.cpp index 27a3746..8cc6983 100644 --- a/saco/net/remoteplayer.cpp +++ b/saco/net/remoteplayer.cpp @@ -8,6 +8,7 @@ using namespace RakNet; extern CNetGame* pNetGame; extern CChatWindow *pChatWindow; +float fPosLerp = 0.1f; int bClampVehicleTurnSpeed = 1; //---------------------------------------------------- @@ -410,6 +411,49 @@ void CRemotePlayer::FUNC_10017260(BYTE *pSync, int iTime) //---------------------------------------------------- +void CRemotePlayer::FUNC_10014C40() +{ + if(!m_pPlayerPed) return; + + MATRIX4X4 mat; + VECTOR vecMove; + float fOffZ; + + m_pPlayerPed->GetMatrix(&mat); + + if(!m_pPlayerPed->IsAdded()) { + mat.pos.X = field_17C.X; + mat.pos.Y = field_17C.Y; + mat.pos.Z = field_17C.Z; + m_pPlayerPed->SetMatrix(mat); + return; + } + + field_160 = FloatOffset(field_17C.X, mat.pos.X); + field_164 = FloatOffset(field_17C.Y, mat.pos.Y); + fOffZ = FloatOffset(field_17C.Z, mat.pos.Z); + field_168 = fOffZ; + + if(field_160 <= 0.00001f && field_164 <= 0.00001f && fOffZ <= 0.00001f) return; + + if(field_160 > 2.0f || field_164 > 2.0f || fOffZ > 1.0f) { + mat.pos.X = field_17C.X; + mat.pos.Y = field_17C.Y; + mat.pos.Z = field_17C.Z; + m_pPlayerPed->SetMatrix(mat); + return; + } + + m_pPlayerPed->GetMoveSpeedVector(&vecMove); + float fLerp = fPosLerp; + if(field_160 > 0.00001f) vecMove.X = (field_17C.X - mat.pos.X) * fLerp + vecMove.X; + if(field_164 > 0.00001f) vecMove.Y = (field_17C.Y - mat.pos.Y) * fLerp + vecMove.Y; + if(field_168 > 0.00001f) vecMove.Z = (field_17C.Z - mat.pos.Z) * fLerp + vecMove.Z; + m_pPlayerPed->SetMoveSpeedVector(vecMove); +} + +//---------------------------------------------------- + void CRemotePlayer::FUNC_10014E60() { if(!m_pPlayerPed) return; diff --git a/saco/net/remoteplayer.h b/saco/net/remoteplayer.h index 6cd0822..19de6a6 100644 --- a/saco/net/remoteplayer.h +++ b/saco/net/remoteplayer.h @@ -39,7 +39,7 @@ public: char _gap114[76]; float field_160; float field_164; - char _gap168[4]; + float field_168; float quat16C[4]; VECTOR field_17C; VECTOR field_188; @@ -94,6 +94,7 @@ public: void FUNC_100148F0(); // .text:100148F0 void FUNC_10014FF0(); // .text:10014FF0 void FUNC_10017260(BYTE *pSync, int iTime); // .text:10017260 + void FUNC_10014C40(); // .text:10014C40 void FUNC_10014E60(); // .text:10014E60 void FUNC_10015460(); // .text:10015460 void FUNC_10015760(BYTE *pAim); // .text:10015760