Skip to content

Commit

Permalink
fix nullpointer crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Jan 14, 2025
1 parent 88ddfab commit 238e0e4
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions server/src/CSharpResourceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,19 @@ case alt::CEvent::Type::SYNCED_META_CHANGE:
{
auto weaponDamageEvent = dynamic_cast<const alt::CWeaponDamageEvent*>(ev);
auto targetEntity = weaponDamageEvent->GetTarget();
if (targetEntity == nullptr) return;

auto sourceEntityType = alt::IBaseObject::Type::PLAYER;
void* sourceEntityPtr = nullptr;

auto sourceEntity = weaponDamageEvent->GetSourceEntity();

if (targetEntity == nullptr) return;
if (sourceEntity != nullptr)
{
sourceEntityPtr = GetEntityPointer(sourceEntity);
sourceEntityType = sourceEntity->GetType();
}


auto eventShotOffset = weaponDamageEvent->GetShotOffset();
position_t shotOffset = {eventShotOffset[0], eventShotOffset[1], eventShotOffset[2]};
Expand All @@ -347,8 +357,8 @@ case alt::CEvent::Type::SYNCED_META_CHANGE:
weaponDamageEvent->GetDamageValue(),
shotOffset,
weaponDamageEvent->GetBodyPart(),
GetEntityPointer(sourceEntity),
sourceEntity->GetType());
sourceEntityPtr,
sourceEntityType);

break;
}
Expand Down

0 comments on commit 238e0e4

Please sign in to comment.