Skip to content

Commit

Permalink
Merge pull request #51744 from jbytheway/mandatory_categories
Browse files Browse the repository at this point in the history
Force recipes to provide (sub)category
  • Loading branch information
kevingranade authored Sep 23, 2021
2 parents 81960cd + 04bdea5 commit 34ca637
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions data/mods/Magiclysm/recipes/blacksmithing.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"type": "recipe",
"activity_level": "fake",
"category": "CC_OTHER",
"subcategory": "CSC_OTHER_MATERIALS",
"skill_used": "fabrication",
"difficulty": 5,
"time": "180 m",
Expand Down
10 changes: 5 additions & 5 deletions src/recipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ void recipe::load( const JsonObject &jo, const std::string &src )

if( type == "recipe" ) {

assign( jo, "category", category, strict );
assign( jo, "subcategory", subcategory, strict );
mandatory( jo, was_loaded, "category", category );
mandatory( jo, was_loaded, "subcategory", subcategory );
assign( jo, "description", description, strict );
assign( jo, "reversible", reversible, strict );

Expand Down Expand Up @@ -377,10 +377,10 @@ void recipe::load( const JsonObject &jo, const std::string &src )
}
} else if( type == "practice" ) {
mandatory( jo, false, "name", name_ );
assign( jo, "category", category, strict );
assign( jo, "subcategory", subcategory, strict );
mandatory( jo, was_loaded, "category", category );
mandatory( jo, was_loaded, "subcategory", subcategory );
assign( jo, "description", description, strict );
mandatory( jo, false, "practice_data", practice_data );
mandatory( jo, was_loaded, "practice_data", practice_data );

if( jo.has_member( "byproducts" ) ) {
byproducts.clear();
Expand Down
1 change: 1 addition & 0 deletions src/recipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class recipe
return result_;
}

bool was_loaded = false;
bool obsolete = false;

std::string category;
Expand Down
1 change: 1 addition & 0 deletions src/recipe_dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ recipe &recipe_dictionary::load( const JsonObject &jo, const std::string &src,
}

r.load( jo, src );
r.was_loaded = true;

return out[ r.ident() ] = std::move( r );
}
Expand Down

0 comments on commit 34ca637

Please sign in to comment.