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: Repair Item activity occasionally encountering a bad pointer when initiated from vehicle/grid #3611

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2688,16 +2688,17 @@ void activity_handlers::repair_item_finish( player_activity *act, player *p )

const std::string iuse_name_string = act->get_str_value( 0, "repair_item" );
repeat_type repeat = static_cast<repeat_type>( act->get_value( 0, REPEAT_INIT ) );
item *ploc = nullptr;
if( !act->targets.empty() && act->targets[0] ) {
ploc = &*act->targets[0];
}

// nullopt if used real tool
std::optional<hack::hack_type_t> hack_type = hack::get_hack_type( *act );
item *fake_tool = nullptr;
// real tool if used.
item *ploc = nullptr;

if( hack_type ) {
fake_tool = hack::get_fake_tool( hack_type.value(), *act );
} else {
ploc = &*act->targets[0];
}
const tripoint hack_position = hack_type ? hack::get_position( *act ) : tripoint{};
const int hack_original_charges = fake_tool ? fake_tool->charges : 0;
Expand Down