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

[Player] cache find_spell lookups #6563

Open
wants to merge 1 commit into
base: shadowlands
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions engine/player/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10250,9 +10250,15 @@ const spell_data_t* player_t::find_spell( unsigned int id ) const
{
if ( id )
{
auto spell_cache_entry = spell_cache.find( id );
if ( spell_cache_entry != spell_cache.end() ) {
return spell_cache_entry->second;
}

auto spell = dbc::find_spell( this, id );
if ( spell->id() && as<int>( spell->level() ) <= true_level )
{
spell_cache[id] = spell;
return spell;
}
}
Expand Down
1 change: 1 addition & 0 deletions engine/player/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ struct player_t : public actor_t
resource_callback_function_t callback;
};
std::vector<resource_callback_entry_t> resource_callbacks;
mutable std::unordered_map<unsigned int, const spell_data_t*> spell_cache;

/// Per-player custom dbc data
std::unique_ptr<dbc_override_t> dbc_override_;
Expand Down