Skip to content

Commit

Permalink
Don't try to get non-existent spellbook spells
Browse files Browse the repository at this point in the history
  • Loading branch information
RenechCDDA committed May 15, 2024
1 parent e3c105a commit 7d3394b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2118,6 +2118,8 @@ spell &known_magic::get_spell( const spell_id &sp )
{
if( !knows_spell( sp ) ) {
debugmsg( "ERROR: Tried to get unknown spell" );
spell null;
return null; // Don't make up new spells in our spellbook

Check failure on line 2122 in src/magic.cpp

View workflow job for this annotation

GitHub Actions / build (src)

Address of stack memory associated with local variable 'null' returned to caller [clang-analyzer-core.StackAddressEscape,-warnings-as-errors]

Check failure on line 2122 in src/magic.cpp

View workflow job for this annotation

GitHub Actions / build (src)

reference to stack memory associated with local variable 'null' returned [clang-diagnostic-return-stack-address,-warnings-as-errors]

Check failure on line 2122 in src/magic.cpp

View workflow job for this annotation

GitHub Actions / Basic Build and Test (Clang 10, Ubuntu, Curses)

reference to stack memory associated with local variable 'null' returned [-Werror,-Wreturn-stack-address]
}
spell &temp_spell = spellbook[ sp ];
return temp_spell;
Expand Down
2 changes: 1 addition & 1 deletion src/player_activity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ std::optional<std::string> player_activity::get_progress_message( const avatar &
}

if( type == ACT_SPELLCASTING ) {
const std::string spell_name = u.magic->get_spell( spell_id( name ) ).name();
const std::string spell_name = spell_id( name )->name.translated();
extra_info = string_format( "%s …", spell_name );
}
}
Expand Down

0 comments on commit 7d3394b

Please sign in to comment.