Skip to content

Commit

Permalink
fix: Voiding and recycling messed up detection of barrelling recipes. (
Browse files Browse the repository at this point in the history
…#407)

Filled barrels and and barrel-filling recipes were considered normal
because filled barrels could be recycled. While this is a valid way to
void unwanted fluids, it isn't enough to make them into normal
items/recipes.

I expected to see some benefit in Py too, but Yafc's rules say Py's
"voiding" recipes are valid sources of Ash.
  • Loading branch information
shpaass authored Feb 7, 2025
2 parents f3603ca + 8978dd4 commit ea84e56
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Yafc.Parser/Data/FactorioDataDeserializer_Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -564,14 +564,17 @@ private void CalculateMaps(bool netProduction) {
mechanic.iconSpec = mechanic.source.iconSpec;
}

// step 3 - detect packing/unpacking (e.g. barreling/unbarreling, stacking/unstacking, etc.) and voiding recipes
// step 3a - detect voiding recipes
// Do this first so voiding recipes don't re-normalize packed items/fluids.
foreach (var recipe in allRecipes) {
if (recipe.specialType != FactorioObjectSpecialType.Normal) {
continue;
}

if (recipe.products.Length == 0) {
recipe.specialType = FactorioObjectSpecialType.Voiding;
}
}

// step 3b - detect packing/unpacking (e.g. barreling/unbarreling, stacking/unstacking, etc.) recipes
foreach (var recipe in allRecipes) {
if (recipe.specialType != FactorioObjectSpecialType.Normal) {
continue;
}

Expand Down Expand Up @@ -642,8 +645,12 @@ private void CalculateMaps(bool netProduction) {
fluid.locName += " " + fluid.temperature + "°";
}
}

// The recipes added by deadlock_stacked_recipes (with CompressedFluids, if present) need to be filtered out to get decent results.
static int countNonDsrRecipes(IEnumerable<Recipe> recipes) => recipes.Count(r => !r.name.Contains("StackedRecipe-") && !r.name.Contains("DSR_HighPressure-"));
// Also exclude recycling and voiding recipes: "I can recycle water barrels" does not count as "used in other recipes". (up ~25 lines)
static int countNonDsrRecipes(IEnumerable<Recipe> recipes)
=> recipes.Count(r => !r.name.Contains("StackedRecipe-") && !r.name.Contains("DSR_HighPressure-")
&& r.specialType is not FactorioObjectSpecialType.Recycling and not FactorioObjectSpecialType.Voiding);
}

private Recipe CreateSpecialRecipe(FactorioObject production, string category, string hint) {
Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Date:
- Detect lightning rods/collectors as electricity sources, and estimate the required accumulator count.
Fixes:
- When creating launch recipes, obey the rocket capacity, not the item stack size.
- Improve detection of special (e.g. barrelling, caging) recipes, especially with SA's recycling recipes.
----------------------------------------------------------------------------------------------------------------------
Version: 2.7.0
Date: January 27th 2025
Expand Down

0 comments on commit ea84e56

Please sign in to comment.