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

Trivial: speedup npc::get_monster_faction #45423

Merged
merged 1 commit into from
Nov 15, 2020
Merged
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
2 changes: 1 addition & 1 deletion src/faction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ faction_template::faction_template( const JsonObject &jsobj )
}
lone_wolf_faction = jsobj.get_bool( "lone_wolf_faction", false );
load_relations( jsobj );
mon_faction = jsobj.get_string( "mon_faction", "human" );
mon_faction = mfaction_str_id( jsobj.get_string( "mon_faction", "human" ) );
for( const JsonObject jao : jsobj.get_array( "epilogues" ) ) {
epilogue_data.emplace( jao.get_int( "power_min", std::numeric_limits<int>::min() ),
jao.get_int( "power_max", std::numeric_limits<int>::max() ),
Expand Down
2 changes: 1 addition & 1 deletion src/faction.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class faction_template
bool lone_wolf_faction; // is this a faction for just one person?
itype_id currency; // id of the faction currency
std::map<std::string, std::bitset<npc_factions::rel_types>> relations;
std::string mon_faction; // mon_faction_id of the monster faction; defaults to human
mfaction_str_id mon_faction; // mon_faction_id of the monster faction; defaults to human
std::set<std::tuple<int, int, snippet_id>> epilogue_data;
};

Expand Down
5 changes: 2 additions & 3 deletions src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2959,9 +2959,8 @@ std::set<tripoint> npc::get_path_avoid() const
mfaction_id npc::get_monster_faction() const
{
if( my_fac ) {
string_id<monfaction> my_mon_fac = string_id<monfaction>( my_fac->mon_faction );
if( my_mon_fac.is_valid() ) {
return my_mon_fac;
if( my_fac->mon_faction.is_valid() ) {
return my_fac->mon_faction;
}
}

Expand Down