Skip to content

Commit 671a758

Browse files
fix nullptr crash when debris collides with ship (#6896)
1 parent 9718e70 commit 671a758

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

code/object/collideshipship.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,13 +751,15 @@ void calculate_ship_ship_collision_physics(collision_info_struct *ship_ship_hit_
751751
// physics should not have to recalculate this, just change into body coords (done in collide_whack)
752752
// Cyborg - to complicate this, multiplayer clients should never ever whack non-player ships.
753753
if (should_collide){
754+
auto light_rot_mag = light_sip ? light_sip->collision_physics.rotation_mag_max : -1.0f;
754755
vm_vec_scale(&impulse, impulse_mag);
755756
vm_vec_scale(&delta_rotvel_light, impulse_mag);
756-
physics_collide_whack(&impulse, &delta_rotvel_light, &lighter->phys_info, &lighter->orient, ship_ship_hit_info->is_landing, light_sip->collision_physics.rotation_mag_max);
757+
physics_collide_whack(&impulse, &delta_rotvel_light, &lighter->phys_info, &lighter->orient, ship_ship_hit_info->is_landing, light_rot_mag);
757758

759+
auto heavy_rot_mag = heavy_sip ? heavy_sip->collision_physics.rotation_mag_max : -1.0f;
758760
vm_vec_negate(&impulse);
759761
vm_vec_scale(&delta_rotvel_heavy, -impulse_mag);
760-
physics_collide_whack(&impulse, &delta_rotvel_heavy, &heavy->phys_info, &heavy->orient, true, heavy_sip->collision_physics.rotation_mag_max);
762+
physics_collide_whack(&impulse, &delta_rotvel_heavy, &heavy->phys_info, &heavy->orient, true, heavy_rot_mag);
761763
}
762764

763765
// If within certain bounds, we want to add some more rotation towards the "resting orientation" of the ship

0 commit comments

Comments
 (0)