@@ -124,6 +124,14 @@ void CPedSync::Packet_PedStartSync(NetBitStreamInterface& BitStream)
124124 float fHealth , fArmor ;
125125 BitStream.Read (fHealth );
126126 BitStream.Read (fArmor );
127+ 128+ if (BitStream.Can (eBitStreamVersion::PedSync_CameraRotation))
129+ {
130+ float cameraRotation{};
131+ BitStream.Read (cameraRotation);
132+ 133+ pPed->SetCameraRotation (cameraRotation);
134+ }
127135
128136 // Set data
129137 pPed->SetPosition (vecPosition);
@@ -179,10 +187,15 @@ void CPedSync::Packet_PedSync(NetBitStreamInterface& BitStream)
179187 unsigned char ucFlags = 0 ;
180188 BitStream.Read (ucFlags);
181189
190+ std::uint8_t flags2{};
191+ if (BitStream.Can (eBitStreamVersion::PedSync_CameraRotation))
192+ BitStream.Read (flags2);
193+ 182194 CVector vecPosition{ CVector::NoInit{} }, vecMoveSpeed{ CVector::NoInit{} };
183195 float fRotation , fHealth , fArmor ;
184196 bool bOnFire;
185197 bool bIsInWater;
198+ float cameraRotation;
186199
187200 if (BitStream.Can (eBitStreamVersion::PedSync_Revision))
188201 {
@@ -231,6 +244,13 @@ void CPedSync::Packet_PedSync(NetBitStreamInterface& BitStream)
231244 if (ucFlags & 0x10 )
232245 BitStream.Read (fArmor );
233246
247+ if (flags2 & 0x01 )
248+ {
249+ SCameraRotationSync camRotation;
250+ BitStream.Read (&camRotation);
251+ cameraRotation = camRotation.data .fRotation ;
252+ }
253+ 234254 // And the burning state
235255 if (BitStream.Version () >= 0x04E && ucFlags & 0x20 )
236256 BitStream.ReadBit (bOnFire);
@@ -246,13 +266,15 @@ void CPedSync::Packet_PedSync(NetBitStreamInterface& BitStream)
246266 if (ucFlags & 0x01 )
247267 pPed->SetTargetPosition (vecPosition, PED_SYNC_RATE);
248268 if (ucFlags & 0x02 )
249- pPed->SetTargetRotation (PED_SYNC_RATE, fRotation , 0 . 0f );
269+ pPed->SetTargetRotation (PED_SYNC_RATE, fRotation , std:: nullopt );
250270 if (ucFlags & 0x04 )
251271 pPed->SetMoveSpeed (vecMoveSpeed);
252272 if (ucFlags & 0x08 )
253273 pPed->LockHealth (fHealth );
254274 if (ucFlags & 0x10 )
255275 pPed->LockArmor (fArmor );
276+ if (flags2 & 0x01 )
277+ pPed->SetTargetRotation (PED_SYNC_RATE, std::nullopt , cameraRotation);
256278 if (BitStream.Version () >= 0x04E && ucFlags & 0x20 )
257279 pPed->SetOnFire (bOnFire);
258280 if (BitStream.Version () >= 0x55 && ucFlags & 0x40 )
@@ -312,8 +334,12 @@ void CPedSync::WritePedInformation(NetBitStreamInterface* pBitStream, CClientPed
312334 if (pPed->HasSyncedAnim () && (!pPed->IsRunningAnimation () || pPed->m_animationOverridedByClient ))
313335 ucFlags |= 0x80 ;
314336
337+ std::uint8_t flags2{};
338+ if (!IsNearlyEqual (pPed->GetCameraRotation (), pPed->m_LastSyncedData ->cameraRotation ) && pBitStream->Can (eBitStreamVersion::PedSync_CameraRotation))
339+ flags2 |= 0x01 ;
340+ 315341 // Do we really have to sync this ped?
316- if (ucFlags == 0 )
342+ if (ucFlags == 0 && flags2 == 0 )
317343 return ;
318344
319345 // Write the ped id
@@ -325,6 +351,10 @@ void CPedSync::WritePedInformation(NetBitStreamInterface* pBitStream, CClientPed
325351 // Write flags
326352 pBitStream->Write (ucFlags);
327353
354+ // Write flags 2
355+ if (pBitStream->Can (eBitStreamVersion::PedSync_CameraRotation))
356+ pBitStream->Write (flags2);
357+ 328358 // Write position if needed
329359 if (ucFlags & 0x01 )
330360 {
@@ -389,6 +419,14 @@ void CPedSync::WritePedInformation(NetBitStreamInterface* pBitStream, CClientPed
389419 pPed->m_LastSyncedData ->fArmour = pPed->GetArmor ();
390420 }
391421
422+ if (flags2 & 0x01 )
423+ {
424+ SCameraRotationSync camRotation;
425+ camRotation.data .fRotation = pPed->GetCameraRotation ();
426+ pBitStream->Write (&camRotation);
427+ pPed->m_LastSyncedData ->cameraRotation = camRotation.data .fRotation ;
428+ }
429+ 392430 if (ucFlags & 0x20 && pBitStream->Version () >= 0x04E )
393431 {
394432 pBitStream->WriteBit (pPed->IsOnFire ());
0 commit comments