From 5f492d0791c4a5b60712ba877ef961291c528071 Mon Sep 17 00:00:00 2001 From: ricardoofnl Date: Sat, 5 Sep 2026 08:32:11 +0700 Subject: [PATCH] [saco] Implement/match `FUNC_10015760`, the aim sync handler; repeating the sync load per destination keeps the copies in GPRs instead of `fld`/`fst` --- saco/game/common.h | 3 ++- saco/game/util.h | 1 + saco/net/remoteplayer.cpp | 49 +++++++++++++++++++++++++++++++++++++++ saco/net/remoteplayer.h | 1 + 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/saco/game/common.h b/saco/game/common.h index 6236eb4..666a54a 100644 --- a/saco/game/common.h +++ b/saco/game/common.h @@ -65,7 +65,8 @@ typedef struct _WEAPON_SLOT_TYPE { DWORD dwType; - char _gap4[8]; + DWORD field_4; + DWORD field_8; DWORD dwAmmo; diff --git a/saco/game/util.h b/saco/game/util.h index cf833c0..53c6fa9 100644 --- a/saco/game/util.h +++ b/saco/game/util.h @@ -112,6 +112,7 @@ void FUNC_100B5D20(); // .text:100B5D20 void FUNC_100B52B0(MATRIX4X4 *pMatrix, float *pQuatOut); // .text:100B52B0 void FUNC_100B5480(float *pQuatOut, float *pQuatFrom, float *pQuatTo, float fT); // .text:100B5480 void FUNC_100B6A80(float *pQuat, MATRIX4X4 *pMatrix); // .text:100B6A80 +void __stdcall FUNC_100B6900(VECTOR *pFront, VECTOR *pOut); // .text:100B6900 void FUNC_100B5210(int a1, void *a2); // .text:100B5210, __cdecl: the caller's // stack cleanup is folded into the next call's argument setup diff --git a/saco/net/remoteplayer.cpp b/saco/net/remoteplayer.cpp index 8f648cd..23ce370 100644 --- a/saco/net/remoteplayer.cpp +++ b/saco/net/remoteplayer.cpp @@ -36,6 +36,8 @@ typedef char CRemotePlayer_offsets[( typedef char CNetPlayer_offsets[(offsetof(CNetPlayer, m_PlayerName) == 0x14) ? 1 : -1]; typedef char struc_41_offsets[(offsetof(struc_41, field_30) == 0x30) ? 1 : -1]; +typedef char WEAPON_SLOT_offsets[(offsetof(WEAPON_SLOT_TYPE, field_8) == 8 && + sizeof(WEAPON_SLOT_TYPE) == 28) ? 1 : -1]; typedef char CPlayerPool_offsets[(offsetof(CPlayerPool, field_6) == 6 && sizeof(std::string) == 0x1C) ? 1 : -1]; @@ -405,6 +407,53 @@ void CRemotePlayer::FUNC_10017260(BYTE *pSync, int iTime) //---------------------------------------------------- +void CRemotePlayer::FUNC_10015760(BYTE *pAim) +{ + if(!m_pPlayerPed) return; + + m_pPlayerPed->SetCameraMode(pAim[0]); + + CAMERA_AIM aim; + VECTOR vecFront; + VECTOR vecUp; + + vecUp.X = 0.0f; + vecUp.Y = 0.0f; + vecUp.Z = 0.0f; + + aim.f1x = *(float *)(pAim + 1); + aim.f1y = *(float *)(pAim + 5); + aim.f1z = *(float *)(pAim + 9); + vecFront.X = *(float *)(pAim + 1); + vecFront.Y = *(float *)(pAim + 5); + vecFront.Z = *(float *)(pAim + 9); + + FUNC_100B6900(&vecFront, &vecUp); + + aim.f2x = vecUp.X; + aim.f2y = vecUp.Y; + aim.f2z = vecUp.Z; + aim.pos1x = *(float *)(pAim + 0xD); + aim.pos1y = *(float *)(pAim + 0x11); + aim.pos1z = *(float *)(pAim + 0x15); + aim.pos2x = *(float *)(pAim + 0xD); + aim.pos2y = *(float *)(pAim + 0x11); + aim.pos2z = *(float *)(pAim + 0x15); + + m_pPlayerPed->SetCurrentAim(&aim); + m_pPlayerPed->SetAimZ(*(float *)(pAim + 0x19)); + m_pPlayerPed->SetCameraExtZoom((float)(pAim[0x1D] & 0x3F) * 0.015873017f, + (float)pAim[0x1E] * 0.0039215689f); + + WEAPON_SLOT_TYPE *pSlot = m_pPlayerPed->GetCurrentWeaponSlot(); + BYTE byteState = pAim[0x1D] >> 6; + if(byteState == 3) pSlot->field_4 = 2; + else if(byteState != 2) pSlot->field_8 = pAim[0x1D] >> 6; + else if(pSlot->field_8 < 2) pSlot->field_8 = 2; +} + +//---------------------------------------------------- + BOOL CRemotePlayer::FUNC_10017130(int a1, int iSkin, int a3, VECTOR *pPos, float fRotation, DWORD dwColor, BYTE byteStyle) { diff --git a/saco/net/remoteplayer.h b/saco/net/remoteplayer.h index 0a45046..df6d4c8 100644 --- a/saco/net/remoteplayer.h +++ b/saco/net/remoteplayer.h @@ -86,6 +86,7 @@ public: void FUNC_100148F0(); // .text:100148F0 void FUNC_10014FF0(); // .text:10014FF0 void FUNC_10017260(BYTE *pSync, int iTime); // .text:10017260 + void FUNC_10015760(BYTE *pAim); // .text:10015760 BOOL FUNC_10017130(int a1, int iSkin, int a3, VECTOR *pPos, float fRotation, DWORD dwColor, BYTE byteStyle); // .text:10017130 void FUNC_10015650(MATRIX4X4 *pMat, VECTOR *pMoveSpeed, float fT); // .text:10015650