From c946aed508066dad04d30c2c699d63c54966364c Mon Sep 17 00:00:00 2001 From: ipcyborg Date: Wed, 15 Jan 2020 17:00:11 +0200 Subject: [PATCH] Fixed overlapping vehicle parts check. --- src/vehicle.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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