Skip to content

Commit

Permalink
Fixed the segfault (#77229)
Browse files Browse the repository at this point in the history
  • Loading branch information
Night-Pryanik authored Oct 21, 2024
1 parent 5762e89 commit 2357a3c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1688,14 +1688,16 @@ static void read()
avatar &player_character = get_avatar();
// Can read items from inventory or within one tile (including in vehicles)
item_location loc = game_menus::inv::read( player_character );
item the_book = *loc.get_item();

if( loc && avatar_action::check_stealing( get_player_character(), the_book ) ) {
if( loc->type->can_use( "learn_spell" ) ) {
the_book.get_use( "learn_spell" )->call( &player_character, the_book, player_character.pos() );
} else {
loc = loc.obtain( player_character );
player_character.read( loc );
if( loc ) {
item the_book = *loc.get_item();
if( avatar_action::check_stealing( get_player_character(), the_book ) ) {
if( loc->type->can_use( "learn_spell" ) ) {
the_book.get_use( "learn_spell" )->call( &player_character, the_book, player_character.pos() );
} else {
loc = loc.obtain( player_character );
player_character.read( loc );
}
}
} else {
add_msg( _( "Never mind." ) );
Expand Down

0 comments on commit 2357a3c

Please sign in to comment.