Skip to content

Commit 496cc42

Browse files
authored
Merge branch 'master' into cancel-command
2 parents 8f0decf + 4d681a4 commit 496cc42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+548
-336
lines changed

Client/game_sa/CSettingsSA.cpp

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "CGameSA.h"
1717
#include "CHudSA.h"
1818
#include "CSettingsSA.h"
19+
#include "CCameraSA.h"
20+
#include "CCamSA.h"
1921

2022
extern CCoreInterface* g_pCore;
2123
extern CGameSA* pGame;
@@ -525,36 +527,73 @@ void CSettingsSA::ResetFieldOfViewFromScript()
525527
UpdateFieldOfViewFromSettings();
526528
}
527529

528-
void CSettingsSA::SetFieldOfViewPlayer(float fAngle, bool bFromScript)
530+
static std::pair<CCam*, unsigned int> GetActiveCamPlusMode()
531+
{
532+
CCam* cam = pGame->GetCamera()->GetCam(pGame->GetCamera()->GetActiveCam());
533+
534+
if (cam == nullptr)
535+
return std::make_pair(cam, MODE_NONE);
536+
537+
return std::make_pair(cam, cam->GetMode());
538+
}
539+
540+
void CSettingsSA::SetFieldOfViewPlayer(float fAngle, bool bFromScript, bool instant)
529541
{
530542
if (!bFromScript && ms_bFOVPlayerFromScript)
531543
return;
544+
532545
ms_bFOVPlayerFromScript = bFromScript;
533546
ms_fFOV = fAngle;
547+
548+
// CCam::Process_FollowPed_SA
534549
MemPut<void*>(0x0522F3A, &ms_fFOV);
535550
MemPut<void*>(0x0522F5D, &ms_fFOV);
536551
MemPut<float>(0x0522F7A, ms_fFOV);
552+
553+
if (instant)
554+
{
555+
const auto pair = GetActiveCamPlusMode();
556+
557+
if (pair.second == MODE_FOLLOWPED)
558+
pair.first->SetFOV(fAngle);
559+
}
537560
}
538561

539-
void CSettingsSA::SetFieldOfViewVehicle(float fAngle, bool bFromScript)
562+
void CSettingsSA::SetFieldOfViewVehicle(float fAngle, bool bFromScript, bool instant)
540563
{
541564
if (!bFromScript && ms_bFOVVehicleFromScript)
542565
return;
566+
543567
ms_bFOVVehicleFromScript = bFromScript;
544568
ms_fFOVCar = fAngle;
569+
570+
// CCam::Process_FollowCar_SA
545571
MemPut<void*>(0x0524B76, &ms_fFOVCar);
546572
MemPut<void*>(0x0524B9A, &ms_fFOVCar);
547573
MemPut<void*>(0x0524BA2, &ms_fFOVCar);
548574
MemPut<void*>(0x0524BD3, &ms_fFOVCar);
549575
MemPut<float>(0x0524BE4, ms_fFOVCar);
576+
577+
if (instant)
578+
{
579+
const auto pair = GetActiveCamPlusMode();
580+
581+
if (pair.second == MODE_BEHINDCAR || pair.second == MODE_CAM_ON_A_STRING || pair.second == MODE_BEHINDBOAT)
582+
pair.first->SetFOV(fAngle);
583+
}
550584
}
551585

552-
void CSettingsSA::SetFieldOfViewVehicleMax(float fAngle, bool bFromScript)
586+
void CSettingsSA::SetFieldOfViewVehicleMax(float fAngle, bool bFromScript, bool instant)
553587
{
588+
(void)instant;
589+
554590
if (!bFromScript && ms_bFOVVehicleFromScript)
555591
return;
592+
556593
ms_bFOVVehicleFromScript = bFromScript;
557594
ms_fFOVCarMax = fAngle;
595+
596+
// CCam::Process_FollowCar_SA
558597
MemPut<void*>(0x0524BB4, &ms_fFOVCarMax);
559598
MemPut<float>(0x0524BC5, ms_fFOVCarMax);
560599
}

Client/game_sa/CSettingsSA.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ class CSettingsSA : public CGameSettings
162162

163163
void UpdateFieldOfViewFromSettings();
164164
void ResetFieldOfViewFromScript();
165-
void SetFieldOfViewPlayer(float fAngle, bool bFromScript);
166-
void SetFieldOfViewVehicle(float fAngle, bool bFromScript);
167-
void SetFieldOfViewVehicleMax(float fAngle, bool bFromScript);
165+
void SetFieldOfViewPlayer(float fAngle, bool bFromScript, bool instant = false);
166+
void SetFieldOfViewVehicle(float fAngle, bool bFromScript, bool instant = false);
167+
void SetFieldOfViewVehicleMax(float fAngle, bool bFromScript, bool instant = false);
168168
float GetFieldOfViewPlayer();
169169
float GetFieldOfViewVehicle();
170170
float GetFieldOfViewVehicleMax();

Client/loader/MainFunctions.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -863,11 +863,11 @@ void CheckDataFiles()
863863
{
864864
const char* expected;
865865
const char* fileName;
866-
} integrityCheckList[] = {{"24F61A108D285381A67CE643ABBF589C", "bass.dll"}, {"5F9352A9D36E12E1E167E28040EADA83", "bass_aac.dll"},
867-
{"F0D770E77C5A5816D9E2323CC683BA32", "bass_ac3.dll"}, {"D6669FA6DFD548E60CC20503ABCF2FF8", "bass_fx.dll"},
868-
{"F47DCE69DAFAA06A55A4BC1F07F80C8A", "bassflac.dll"}, {"CD9B45DFE7D8B4D547F8B0193C6CF30B", "bassmidi.dll"},
869-
{"F1F587B6515530634AD489CE507BC957", "bassmix.dll"}, {"9CFA31A873FF89C2CC491B9974FC5C65", "bassopus.dll"},
870-
{"0F1B2FC6C0C703A43A24DC05352E7ADA", "basswebm.dll"}, {"1507C60C02E159B5FB247FEC6B209B09", "basswma.dll"},
866+
} integrityCheckList[] = {{"DE5C08577EAA65309974F9860E303F53", "bass.dll"}, {"1D5A1AEF041255DEA49CD4780CAE4CCC", "bass_aac.dll"},
867+
{"8A1AC2AAD7F1691943635CA42F7F2940", "bass_ac3.dll"}, {"61C38C1FD091375F2A30EC631DF337E6", "bass_fx.dll"},
868+
{"F47DCE69DAFAA06A55A4BC1F07F80C8A", "bassflac.dll"}, {"49A603ED114982787FC0A301C0E93FDB", "bassmidi.dll"},
869+
{"064398B1A74B4EF35902F0C218142133", "bassmix.dll"}, {"9CFA31A873FF89C2CC491B9974FC5C65", "bassopus.dll"},
870+
{"B35714019BBFF0D0CEE0AFA2637A77A7", "basswebm.dll"}, {"1507C60C02E159B5FB247FEC6B209B09", "basswma.dll"},
871871
{"C6A44FC3CF2F5801561804272217B14D", "D3DX9_42.dll"}, {"D439E8EDD8C93D7ADE9C04BCFE9197C6", "sa.dat"},
872872
{"B33B21DB610116262D906305CE65C354", "D3DCompiler_42.dll"}, {"4B3932359373F11CBC542CC96D9A9285", "tags.dll"},
873873
{"0B3DD892007FB366D1F52F2247C046F5", "d3dcompiler_43.dll"}, {"D5D8C8561C6DDA7EF0D7D6ABB0D772F4", "xinput1_3_mta.dll"},

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 27 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2895,11 +2895,6 @@ void CClientPed::StreamedInPulse(bool bDoStandardPulses)
28952895
}
28962896
}
28972897

2898-
// Are we need to update anim speed & progress?
2899-
// We need to do it here because the anim starts on the next frame after calling RunNamedAnimation
2900-
if (m_pAnimationBlock && m_AnimationCache.progressWaitForStreamIn && IsAnimationInProgress())
2901-
UpdateAnimationProgressAndSpeed();
2902-
29032898
// Update our alpha
29042899
unsigned char ucAlpha = m_ucAlpha;
29052900
// Are we in a different interior to the camera? set our alpha to 0
@@ -3690,8 +3685,8 @@ void CClientPed::_CreateModel()
36903685
Kill(WEAPONTYPE_UNARMED, 0, false, true);
36913686
}
36923687

3693-
// Are we still playing a animation?
3694-
if (m_pAnimationBlock && IsAnimationInProgress())
3688+
// Are we still playing animation?
3689+
if ((m_AnimationCache.bLoop || m_AnimationCache.bFreezeLastFrame || m_AnimationCache.progressWaitForStreamIn) && m_pAnimationBlock)
36953690
{
36963691
if (m_bisCurrentAnimationCustom)
36973692
{
@@ -3968,8 +3963,8 @@ void CClientPed::_ChangeModel()
39683963
}
39693964
m_bDontChangeRadio = false;
39703965

3971-
// Are we still playing a animation?
3972-
if (m_pAnimationBlock && IsAnimationInProgress())
3966+
// Are we still playing a looped animation?
3967+
if ((m_AnimationCache.bLoop || m_AnimationCache.bFreezeLastFrame || m_AnimationCache.progressWaitForStreamIn) && m_pAnimationBlock)
39733968
{
39743969
if (m_bisCurrentAnimationCustom)
39753970
{
@@ -5736,23 +5731,7 @@ bool CClientPed::IsRunningAnimation()
57365731
}
57375732
return false;
57385733
}
5739-
return (m_AnimationCache.bLoop || m_AnimationCache.bFreezeLastFrame) && m_pAnimationBlock;
5740-
}
5741-
5742-
bool CClientPed::IsAnimationInProgress()
5743-
{
5744-
bool constAnim = m_AnimationCache.bLoop || m_AnimationCache.bFreezeLastFrame;
5745-
5746-
if (!m_pAnimationBlock)
5747-
return constAnim;
5748-
5749-
float elapsedTime = static_cast<float>(GetTimestamp() - m_AnimationCache.startTime) / 1000.0f;
5750-
5751-
auto animBlendHierarchy = g_pGame->GetAnimManager()->GetAnimation(m_AnimationCache.strName.c_str(), m_pAnimationBlock);
5752-
if (!animBlendHierarchy)
5753-
return constAnim;
5754-
5755-
return constAnim || elapsedTime < animBlendHierarchy->GetTotalTime();
5734+
return (m_AnimationCache.bLoop && m_pAnimationBlock);
57565735
}
57575736

57585737
void CClientPed::RunNamedAnimation(std::unique_ptr<CAnimBlock>& pBlock, const char* szAnimName, int iTime, int iBlend, bool bLoop, bool bUpdatePosition,
@@ -5840,6 +5819,10 @@ void CClientPed::RunNamedAnimation(std::unique_ptr<CAnimBlock>& pBlock, const ch
58405819
m_AnimationCache.bUpdatePosition = bUpdatePosition;
58415820
m_AnimationCache.bInterruptable = bInterruptable;
58425821
m_AnimationCache.bFreezeLastFrame = bFreezeLastFrame;
5822+
m_AnimationCache.progress = 0.0f;
5823+
m_AnimationCache.speed = 1.0f;
5824+
m_AnimationCache.progressWaitForStreamIn = false;
5825+
m_AnimationCache.elapsedTime = 0.0f;
58435826
}
58445827

58455828
void CClientPed::KillAnimation()
@@ -5878,45 +5861,39 @@ void CClientPed::RunAnimationFromCache()
58785861
if (!m_pAnimationBlock)
58795862
return;
58805863

5864+
bool needCalcProgress = m_AnimationCache.progressWaitForStreamIn;
5865+
float elapsedTime = m_AnimationCache.elapsedTime;
5866+
58815867
// Copy our name incase it gets deleted
58825868
std::string animName = m_AnimationCache.strName;
58835869

58845870
// Run our animation
58855871
RunNamedAnimation(m_pAnimationBlock, animName.c_str(), m_AnimationCache.iTime, m_AnimationCache.iBlend, m_AnimationCache.bLoop, m_AnimationCache.bUpdatePosition, m_AnimationCache.bInterruptable, m_AnimationCache.bFreezeLastFrame);
58865872

5887-
// Set anim progress & speed
5888-
m_AnimationCache.progressWaitForStreamIn = true;
5889-
}
5890-
5891-
void CClientPed::UpdateAnimationProgressAndSpeed()
5892-
{
5893-
if (!m_AnimationCache.progressWaitForStreamIn)
5894-
return;
5895-
5896-
// Get current anim
5897-
auto animAssoc = g_pGame->GetAnimManager()->RpAnimBlendClumpGetAssociation(GetClump(), m_AnimationCache.strName.c_str());
5873+
auto animAssoc = g_pGame->GetAnimManager()->RpAnimBlendClumpGetAssociation(GetClump(), animName.c_str());
58985874
if (!animAssoc)
58995875
return;
59005876

5901-
float animLength = animAssoc->GetLength();
5902-
float progress = 0.0f;
5903-
float elapsedTime = static_cast<float>(GetTimestamp() - m_AnimationCache.startTime) / 1000.0f;
5904-
5905-
if (m_AnimationCache.bFreezeLastFrame) // time and loop is ignored if freezeLastFrame is true
5906-
progress = (elapsedTime / animLength) * m_AnimationCache.speed;
5907-
else
5877+
// If the anim is synced from the server side, we need to calculate the progress
5878+
float progress = m_AnimationCache.progress;
5879+
if (needCalcProgress)
59085880
{
5909-
if (m_AnimationCache.bLoop)
5910-
progress = std::fmod(elapsedTime * m_AnimationCache.speed, animLength) / animLength;
5881+
float animLength = animAssoc->GetLength();
5882+
5883+
if (m_AnimationCache.bFreezeLastFrame) // time and loop is ignored if freezeLastFrame is true
5884+
progress = (elapsedTime / animLength) * m_AnimationCache.speed;
59115885
else
5912-
// For non-looped animations, limit duration to animLength if time exceeds it
5913-
progress = (elapsedTime / (m_AnimationCache.iTime <= animLength ? m_AnimationCache.iTime : animLength)) * m_AnimationCache.speed;
5886+
{
5887+
if (m_AnimationCache.bLoop)
5888+
progress = std::fmod(elapsedTime * m_AnimationCache.speed, animLength) / animLength;
5889+
else
5890+
// For non-looped animations, limit duration to animLength if time exceeds it
5891+
progress = (elapsedTime / (m_AnimationCache.iTime <= animLength ? m_AnimationCache.iTime : animLength)) * m_AnimationCache.speed;
5892+
}
59145893
}
59155894

59165895
animAssoc->SetCurrentProgress(std::clamp(progress, 0.0f, 1.0f));
59175896
animAssoc->SetCurrentSpeed(m_AnimationCache.speed);
5918-
5919-
m_AnimationCache.progressWaitForStreamIn = false;
59205897
}
59215898

59225899
void CClientPed::PostWeaponFire()

Client/mods/deathmatch/logic/CClientPed.h

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,17 @@ struct SReplacedAnimation
129129

130130
struct SAnimationCache
131131
{
132-
std::string strName;
133-
int iTime{-1};
134-
bool bLoop{false};
135-
bool bUpdatePosition{false};
136-
bool bInterruptable{false};
137-
bool bFreezeLastFrame{true};
138-
int iBlend{250};
139-
float progress{0.0f};
140-
float speed{1.0f};
141-
bool progressWaitForStreamIn{false};
142-
std::int64_t startTime{0};
132+
std::string strName;
133+
int iTime{-1};
134+
bool bLoop{false};
135+
bool bUpdatePosition{false};
136+
bool bInterruptable{false};
137+
bool bFreezeLastFrame{true};
138+
int iBlend{250};
139+
float progress{0.0f};
140+
float speed{1.0f};
141+
bool progressWaitForStreamIn{false}; // for sync anim only
142+
float elapsedTime{0.0f}; // for sync anim only
143143
};
144144

145145
class CClientObject;
@@ -456,18 +456,13 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
456456

457457
bool GetRunningAnimationName(SString& strBlockName, SString& strAnimName);
458458
bool IsRunningAnimation();
459-
460-
// It checks whether the animation is still playing based on time, not on task execution.
461-
bool IsAnimationInProgress();
462-
463459
void RunNamedAnimation(std::unique_ptr<CAnimBlock>& pBlock, const char* szAnimName, int iTime = -1, int iBlend = 250, bool bLoop = true,
464460
bool bUpdatePosition = true, bool bInterruptable = false, bool bFreezeLastFrame = true, bool bRunInSequence = false,
465461
bool bOffsetPed = false, bool bHoldLastFrame = false);
466462
void KillAnimation();
467463
std::unique_ptr<CAnimBlock> GetAnimationBlock();
468464
const SAnimationCache& GetAnimationCache() const noexcept { return m_AnimationCache; }
469465
void RunAnimationFromCache();
470-
void UpdateAnimationProgressAndSpeed();
471466

472467
bool IsUsingGun();
473468

Client/mods/deathmatch/logic/CPacketHandler.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4011,8 +4011,7 @@ void CPacketHandler::Packet_EntityAdd(NetBitStreamInterface& bitStream)
40114011
std::string blockName, animName;
40124012
int time, blendTime;
40134013
bool looped, updatePosition, interruptable, freezeLastFrame, taskRestore;
4014-
float speed;
4015-
double startTime;
4014+
float elapsedTime, speed;
40164015

40174016
// Read data
40184017
bitStream.ReadString(blockName);
@@ -4024,14 +4023,15 @@ void CPacketHandler::Packet_EntityAdd(NetBitStreamInterface& bitStream)
40244023
bitStream.ReadBit(freezeLastFrame);
40254024
bitStream.Read(blendTime);
40264025
bitStream.ReadBit(taskRestore);
4027-
bitStream.Read(startTime);
4026+
bitStream.Read(elapsedTime);
40284027
bitStream.Read(speed);
40294028

40304029
// Run anim
40314030
CStaticFunctionDefinitions::SetPedAnimation(*pPed, blockName, animName.c_str(), time, blendTime, looped, updatePosition, interruptable, freezeLastFrame);
4032-
pPed->m_AnimationCache.startTime = static_cast<std::int64_t>(startTime);
4033-
pPed->m_AnimationCache.speed = speed;
4034-
pPed->m_AnimationCache.progress = 0.0f;
4031+
pPed->m_AnimationCache.progressWaitForStreamIn = true;
4032+
pPed->m_AnimationCache.elapsedTime = elapsedTime;
4033+
4034+
CStaticFunctionDefinitions::SetPedAnimationSpeed(*pPed, animName, speed);
40354035

40364036
pPed->SetHasSyncedAnim(true);
40374037
}

Client/mods/deathmatch/logic/CScriptFile.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ long CScriptFile::Read(unsigned long ulSize, SString& outBuffer)
180180
return m_pFile->FRead(outBuffer.data(), ulSize);
181181
}
182182

183+
long CScriptFile::ReadToBuffer(unsigned char* buffer, unsigned long bufferSize)
184+
{
185+
if (!m_pFile)
186+
return -1;
187+
188+
return m_pFile->FRead(buffer, bufferSize);
189+
}
190+
183191
long CScriptFile::Write(unsigned long ulSize, const char* pData)
184192
{
185193
if (!m_pFile)

Client/mods/deathmatch/logic/CScriptFile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class CScriptFile final : public CClientEntity
6666

6767
void Flush();
6868
long Read(unsigned long ulSize, SString& outBuffer);
69+
long ReadToBuffer(unsigned char* buffer, unsigned long bufferSize);
6970
long Write(unsigned long ulSize, const char* pData);
7071

7172
long GetContents(std::string& buffer);

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,8 +2247,6 @@ bool CStaticFunctionDefinitions::SetPedAnimation(CClientEntity& Entity, const SS
22472247
}
22482248
}
22492249
}
2250-
2251-
Ped.m_AnimationCache.startTime = GetTimestamp();
22522250
}
22532251
else
22542252
{

0 commit comments

Comments
 (0)