From 52d7c730ef81bdffbc701c04c02468eec25fd6a7 Mon Sep 17 00:00:00 2001 From: b3brodie Date: Sun, 13 Oct 2024 15:47:56 -0700 Subject: [PATCH] Swap recipe dictionary to use duplicate entries method --- src/recipe_dictionary.cpp | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/recipe_dictionary.cpp b/src/recipe_dictionary.cpp index 1aa1417a547c4..f02bf464b8a9d 100644 --- a/src/recipe_dictionary.cpp +++ b/src/recipe_dictionary.cpp @@ -441,30 +441,9 @@ recipe &recipe_dictionary::load( const JsonObject &jo, const std::string &src, r.was_loaded = true; // Check for duplicate recipe_ids before assigning it to the map - if( out.find( r.ident() ) != out.end() ) { - const std::string new_mod_src = enumerate_as_string( r.src, []( - const std::pair &source ) { - return string_format( "'%s'", source.second->name() ); - }, enumeration_conjunction::arrow ); - const std::string old_mod_src = enumerate_as_string( out[ r.ident() ].src, []( - const std::pair &source ) { - return string_format( "'%s'", source.second->name() ); - }, enumeration_conjunction::arrow ); - - const std::string base_json = string_format( "'%s'", _( "Dark Days Ahead" ) ); - if( old_mod_src == base_json && new_mod_src != base_json ) { - // Assume the mod developer knows what they're doing - } else if( old_mod_src == new_mod_src ) { - // Conflict within a single source. Throw an error: - debugmsg( "Unable to load recipe_id %1$s. A recipe with that id already exists.\nExisting recipe source: %2$s\nNew recipe source: %3$s", - r.ident().str(), old_mod_src, new_mod_src ); - } else { - // Conflict between mods, leave a warning for debugging - DebugLog( DebugLevel::D_WARNING, - DC_ALL ) << - string_format( "Recipe_id conflict: %1$s is included in both %2$s and %3$s. Only the latter recipe will be loaded", - r.ident().str(), old_mod_src, new_mod_src ); - } + auto duplicate = out.find( r.ident() ); + if( duplicate != out.end() ) { + mod_tracker::check_duplicate_entries(r, duplicate->second); } return out[ r.ident() ] = std::move( r );