Skip to content

Commit 08606b2

Browse files
authored
Merge branch 'master' into feature/replace-cj-clothe-model
2 parents 5c5619f + 361e1e2 commit 08606b2

Some content is hidden

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

45 files changed

+2320
-2192
lines changed

Client/game_sa/CBuildingsPoolSA.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ inline bool CBuildingsPoolSA::AddBuildingToPool(CClientBuilding* pClientBuilding
4949
return true;
5050
}
5151

52+
CClientEntity* CBuildingsPoolSA::GetClientBuilding(CBuildingSAInterface* pGameInterface) const noexcept
53+
{
54+
std::uint32_t poolIndex = (*m_ppBuildingPoolInterface)->GetObjectIndex(pGameInterface);
55+
56+
if (poolIndex == static_cast<std::uint32_t>(-1))
57+
return nullptr;
58+
59+
return m_buildingPool.entities[poolIndex].pClientEntity;
60+
}
61+
5262
CBuilding* CBuildingsPoolSA::AddBuilding(CClientBuilding* pClientBuilding, uint16_t modelId, CVector* vPos, CVector4D* vRot, uint8_t interior)
5363
{
5464
if (!HasFreeBuildingSlot())

Client/game_sa/CBuildingsPoolSA.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class CBuildingsPoolSA : public CBuildingsPool
3030
void RestoreBackup() override;
3131
bool Resize(int size) override;
3232
int GetSize() const override { return (*m_ppBuildingPoolInterface)->m_nSize; };
33+
CClientEntity* GetClientBuilding(CBuildingSAInterface* pGameInterface) const noexcept;
3334

3435
private:
3536
void RemoveBuildingFromWorld(CBuildingSAInterface* pBuilding);

Client/game_sa/CPedSA.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,14 @@ void CPedSA::SetHealth(float fHealth)
259259
GetPedInterface()->fHealth = fHealth;
260260
}
261261

262-
float CPedSA::GetArmor()
262+
float CPedSA::GetArmor() noexcept
263263
{
264264
return GetPedInterface()->fArmor;
265265
}
266266

267-
void CPedSA::SetArmor(float fArmor)
267+
void CPedSA::SetArmor(float armor) noexcept
268268
{
269-
GetPedInterface()->fArmor = fArmor;
269+
GetPedInterface()->fArmor = armor;
270270
}
271271

272272
float CPedSA::GetOxygenLevel()

Client/game_sa/CPedSA.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ class CPedSA : public virtual CPed, public virtual CPhysicalSA
313313
float GetHealth();
314314
void SetHealth(float fHealth);
315315

316-
float GetArmor();
317-
void SetArmor(float fArmor);
316+
float GetArmor() noexcept;
317+
void SetArmor(float armor) noexcept;
318318

319319
float GetOxygenLevel();
320320
void SetOxygenLevel(float fOxygen);

Client/game_sa/CPoolsSA.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,12 @@ CClientEntity* CPoolsSA::GetClientEntity(DWORD* pGameInterface)
566566
{
567567
return pThePedEntity->pClientEntity;
568568
}
569+
570+
auto clientBuilding = m_BuildingsPool.GetClientBuilding(reinterpret_cast<CBuildingSAInterface*>(pGameInterface));
571+
if (clientBuilding)
572+
return clientBuilding;
569573
}
570-
return NULL;
574+
return nullptr;
571575
}
572576

573577
static void CreateMissionTrain(const CVector& vecPos, bool bDirection, std::uint32_t uiTrainType, CTrainSAInterface** ppTrainBeginning,

Client/mods/deathmatch/logic/CClientBuilding.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ void CClientBuilding::Create()
133133

134134
m_pBuilding = g_pGame->GetPools()->GetBuildingsPool().AddBuilding(this, m_usModelId, &m_vPos, &vRot4D, m_interior);
135135

136+
if (!m_pBuilding)
137+
return;
138+
139+
m_pBuilding->SetBackfaceCulled(!m_bDoubleSided);
140+
136141
if (!m_usesCollision)
137142
{
138143
m_pBuilding->SetUsesCollision(m_usesCollision);

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3734,6 +3734,9 @@ void CClientGame::StaticGameEntityRenderHandler(CEntitySAInterface* pGameEntity)
37343734
case CCLIENTOBJECT:
37353735
iTypeMask = TYPE_MASK_OBJECT;
37363736
break;
3737+
case CCLIENTBUILDING:
3738+
iTypeMask = TYPE_MASK_WORLD;
3739+
break;
37373740
default:
37383741
iTypeMask = TYPE_MASK_OTHER;
37393742
break;
@@ -4368,7 +4371,7 @@ bool CClientGame::ApplyPedDamageFromGame(eWeaponType weaponUsed, float fDamage,
43684371
{
43694372
float fPreviousHealth = pDamagedPed->m_fHealth;
43704373
float fCurrentHealth = pDamagedPed->GetGamePlayer()->GetHealth();
4371-
float fPreviousArmor = pDamagedPed->m_fArmor;
4374+
float fPreviousArmor = pDamagedPed->m_armor;
43724375
float fCurrentArmor = pDamagedPed->GetGamePlayer()->GetArmor();
43734376

43744377
// Have we taken any damage here?
@@ -4404,7 +4407,7 @@ bool CClientGame::ApplyPedDamageFromGame(eWeaponType weaponUsed, float fDamage,
44044407
{
44054408
// Reget values in case they have been changed during onClientPlayerDamage event (Avoid AC#1 kick)
44064409
fPreviousHealth = pDamagedPed->m_fHealth;
4407-
fPreviousArmor = pDamagedPed->m_fArmor;
4410+
fPreviousArmor = pDamagedPed->m_armor;
44084411
}
44094412
pDamagedPed->GetGamePlayer()->SetHealth(fPreviousHealth);
44104413
pDamagedPed->GetGamePlayer()->SetArmor(fPreviousArmor);
@@ -4450,7 +4453,7 @@ bool CClientGame::ApplyPedDamageFromGame(eWeaponType weaponUsed, float fDamage,
44504453

44514454
// Update our stored health/armor
44524455
pDamagedPed->m_fHealth = fCurrentHealth;
4453-
pDamagedPed->m_fArmor = fCurrentArmor;
4456+
pDamagedPed->m_armor = fCurrentArmor;
44544457

44554458
ElementID damagerID = INVALID_ELEMENT_ID;
44564459
if (pInflictingEntity && !pInflictingEntity->IsLocalEntity())

Client/mods/deathmatch/logic/CClientManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ void CClientManager::DoPulse(bool bDoStandardPulses, bool bDoVehicleManagerPulse
218218
m_pColManager->DoPulse();
219219
m_pGUIManager->DoPulse();
220220
m_pWeaponManager->DoPulse();
221+
m_pRenderElementManager->DoPulse();
221222
}
222223
else
223224
{

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void CClientPed::Init(CClientManager* pManager, unsigned long ulModelID, bool bI
129129
m_uiOccupiedVehicleSeat = 0xFF;
130130
m_bHealthLocked = false;
131131
m_bDontChangeRadio = false;
132-
m_bArmorLocked = false;
132+
m_armorLocked = false;
133133
m_ulLastOnScreenTime = 0;
134134
m_pLoadedModelInfo = NULL;
135135
m_pOutOfVehicleWeaponSlot = WEAPONSLOT_MAX; // WEAPONSLOT_MAX = invalid
@@ -157,7 +157,7 @@ void CClientPed::Init(CClientManager* pManager, unsigned long ulModelID, bool bI
157157
m_bVisible = true;
158158
m_bUsesCollision = true;
159159
m_fHealth = 100.0f;
160-
m_fArmor = 0.0f;
160+
m_armor = 0.0f;
161161
m_bDead = false;
162162
m_bWorldIgnored = false;
163163
m_fCurrentRotation = 0.0f;
@@ -1793,29 +1793,28 @@ void CClientPed::InternalSetHealth(float fHealth)
17931793
}
17941794
}
17951795

1796-
float CClientPed::GetArmor()
1796+
float CClientPed::GetArmor() const noexcept
17971797
{
1798-
if (m_bArmorLocked)
1799-
return m_fArmor;
1798+
if (m_armorLocked)
1799+
return m_armor;
18001800

18011801
if (m_pPlayerPed)
1802-
{
18031802
return m_pPlayerPed->GetArmor();
1804-
}
1805-
return m_fArmor;
1803+
1804+
return m_armor;
18061805
}
18071806

1808-
void CClientPed::SetArmor(float fArmor)
1807+
void CClientPed::SetArmor(float armor) noexcept
18091808
{
1810-
// If our armor is locked, dont allow any change
1811-
if (m_bArmorLocked)
1809+
if (m_armorLocked)
18121810
return;
18131811

1812+
armor = std::clamp(armor, 0.0f, 100.0f);
1813+
18141814
if (m_pPlayerPed)
1815-
{
1816-
m_pPlayerPed->SetArmor(fArmor);
1817-
}
1818-
m_fArmor = fArmor;
1815+
m_pPlayerPed->SetArmor(armor);
1816+
1817+
m_armor = armor;
18191818
}
18201819

18211820
void CClientPed::LockHealth(float fHealth)
@@ -1824,10 +1823,10 @@ void CClientPed::LockHealth(float fHealth)
18241823
m_fHealth = fHealth;
18251824
}
18261825

1827-
void CClientPed::LockArmor(float fArmor)
1826+
void CClientPed::LockArmor(float armor) noexcept
18281827
{
1829-
m_bArmorLocked = true;
1830-
m_fArmor = fArmor;
1828+
m_armorLocked = true;
1829+
m_armor = armor;
18311830
}
18321831

18331832
float CClientPed::GetOxygenLevel()
@@ -2772,9 +2771,9 @@ void CClientPed::StreamedInPulse(bool bDoStandardPulses)
27722771
}
27732772

27742773
// Is our armor locked?
2775-
if (m_bArmorLocked)
2774+
if (m_armorLocked)
27762775
{
2777-
m_pPlayerPed->SetArmor(m_fArmor);
2776+
m_pPlayerPed->SetArmor(m_armor);
27782777
}
27792778

27802779
// In a vehicle?
@@ -3334,14 +3333,20 @@ void CClientPed::SetTargetRotation(float fRotation)
33343333
SetCurrentRotation(fRotation);
33353334
}
33363335

3337-
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)
33383337
{
33393338
m_ulBeginRotationTime = CClientTime::GetTime();
33403339
m_ulEndRotationTime = m_ulBeginRotationTime + ulDelay;
3341-
m_fBeginRotation = (m_pPlayerPed) ? m_pPlayerPed->GetCurrentRotation() : m_fCurrentRotation;
3342-
m_fTargetRotationA = fRotation;
3343-
m_fBeginCameraRotation = GetCameraRotation();
3344-
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+
}
33453350
}
33463351

33473352
// Temporary
@@ -3623,7 +3628,7 @@ void CClientPed::_CreateModel()
36233628
m_pPlayerPed->SetVisible(m_bVisible);
36243629
m_pPlayerPed->SetUsesCollision(m_bUsesCollision);
36253630
m_pPlayerPed->SetHealth(m_fHealth);
3626-
m_pPlayerPed->SetArmor(m_fArmor);
3631+
m_pPlayerPed->SetArmor(m_armor);
36273632
m_pPlayerPed->SetLighting(m_fLighting);
36283633
WorldIgnore(m_bWorldIgnored);
36293634

@@ -4225,10 +4230,10 @@ bool CClientPed::PerformChecks()
42254230
// The player should not be able to gain any health/armor without us knowing..
42264231
// meaning all health/armor giving must go through SetHealth/SetArmor.
42274232
if ((m_fHealth > 0.0f && m_pPlayerPed->GetHealth() > m_fHealth + FLOAT_EPSILON) ||
4228-
(m_fArmor < 100.0f && m_pPlayerPed->GetArmor() > m_fArmor + FLOAT_EPSILON))
4233+
(m_armor < 100.0f && m_pPlayerPed->GetArmor() > m_armor + FLOAT_EPSILON))
42294234
{
42304235
g_pCore->GetConsole()->Printf("healthCheck: %f %f", m_pPlayerPed->GetHealth(), m_fHealth);
4231-
g_pCore->GetConsole()->Printf("armorCheck: %f %f", m_pPlayerPed->GetArmor(), m_fArmor);
4236+
g_pCore->GetConsole()->Printf("armorCheck: %f %f", m_pPlayerPed->GetArmor(), m_armor);
42324237
return false;
42334238
}
42344239
// Perform the checks in CGame

Client/mods/deathmatch/logic/CClientPed.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ struct SLastSyncedPedData
105105
CVector vPosition;
106106
CVector vVelocity;
107107
float fRotation;
108+
float cameraRotation{};
108109
bool bOnFire;
109110
bool bIsInWater;
110111
bool isReloadingWeapon;
@@ -205,7 +206,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
205206
float GetCurrentRotation();
206207
void SetCurrentRotation(float fRotation, bool bIncludeTarget = true);
207208
void SetTargetRotation(float fRotation);
208-
void SetTargetRotation(unsigned long ulDelay, float fRotation, float fCameraRotation);
209+
void SetTargetRotation(unsigned long ulDelay, std::optional<float> rotation, std::optional<float> cameraRotation);
209210

210211
float GetCameraRotation();
211212
void SetCameraRotation(float fRotation);
@@ -267,17 +268,17 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
267268
float GetHealth();
268269
void SetHealth(float fHealth);
269270
void InternalSetHealth(float fHealth);
270-
float GetArmor();
271-
void SetArmor(float fArmor);
271+
float GetArmor() const noexcept;
272+
void SetArmor(float armor) noexcept;
272273
float GetOxygenLevel();
273274
void SetOxygenLevel(float fOxygen);
274275

275276
void LockHealth(float fHealth);
276-
void LockArmor(float fArmor);
277+
void LockArmor(float armor) noexcept;
277278
void UnlockHealth() noexcept { m_bHealthLocked = false; };
278-
void UnlockArmor() noexcept { m_bArmorLocked = false; };
279+
void UnlockArmor() noexcept { m_armorLocked = false; };
279280
bool IsHealthLocked() const noexcept { return m_bHealthLocked; };
280-
bool IsArmorLocked() const noexcept { return m_bArmorLocked; };
281+
bool IsArmorLocked() const noexcept { return m_armorLocked; };
281282

282283
bool IsDying();
283284
bool IsDead();
@@ -619,7 +620,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
619620
bool m_bRadioOn;
620621
unsigned char m_ucRadioChannel;
621622
bool m_bHealthLocked;
622-
bool m_bArmorLocked;
623+
bool m_armorLocked;
623624
unsigned long m_ulLastOnScreenTime;
624625
CClientVehiclePtr m_pOccupiedVehicle;
625626
CClientVehiclePtr m_pOccupyingVehicle;
@@ -678,7 +679,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
678679
bool m_bVisible;
679680
bool m_bUsesCollision;
680681
float m_fHealth;
681-
float m_fArmor;
682+
float m_armor;
682683
bool m_bDead;
683684
bool m_bWorldIgnored;
684685
float m_fCurrentRotation;

0 commit comments

Comments
 (0)