Skip to content

Commit d318adf

Browse files
committed
Handle target camera rotation
1 parent b3d44c7 commit d318adf

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3333,14 +3333,20 @@ void CClientPed::SetTargetRotation(float fRotation)
33333333
SetCurrentRotation(fRotation);
33343334
}
33353335

3336-
void CClientPed::SetTargetRotation(unsigned long ulDelay, float fRotation, float fCameraRotation)
3336+
void CClientPed::SetTargetRotation(unsigned long ulDelay, std::optional<float> rotation, std::optional<float> cameraRotation)
33373337
{
33383338
m_ulBeginRotationTime = CClientTime::GetTime();
33393339
m_ulEndRotationTime = m_ulBeginRotationTime + ulDelay;
3340-
m_fBeginRotation = (m_pPlayerPed) ? m_pPlayerPed->GetCurrentRotation() : m_fCurrentRotation;
3341-
m_fTargetRotationA = fRotation;
3342-
m_fBeginCameraRotation = GetCameraRotation();
3343-
m_fTargetCameraRotation = fCameraRotation;
3340+
if (rotation.has_value())
3341+
{
3342+
m_fBeginRotation = (m_pPlayerPed) ? m_pPlayerPed->GetCurrentRotation() : m_fCurrentRotation;
3343+
m_fTargetRotationA = rotation.value();
3344+
}
3345+
if (cameraRotation.has_value())
3346+
{
3347+
m_fBeginCameraRotation = GetCameraRotation();
3348+
m_fTargetCameraRotation = cameraRotation.value();
3349+
}
33443350
}
33453351

33463352
// Temporary

Client/mods/deathmatch/logic/CClientPed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
206206
float GetCurrentRotation();
207207
void SetCurrentRotation(float fRotation, bool bIncludeTarget = true);
208208
void SetTargetRotation(float fRotation);
209-
void SetTargetRotation(unsigned long ulDelay, float fRotation, float fCameraRotation);
209+
void SetTargetRotation(unsigned long ulDelay, std::optional<float> rotation, std::optional<float> cameraRotation);
210210

211211
float GetCameraRotation();
212212
void SetCameraRotation(float fRotation);

Client/mods/deathmatch/logic/CPedSync.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,15 @@ void CPedSync::Packet_PedSync(NetBitStreamInterface& BitStream)
266266
if (ucFlags & 0x01)
267267
pPed->SetTargetPosition(vecPosition, PED_SYNC_RATE);
268268
if (ucFlags & 0x02)
269-
pPed->SetTargetRotation(PED_SYNC_RATE, fRotation, 0.0f);
269+
pPed->SetTargetRotation(PED_SYNC_RATE, fRotation, std::nullopt);
270270
if (ucFlags & 0x04)
271271
pPed->SetMoveSpeed(vecMoveSpeed);
272272
if (ucFlags & 0x08)
273273
pPed->LockHealth(fHealth);
274274
if (ucFlags & 0x10)
275275
pPed->LockArmor(fArmor);
276276
if (flags2 & 0x01)
277-
pPed->SetCameraRotation(cameraRotation);
277+
pPed->SetTargetRotation(PED_SYNC_RATE, std::nullopt, cameraRotation);
278278
if (BitStream.Version() >= 0x04E && ucFlags & 0x20)
279279
pPed->SetOnFire(bOnFire);
280280
if (BitStream.Version() >= 0x55 && ucFlags & 0x40)

0 commit comments

Comments
 (0)