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 ASan error, suppress more checks #72900

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Changes from 2 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
25 changes: 16 additions & 9 deletions src/mutation_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,8 @@ void mutation_branch::check_consistency()
{
for( const mutation_branch &mdata : get_all() ) {
const trait_id &mid = mdata.id;
const mod_id &trait_source = mdata.src.back().second;
const bool basegame_trait = trait_source.str() == "dda";
const std::optional<scenttype_id> &s_id = mdata.scent_typeid;
const std::map<species_id, int> &an_id = mdata.anger_relations;
for( const auto &style : mdata.initial_ma_styles ) {
Expand All @@ -676,10 +678,13 @@ void mutation_branch::check_consistency()
if( s_id && !s_id.value().is_valid() ) {
debugmsg( "mutation %s refers to undefined scent type %s", mid.c_str(), s_id.value().c_str() );
}
// Suppress these onload warnings for overlapping mods
for( const trait_id &replacement : mdata.replacements ) {
const mutation_branch &rdata = replacement.obj();
bool suppressed = rdata.src.back().second != trait_source && !basegame_trait;
for( const mutation_category_id &cat : rdata.category ) {
if( std::find( mdata.category.begin(), mdata.category.end(), cat ) == mdata.category.end() ) {
if( std::find( mdata.category.begin(), mdata.category.end(), cat ) == mdata.category.end() &&
Venera3 marked this conversation as resolved.
Show resolved Hide resolved
!suppressed ) {
debugmsg( "mutation %s lacks category %s present in replacement mutation %s", mid.c_str(),
cat.c_str(), replacement.c_str() );
}
Expand All @@ -691,41 +696,43 @@ void mutation_branch::check_consistency()
}
const mutation_branch &adata = addition.obj();
bool found = false;
bool suppressed = adata.src.back().second != trait_source && !basegame_trait;
for( const mutation_category_id &cat : adata.category ) {
found = found ||
std::find( mdata.category.begin(), mdata.category.end(), cat ) != mdata.category.end();
}
if( !found ) {
if( !found && !suppressed ) {
debugmsg( "categories in mutation %s don't match any category present in additive mutation %s",
mid.c_str(), addition.c_str() );
}
}

// Suppress this check for trait/prereq combos from different mod sources
for( const mutation_category_id &cat_id : mdata.category ) {
if( !mdata.prereqs.empty() ) {
bool found = false;
bool suppressed = false;
for( const trait_id &prereq_id : mdata.prereqs ) {
const mutation_branch &prereq = prereq_id.obj();
suppressed = suppressed || ( prereq.src.back().second != trait_source && !basegame_trait );
found = found ||
std::find( prereq.category.begin(), prereq.category.end(), cat_id ) != prereq.category.end() ||
mdata.src.end()->second != prereq.src.end()->second;
std::find( prereq.category.begin(), prereq.category.end(), cat_id ) != prereq.category.end();
}
if( !found ) {
if( !found && !suppressed ) {
debugmsg( "mutation %s is in category %s but none of its slot 1 prereqs have this category",
mid.c_str(), cat_id.c_str() );
}
}

if( !mdata.prereqs2.empty() ) {
bool found = false;
bool suppressed = false;
for( const trait_id &prereq_id : mdata.prereqs2 ) {
const mutation_branch &prereq = prereq_id.obj();
suppressed = suppressed || ( prereq.src.back().second != trait_source && !basegame_trait );
found = found ||
std::find( prereq.category.begin(), prereq.category.end(), cat_id ) != prereq.category.end() ||
mdata.src.end()->second != prereq.src.end()->second;
std::find( prereq.category.begin(), prereq.category.end(), cat_id ) != prereq.category.end();
}
if( !found ) {
if( !found && !suppressed ) {
debugmsg( "mutation %s is in category %s but none of its slot 2 prereqs have this category",
mid.c_str(), cat_id.c_str() );
}
Expand Down
Loading