Skip to content

Commit afeb30d

Browse files
committed
Write debug information about ped before crashing
1 parent c0bb578 commit afeb30d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4415,6 +4415,24 @@ bool CClientGame::DamageHandler(CPed* pDamagePed, CEventDamage* pEvent)
44154415
bool CClientGame::ApplyPedDamageFromGame(eWeaponType weaponUsed, float fDamage, uchar hitZone, CClientPed* pDamagedPed, CClientEntity* pInflictingEntity,
44164416
CEventDamage* pEvent)
44174417
{
4418+
if (pDamagedPed->GetGamePlayer() == nullptr)
4419+
{
4420+
// Shouldn't happen, but it does anyway. Log some information about the damaged ped and the ped pool; and then crash optionally
4421+
auto entityType = static_cast<int>(pDamagedPed->GetType());
4422+
bool isInVehicle = pDamagedPed->IsInVehicle();
4423+
bool isDead = pDamagedPed->IsDead();
4424+
bool isLocalPlayer = pDamagedPed->IsLocalPlayer();
4425+
unsigned long pedCount = g_pGame->GetPools()->GetPedCount();
4426+
4427+
WriteDebugEvent(
4428+
SString("CClientGame::ApplyPedDamageFromGame: GetGamePlayer() == nullptr (type: %d, inVehicle: %d, isDead: %d, isLocalPlayer: %d, pedCount: %lu)",
4429+
entityType, isInVehicle, isDead, isLocalPlayer, pedCount));
4430+
4431+
// Crash on purpose to gather crash information for this offset and not somewhere else
4432+
assert(false);
4433+
return false;
4434+
}
4435+
44184436
float fPreviousHealth = pDamagedPed->m_fHealth;
44194437
float fCurrentHealth = pDamagedPed->GetGamePlayer()->GetHealth();
44204438
float fPreviousArmor = pDamagedPed->m_fArmor;

0 commit comments

Comments
 (0)