diff --git a/src/vehicle.cpp b/src/vehicle.cpp index b062608ab105b..02c2d76ed6c8e 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -997,9 +997,11 @@ void vehicle::smash( map &m, float hp_percent_loss_min, float hp_percent_loss_ma if( p == other_p ) { continue; } - if( ( part_info( p ).location.empty() && - part_info( p ).get_id() == part_info( other_p ).get_id() ) || - ( part_info( p ).location == part_info( other_p ).location ) ) { + const vpart_info &p_info = part_info( p ); + const vpart_info &other_p_info = part_info( other_p ); + + if( p_info.get_id() == other_p_info.get_id() || + ( !p_info.location.empty() && p_info.location == other_p_info.location ) ) { // Deferred creation of the handler to here so it is only created when actually needed. if( !handler_ptr ) { // This is a heuristic: we just assume the default handler is good enough when called