Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 27487: Ensure vehicle loot zone has corresponding cargo part on refresh #28142

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5353,7 +5353,16 @@ bool vehicle::refresh_zones()
zone_data zone = z.second;
//Get the global position of the first cargo part at the relative coordinate

tripoint zone_pos = global_part_pos3( part_with_feature( z.first, "CARGO", false ) );
const int part_idx = part_with_feature( z.first, "CARGO", false );
if( part_idx == -1 ) {
debugmsg( "Could not find cargo part at %d,%d on vehicle %s for loot zone. Removing loot zone.",
z.first.x, z.first.y, this->name.c_str() );

// If this loot zone refers to a part that no longer exists at this location, then its unattached somehow.
// By continuing here and not adding to new_zones, we effectively remove it
continue;
}
tripoint zone_pos = global_part_pos3( part_idx );
zone_pos = g->m.getabs( zone_pos );
//Set the position of the zone to that part
zone.set_position( std::pair<tripoint, tripoint>( zone_pos, zone_pos ), false );
Expand Down