Skip to content

Commit 3c33e87

Browse files
Synchronize changes from 1.6 master branch [ci skip]
2d3397d Fix crash by delaying ped recreation (PR #3914, Fixes #472)
2 parents 42a4863 + 2d3397d commit 3c33e87

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4404,12 +4404,9 @@ bool CClientGame::ApplyPedDamageFromGame(eWeaponType weaponUsed, float fDamage,
44044404
return false;
44054405
}
44064406

4407-
if (pDamagedPed->IsLocalPlayer())
4408-
{
4409-
// Reget values in case they have been changed during onClientPlayerDamage event (Avoid AC#1 kick)
4410-
fCurrentHealth = pDamagedPed->GetGamePlayer()->GetHealth();
4411-
fCurrentArmor = pDamagedPed->GetGamePlayer()->GetArmor();
4412-
}
4407+
// Reget values in case they have been changed during onClientPlayerDamage/onClientPedDamage event (Avoid AC#1 kick)
4408+
fCurrentHealth = pDamagedPed->GetGamePlayer()->GetHealth();
4409+
fCurrentArmor = pDamagedPed->GetGamePlayer()->GetArmor();
44134410

44144411
bool bIsBeingShotWhilstAiming = (weaponUsed >= WEAPONTYPE_PISTOL && weaponUsed <= WEAPONTYPE_MINIGUN && pDamagedPed->IsUsingGun());
44154412
bool bOldBehaviour = !IsGlitchEnabled(GLITCH_HITANIM);

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,6 +2705,10 @@ void CClientPed::StreamedInPulse(bool bDoStandardPulses)
27052705
return;
27062706
}
27072707

2708+
// Re-create ped
2709+
if (m_shouldRecreate)
2710+
ReCreateGameEntity();
2711+
27082712
// Grab some vars here, saves getting them twice
27092713
CClientVehicle* pVehicle = GetOccupiedVehicle();
27102714

@@ -3974,11 +3978,7 @@ void CClientPed::_ChangeModel()
39743978
{
39753979
// ChrML: Changing the skin in certain cases causes player sliding. So we recreate instead.
39763980

3977-
// Kill the old player
3978-
_DestroyModel();
3979-
3980-
// Create the new with the new skin
3981-
_CreateModel();
3981+
m_shouldRecreate = true;
39823982
}
39833983

39843984
// ReAttach satchels
@@ -4012,11 +4012,7 @@ void CClientPed::ReCreateModel()
40124012
m_pLoadedModelInfo->ModelAddRef(BLOCKING, "CClientPed::ReCreateModel");
40134013
}
40144014

4015-
// Destroy the old model
4016-
_DestroyModel();
4017-
4018-
// Create the new model
4019-
_CreateModel();
4015+
m_shouldRecreate = true;
40204016

40214017
// Remove the reference we temporarily added again
40224018
if (bSameModel)
@@ -4026,6 +4022,20 @@ void CClientPed::ReCreateModel()
40264022
}
40274023
}
40284024

4025+
void CClientPed::ReCreateGameEntity()
4026+
{
4027+
if (!m_shouldRecreate || !m_pPlayerPed)
4028+
return;
4029+
4030+
// Destroy current game entity
4031+
_DestroyModel();
4032+
4033+
// Create the new game entity
4034+
_CreateModel();
4035+
4036+
m_shouldRecreate = false;
4037+
}
4038+
40294039
void CClientPed::ModelRequestCallback(CModelInfo* pModelInfo)
40304040
{
40314041
// If we have a player loaded

Client/mods/deathmatch/logic/CClientPed.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
566566

567567
// Used to destroy the current game ped and create a new one in the same state.
568568
void ReCreateModel();
569+
void ReCreateGameEntity();
569570

570571
void _CreateModel();
571572
void _CreateLocalModel();
@@ -725,6 +726,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
725726
bool m_bPendingRebuildPlayer;
726727
uint m_uiFrameLastRebuildPlayer;
727728
bool m_bIsSyncing;
729+
bool m_shouldRecreate{false};
728730

729731
bool m_bBulletImpactData;
730732
CClientEntityPtr m_pBulletImpactEntity;

0 commit comments

Comments
 (0)