Skip to content

Commit

Permalink
Fix ASan error, suppress more checks (#72900)
Browse files Browse the repository at this point in the history
* Hopefully no shadowy bytes

* No u

* Update src/mutation_data.cpp

Co-authored-by: Brambor <[email protected]>

---------

Co-authored-by: Brambor <[email protected]>
  • Loading branch information
Venera3 and Brambor authored Apr 9, 2024
1 parent fe6bfdd commit ac2d4a7
Showing 1 changed file with 16 additions and 9 deletions.
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() &&
!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

0 comments on commit ac2d4a7

Please sign in to comment.